[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 3/3] qemu: driver: Allow disk update of startupPolicy/snapshot for all disks



The libvirt internal bits can be changed for disks that don't otherwise
support changing media. Remove the switch statement and allow changes of
non-source data for all disks.
---
 src/qemu/qemu_driver.c | 55 +++++++++++++++++++++-----------------------------
 1 file changed, 23 insertions(+), 32 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6f5712d..592be84 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7671,45 +7671,36 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
         return -1;
     }

-    switch ((virDomainDiskDevice) disk->device) {
-    case VIR_DOMAIN_DISK_DEVICE_CDROM:
-    case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
-        if (!qemuDomainDiskChangeSupported(disk, orig_disk))
-            return -1;
-
-        if (qemuDomainDiskSourceDiffers(disk, orig_disk)) {
-            /* Add the new disk src into shared disk hash table */
-            if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
-                return -1;
-
-            if (qemuDomainChangeEjectableMedia(driver, vm, orig_disk,
-                                               dev->data.disk->src,
-                                               force) < 0) {
-                ignore_value(qemuRemoveSharedDisk(driver, dev->data.disk,
-                                                  vm->def->name));
-                return -1;
-            }
+    if (!qemuDomainDiskChangeSupported(disk, orig_disk))
+        return -1;

-            dev->data.disk->src = NULL;
+    if (qemuDomainDiskSourceDiffers(disk, orig_disk)) {
+        /* Disk source can be changed only for removable devices */
+        if (disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM &&
+            disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("disk source can be changed only in removable "
+                             "drives"));
+            return -1;
         }

-        orig_disk->startupPolicy = dev->data.disk->startupPolicy;
-        orig_disk->snapshot = dev->data.disk->snapshot;
-        break;
+        /* Add the new disk src into shared disk hash table */
+        if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
+            return -1;

-    case VIR_DOMAIN_DISK_DEVICE_DISK:
-    case VIR_DOMAIN_DISK_DEVICE_LUN:
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("disk bus '%s' cannot be updated."),
-                       virDomainDiskBusTypeToString(disk->bus));
-        return -1;
-        break;
+        if (qemuDomainChangeEjectableMedia(driver, vm, orig_disk,
+                                           dev->data.disk->src, force) < 0) {
+            ignore_value(qemuRemoveSharedDisk(driver, dev->data.disk,
+                                              vm->def->name));
+            return -1;
+        }

-    case VIR_DOMAIN_DISK_DEVICE_LAST:
-        /* nada */
-        break;
+        dev->data.disk->src = NULL;
     }

+    orig_disk->startupPolicy = dev->data.disk->startupPolicy;
+    orig_disk->snapshot = dev->data.disk->snapshot;
+
     return 0;
 }

-- 
2.8.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]