render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
edecca
From c0f26a13c6ddd9aca729012d3a31347f77d52c68 Mon Sep 17 00:00:00 2001
edecca
Message-Id: <c0f26a13c6ddd9aca729012d3a31347f77d52c68@dist-git>
edecca
From: John Ferlan <jferlan@redhat.com>
edecca
Date: Mon, 17 Dec 2018 20:42:32 -0500
edecca
Subject: [PATCH] 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
edecca
index 7d15af9c0b..de0cbca083 100644
edecca
--- a/src/qemu/qemu_conf.c
edecca
+++ b/src/qemu/qemu_conf.c
edecca
@@ -1650,7 +1650,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
edecca
     char *sysfs_path = NULL;
edecca
     char *hostdev_path = NULL;
edecca
     const char *path = NULL;
edecca
-    int val = -1;
edecca
+    int val = 0;
edecca
     int ret = -1;
edecca
 
edecca
     /* "sgio" is only valid for block disk; cdrom
edecca
@@ -1682,11 +1682,14 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
edecca
         goto cleanup;
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
-- 
edecca
2.20.1
edecca