]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Fix integer/boolean logic in qemuSetUnprivSGIO
authorJohn Ferlan <jferlan@redhat.com>
Mon, 6 Jul 2015 15:00:13 +0000 (11:00 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 9 Jul 2015 10:48:05 +0000 (06:48 -0400)
Setting of 'val' is a boolean expression, so handle it that way and
adjust the check/return logic to be clearer

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_conf.c

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