[PATCH 11/12] qemu: Do not restore unpriv_sgio when detaching disk if it's still shared

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

 



Just like for domain shutdown, this prevents restoring the disk's
unpriv_sgio if it's being shared by other domain(s).
---
 src/qemu/qemu_driver.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c5e45c5..48201c1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6195,15 +6195,23 @@ qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr driver,
         /* Restore the disk's unpriv_sgio */
         if (disk->cdbfilter) {
             int val;
+            qemuSharedDiskEntryPtr entry = NULL;
 
-            if (disk->orig_cdbfilter == VIR_DOMAIN_DISK_CDB_FILTER_YES)
-                val = 0;
-            else
-                val = 1;
+            if (!disk->shared ||
+                qemuSharedDiskIsLast(driver->sharedDisks, disk->src)) {
+                if (!disk->shared) {
+                    val = disk->orig_cdbfilter;
+                } else {
+                    entry = virHashLookup(driver->sharedDisks, disk->src);
+                    val = entry->orig_cdbfilter;
+                }
 
-            if (virSetDeviceUnprivSGIO(disk->src, val) < 0)
-                VIR_DEBUG("Failed to restore unpriv_sgio for disk '%s'",
-                          disk->src);
+                if (virSetDeviceUnprivSGIO(disk->src,
+                                           (val == VIR_DOMAIN_DISK_CDB_FILTER_YES) ?
+                                           0 : 1) < 0)
+                    VIR_DEBUG("Failed to restore unpriv_sgio for disk '%s'",
+                              disk->src);
+            }
         }
 
         if (disk->shared) {
-- 
1.7.7.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]