[libvirt] [PATCH] Revert "qemu: Fix integer/boolean logic in qemuSetUnprivSGIO"

John Ferlan jferlan at redhat.com
Fri Sep 18 19:56:34 UTC 2015


This reverts commit 69b850fe2a19d0c32ae2f209e8d8463df6ead665.

This change broke the ability to "clear" or reset unfiltered back
to filtered.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---

This is a <facepalm> event - have to wonder what I was thinking
at the time. The patch pushed removes the ability to actually
clear the value in the file. Although it's possible to check what's
in the file first, it's still important to "attempt" the check if
someone set sgio on a disk and unpriv_sgio isn't supported. So, just
reverting this restores the former functionality of setting to
either 0 or 1.

 src/qemu/qemu_conf.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 1ce459f..658a50e 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1433,7 +1433,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
     virDomainHostdevDefPtr hostdev = NULL;
     char *sysfs_path = NULL;
     const char *path = NULL;
-    bool val;
+    int val = -1;
     int ret = -1;
 
     /* "sgio" is only valid for block disk; cdrom
@@ -1475,12 +1475,8 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
      * whitelist is enabled.  But if requesting unfiltered access, always call
      * virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_sgio.
      */
-    if (!val || !virFileExists(sysfs_path)) {
-        ret = 0;
-        goto cleanup;
-    }
-
-    if (virSetDeviceUnprivSGIO(path, NULL, 1) < 0)
+    if ((virFileExists(sysfs_path) || val == 1) &&
+        virSetDeviceUnprivSGIO(path, NULL, val) < 0)
         goto cleanup;
 
     ret = 0;
-- 
2.1.0




More information about the libvir-list mailing list