[libvirt] [PATCH] qemuDomainUpdateDeviceConfig: Allow full disk update

Michal Privoznik mprivozn at redhat.com
Fri Sep 2 11:41:44 UTC 2016


https://bugzilla.redhat.com/show_bug.cgi?id=1368417

So far, when it comes to 'virsh update-device --config' of disks
we are limiting ourselves for just the disk source update and
just for CDROMs and floppies. This makes no sense. Especially if
you look around and see that we already allow full update to
graphics and net devices. So let's just take whatever XML user
wants to have there and replace our internal definition with it.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_driver.c | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2efaa2a..b5abb0c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8104,35 +8104,23 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
                              unsigned int parse_flags,
                              virDomainXMLOptionPtr xmlopt)
 {
-    virDomainDiskDefPtr orig, disk;
+    virDomainDiskDefPtr newDisk;
     virDomainGraphicsDefPtr newGraphics;
     virDomainNetDefPtr net;
     int pos;
 
     switch ((virDomainDeviceType) dev->type) {
     case VIR_DOMAIN_DEVICE_DISK:
-        disk = dev->data.disk;
-        if (!(orig = virDomainDiskByName(vmdef, disk->dst, false))) {
+        newDisk = dev->data.disk;
+        if ((pos = virDomainDiskIndexByName(vmdef, newDisk->dst, false)) < 0) {
             virReportError(VIR_ERR_INVALID_ARG,
-                           _("target %s doesn't exist."), disk->dst);
+                           _("target %s doesn't exist."), newDisk->dst);
             return -1;
         }
-        if (!(orig->device == VIR_DOMAIN_DISK_DEVICE_CDROM) &&
-            !(orig->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)) {
-            virReportError(VIR_ERR_INVALID_ARG, "%s",
-                           _("this disk doesn't support update"));
-            return -1;
-        }
-        /*
-         * Update 'orig'
-         * We allow updating src/type//driverType/cachemode/
-         */
-        orig->cachemode = disk->cachemode;
-        orig->startupPolicy = disk->startupPolicy;
 
-        virStorageSourceFree(orig->src);
-        orig->src = disk->src;
-        disk->src = NULL;
+        virDomainDiskDefFree(vmdef->disks[pos]);
+        vmdef->disks[pos] = newDisk;
+        dev->data.disk = NULL;
         break;
 
     case VIR_DOMAIN_DEVICE_GRAPHICS:
-- 
2.8.4




More information about the libvir-list mailing list