a41c76
From fa46b5b4d5bb732462d0d5484cc010aa652d821b Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <fa46b5b4d5bb732462d0d5484cc010aa652d821b@dist-git>
edecca
From: John Ferlan <jferlan@redhat.com>
edecca
Date: Mon, 17 Dec 2018 20:42:32 -0500
a41c76
Subject: [PATCH] RHEL: qemu: Alter @val usage in qemuSetUnprivSGIO
edecca
MIME-Version: 1.0
edecca
Content-Type: text/plain; charset=UTF-8
edecca
Content-Transfer-Encoding: 8bit
edecca
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1656362 (RHEL8)
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1656360 (RHEL7)
edecca
edecca
RHEL-only
edecca
edecca
Rather than initializing to -1 and then setting to the result
edecca
of a boolean check (either 0 or 1), let's just initialize @val
edecca
to 0 and then only change to 1 if conditions are "right".
edecca
edecca
Signed-off-by: John Ferlan <jferlan@redhat.com>
edecca
Reviewed-by: Ján Tomko <jtomko@redhat.com>
edecca
---
edecca
 src/qemu/qemu_conf.c | 15 +++++++++------
edecca
 1 file changed, 9 insertions(+), 6 deletions(-)
edecca
edecca
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
a41c76
index 2a84972fd9..faabc4d49f 100644
edecca
--- a/src/qemu/qemu_conf.c
edecca
+++ b/src/qemu/qemu_conf.c
a41c76
@@ -1828,7 +1828,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
a41c76
     g_autofree char *sysfs_path = NULL;
a41c76
     g_autofree char *hostdev_path = NULL;
edecca
     const char *path = NULL;
edecca
-    int val = -1;
edecca
+    int val = 0;
edecca
 
edecca
     /* "sgio" is only valid for block disk; cdrom
a41c76
      * and floopy disk can have empty source.
a41c76
@@ -1859,11 +1859,14 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
a41c76
         return -1;
edecca
 
edecca
     /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0.  */
edecca
-    if (dev->type == VIR_DOMAIN_DEVICE_DISK)
edecca
-        val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
edecca
-    else
edecca
-        val = (hostdev->source.subsys.u.scsi.sgio ==
edecca
-               VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
edecca
+    if (dev->type == VIR_DOMAIN_DEVICE_DISK &&
edecca
+        disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED) {
edecca
+        val = 1;
edecca
+    } else {
edecca
+        if (hostdev->source.subsys.u.scsi.sgio ==
edecca
+            VIR_DOMAIN_DEVICE_SGIO_UNFILTERED)
edecca
+            val = 1;
edecca
+    }
edecca
 
edecca
     /* Do not do anything if unpriv_sgio is not supported by the kernel and the
edecca
      * whitelist is enabled.  But if requesting unfiltered access, always call
edecca
-- 
a41c76
2.25.0
edecca