[PATCH v2 7/7] qemuDomainChangeDiskLive: Allow startupPolicy change

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

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c |  1 -
 src/qemu/qemu_driver.c | 29 ++++++++++++++++++++---------
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index ed92d8a..fb8ab30 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3157,7 +3157,6 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
     CHECK_EQ(event_idx, "event_idx", true);
     CHECK_EQ(copy_on_read, "copy_on_read", true);
     CHECK_EQ(snapshot, "snapshot", true);
-    CHECK_EQ(startupPolicy, "startupPolicy", true);
     CHECK_EQ(transient, "transient", true);
     CHECK_EQ(info.bootIndex, "boot order", true);
     CHECK_EQ(rawio, "rawio", true);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1a189cc..d74255b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7922,6 +7922,7 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
 {
     virDomainDiskDefPtr disk = dev->data.disk;
     virDomainDiskDefPtr orig_disk = NULL;
+    int startupPolicy;
     int ret = -1;
 
     if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
@@ -7939,23 +7940,29 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
         goto cleanup;
     }
 
+    startupPolicy = orig_disk->startupPolicy;
+
     switch ((virDomainDiskDevice) disk->device) {
     case VIR_DOMAIN_DISK_DEVICE_CDROM:
     case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
         if (!qemuDomainDiskChangeSupported(disk, orig_disk))
             goto cleanup;
 
-        /* Add the new disk src into shared disk hash table */
-        if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
-            goto cleanup;
+        orig_disk->startupPolicy = dev->data.disk->startupPolicy;
 
-        if (qemuDomainChangeEjectableMedia(driver, conn, vm,
-                                           orig_disk, disk->src, force) < 0) {
-            ignore_value(qemuRemoveSharedDisk(driver, disk, vm->def->name));
-            goto cleanup;
+        if (qemuDomainDiskSourceDiffers(conn, disk, orig_disk)) {
+            /* Add the new disk src into shared disk hash table */
+            if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
+                goto cleanup;
+
+            if (qemuDomainChangeEjectableMedia(driver, conn, vm,
+                                               orig_disk, dev->data.disk->src, force) < 0) {
+                ignore_value(qemuRemoveSharedDisk(driver, dev->data.disk, vm->def->name));
+                goto rollback;
+            }
+
+            dev->data.disk->src = NULL;
         }
-
-        disk->src = NULL;
         break;
 
     case VIR_DOMAIN_DISK_DEVICE_DISK:
@@ -7974,6 +7981,10 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
     ret = 0;
  cleanup:
     return ret;
+
+ rollback:
+    orig_disk->startupPolicy = startupPolicy;
+    goto cleanup;
 }
 
 static int
-- 
2.4.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]