[PATCH 08/12] qemu: Set unpriv_sgio when attaching disk

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

 



Just like for domain starting, the original unpriv_sgio state
is recorded in disk def and shareDisks entry for restoring when
detaching or shutdown.
---
 src/qemu/qemu_driver.c |   36 ++++++++++++++++++++++++++++++++----
 1 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fdde74d..a16e336 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6040,11 +6040,39 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
                      NULLSTR(disk->src));
     }
 
-    if (ret == 0 && disk->shared) {
-        if (qemuAddSharedDisk(driver->sharedDisks, disk->src, 0) < 0)
-            VIR_WARN("Failed to add disk '%s' to shared disk table",
-                     disk->src);
+    if (ret == 0) {
+        if (disk->cdbfilter) {
+            int val;
+
+            /* Store the original unpriv_sgio state */
+            if (virGetDeviceUnprivSGIO(disk->src, &val) < 0) {
+                VIR_WARN("Failed to get unpriv_sgio of disk '%s'", disk->src);
+                goto end;
+            }
+
+            if (val == 0)
+                disk->orig_cdbfilter = VIR_DOMAIN_DISK_CDB_FILTER_YES;
+            else
+                disk->orig_cdbfilter = VIR_DOMAIN_DISK_CDB_FILTER_NO;
+
+            /* Set unpriv_sgio */
+            if (virSetDeviceUnprivSGIO(disk->src,
+                                       (disk->cdbfilter ==
+                                       VIR_DOMAIN_DISK_CDB_FILTER_NO)
+                                       ? 1 : 0) < 0) {
+                VIR_WARN("Failed to set unpriv_sgio of disk '%s'", disk->src);
+                goto end;
+            }
+        }
+
+        if (disk->shared) {
+            if (qemuAddSharedDisk(driver->sharedDisks, disk->src,
+                                  disk->orig_cdbfilter) < 0)
+                VIR_WARN("Failed to add disk '%s' to shared disk table",
+                         disk->src);
+        }
     }
+
 end:
     if (cgroup)
         virCgroupFree(&cgroup);
-- 
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]