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

[libvirt] [PATCH 12/15] qemu: Restore unpriv_sgio when detaching disk



Later patch will prohibit restoring it the disk is shared and
being used by other domain(s).
---
 src/qemu/qemu_driver.c |   28 ++++++++++++++++++++++------
 1 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b75b6fe..cedf636 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6195,12 +6195,28 @@ qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr driver,
         break;
     }
 
-    if (ret == 0 && disk->shared) {
-        if (qemuSharedDiskListDel(driver->sharedDisks,
-                                  disk->src,
-                                  vm->def->name) < 0) {
-            VIR_DEBUG("Failed to remove the entry of disk '%s', domain "
-                      "%s from sharedDisks", disk->src, vm->def->name);
+    if (ret == 0) {
+        /* Restore the disk's unpriv_sgio */
+        if (disk->cdbfilter) {
+            int val;
+
+            if (disk->old_cdbfilter == VIR_DOMAIN_DISK_CDB_FILTER_YES)
+                val = 0;
+            else
+                val = 1;
+
+            if (virSetDeviceUnprivSGIO(disk->src, val) < 0)
+                VIR_DEBUG("Failed to restore unpriv_sgio for disk '%s'",
+                          disk->src);
+        }
+
+        if (disk->shared) {
+            if (qemuSharedDiskListDel(driver->sharedDisks,
+                                      disk->src,
+                                      vm->def->name) < 0) {
+                VIR_DEBUG("Failed to remove the entry of disk '%s', domain "
+                          "%s from sharedDisks", disk->src, vm->def->name);
+            }
         }
     }
 
-- 
1.7.7.6


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