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