|
Mark McLoughlin |
c034c1 |
From 165fb333c9d954fec636dc0f1917ba50417478c0 Mon Sep 17 00:00:00 2001
|
|
Mark McLoughlin |
c034c1 |
From: Mark McLoughlin <markmc@redhat.com>
|
|
Mark McLoughlin |
c034c1 |
Date: Sat, 15 Aug 2009 19:38:15 +0100
|
|
Mark McLoughlin |
c034c1 |
Subject: [PATCH] Fix list updating after disk/network hot-unplug
|
|
Mark McLoughlin |
c034c1 |
|
|
Mark McLoughlin |
c034c1 |
The current code makes a poor effort at updating the device arrays after
|
|
Mark McLoughlin |
c034c1 |
hot-unplug. Fix that and combine the two code paths into one.
|
|
Mark McLoughlin |
c034c1 |
|
|
Mark McLoughlin |
c034c1 |
* src/qemu_driver.c: fix list updating in qemudDomainDetachNetDevice() and
|
|
Mark McLoughlin |
c034c1 |
qemudDomainDetachPciDiskDevice()
|
|
Mark McLoughlin |
c034c1 |
|
|
Mark McLoughlin |
c034c1 |
(cherry picked from commit 4e12af5623e4a962a6bb911af06fa29aa85befba)
|
|
Mark McLoughlin |
c034c1 |
|
|
Mark McLoughlin |
c034c1 |
Fedora-patch: libvirt-fix-device-list-update-after-detach.patch
|
|
Mark McLoughlin |
c034c1 |
---
|
|
Mark McLoughlin |
c034c1 |
src/qemu_driver.c | 38 ++++++++++++++++++--------------------
|
|
Mark McLoughlin |
c034c1 |
1 files changed, 18 insertions(+), 20 deletions(-)
|
|
Mark McLoughlin |
c034c1 |
|
|
Mark McLoughlin |
c034c1 |
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
|
|
Mark McLoughlin |
c034c1 |
index bd58435..2c4fd6f 100644
|
|
Mark McLoughlin |
c034c1 |
--- a/src/qemu_driver.c
|
|
Mark McLoughlin |
c034c1 |
+++ b/src/qemu_driver.c
|
|
Mark McLoughlin |
c034c1 |
@@ -5404,18 +5404,17 @@ try_command:
|
|
Mark McLoughlin |
c034c1 |
goto cleanup;
|
|
Mark McLoughlin |
c034c1 |
}
|
|
Mark McLoughlin |
c034c1 |
|
|
Mark McLoughlin |
c034c1 |
- if (vm->def->ndisks > 1) {
|
|
Mark McLoughlin |
c034c1 |
- vm->def->disks[i] = vm->def->disks[--vm->def->ndisks];
|
|
Mark McLoughlin |
c034c1 |
- if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks) < 0) {
|
|
Mark McLoughlin |
c034c1 |
- virReportOOMError(conn);
|
|
Mark McLoughlin |
c034c1 |
- goto cleanup;
|
|
Mark McLoughlin |
c034c1 |
- }
|
|
Mark McLoughlin |
c034c1 |
- qsort(vm->def->disks, vm->def->ndisks, sizeof(*vm->def->disks),
|
|
Mark McLoughlin |
c034c1 |
- virDomainDiskQSort);
|
|
Mark McLoughlin |
c034c1 |
- } else {
|
|
Mark McLoughlin |
c034c1 |
- VIR_FREE(vm->def->disks[0]);
|
|
Mark McLoughlin |
c034c1 |
- vm->def->ndisks = 0;
|
|
Mark McLoughlin |
c034c1 |
+ if (i != --vm->def->ndisks)
|
|
Mark McLoughlin |
c034c1 |
+ memmove(&vm->def->disks[i],
|
|
Mark McLoughlin |
c034c1 |
+ &vm->def->disks[i+1],
|
|
Mark McLoughlin |
c034c1 |
+ sizeof(*vm->def->disks) * (vm->def->ndisks-i));
|
|
Mark McLoughlin |
c034c1 |
+ if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks) < 0) {
|
|
Mark McLoughlin |
c034c1 |
+ virReportOOMError(conn);
|
|
Mark McLoughlin |
c034c1 |
+ goto cleanup;
|
|
Mark McLoughlin |
c034c1 |
}
|
|
Mark McLoughlin |
c034c1 |
+ qsort(vm->def->disks, vm->def->ndisks, sizeof(*vm->def->disks),
|
|
Mark McLoughlin |
c034c1 |
+ virDomainDiskQSort);
|
|
Mark McLoughlin |
c034c1 |
+
|
|
Mark McLoughlin |
c034c1 |
ret = 0;
|
|
Mark McLoughlin |
c034c1 |
|
|
Mark McLoughlin |
c034c1 |
cleanup:
|
|
Mark McLoughlin |
c034c1 |
@@ -5503,16 +5502,15 @@ qemudDomainDetachNetDevice(virConnectPtr conn,
|
|
Mark McLoughlin |
c034c1 |
|
|
Mark McLoughlin |
c034c1 |
DEBUG("%s: host_net_remove reply: %s", vm->def->name, reply);
|
|
Mark McLoughlin |
c034c1 |
|
|
Mark McLoughlin |
c034c1 |
- if (vm->def->nnets > 1) {
|
|
Mark McLoughlin |
c034c1 |
- vm->def->nets[i] = vm->def->nets[--vm->def->nnets];
|
|
Mark McLoughlin |
c034c1 |
- if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets) < 0) {
|
|
Mark McLoughlin |
c034c1 |
- virReportOOMError(conn);
|
|
Mark McLoughlin |
c034c1 |
- goto cleanup;
|
|
Mark McLoughlin |
c034c1 |
- }
|
|
Mark McLoughlin |
c034c1 |
- } else {
|
|
Mark McLoughlin |
c034c1 |
- VIR_FREE(vm->def->nets[0]);
|
|
Mark McLoughlin |
c034c1 |
- vm->def->nnets = 0;
|
|
Mark McLoughlin |
c034c1 |
+ if (i != --vm->def->nnets)
|
|
Mark McLoughlin |
c034c1 |
+ memmove(&vm->def->nets[i],
|
|
Mark McLoughlin |
c034c1 |
+ &vm->def->nets[i+1],
|
|
Mark McLoughlin |
c034c1 |
+ sizeof(*vm->def->nets) * (vm->def->nnets-i));
|
|
Mark McLoughlin |
c034c1 |
+ if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets) < 0) {
|
|
Mark McLoughlin |
c034c1 |
+ virReportOOMError(conn);
|
|
Mark McLoughlin |
c034c1 |
+ goto cleanup;
|
|
Mark McLoughlin |
c034c1 |
}
|
|
Mark McLoughlin |
c034c1 |
+
|
|
Mark McLoughlin |
c034c1 |
ret = 0;
|
|
Mark McLoughlin |
c034c1 |
|
|
Mark McLoughlin |
c034c1 |
cleanup:
|
|
Mark McLoughlin |
c034c1 |
--
|
|
Mark McLoughlin |
c034c1 |
1.6.2.5
|
|
Mark McLoughlin |
c034c1 |
|