render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
0a7476
From 6764c4c345ba0ce1f60adab7958441279c3f4913 Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <6764c4c345ba0ce1f60adab7958441279c3f4913@dist-git>
0a7476
From: John Ferlan <jferlan@redhat.com>
0a7476
Date: Wed, 5 Dec 2018 08:49:30 -0500
0a7476
Subject: [PATCH] RHEL: qemu: Alter @val usage in qemuSetUnprivSGIO
0a7476
MIME-Version: 1.0
0a7476
Content-Type: text/plain; charset=UTF-8
0a7476
Content-Transfer-Encoding: 8bit
0a7476
0a7476
https://bugzilla.redhat.com/show_bug.cgi?id=1656360
0a7476
0a7476
RHEL-only
0a7476
0a7476
Rather than initializing to -1 and then setting to the result
0a7476
of a boolean check (either 0 or 1), let's just initialize @val
0a7476
to 0 and then only change to 1 if conditions are "right".
0a7476
0a7476
Signed-off-by: John Ferlan <jferlan@redhat.com>
0a7476
Reviewed-by: Ján Tomko <jtomko@redhat.com>
0a7476
---
0a7476
 src/qemu/qemu_conf.c | 15 +++++++++------
0a7476
 1 file changed, 9 insertions(+), 6 deletions(-)
0a7476
0a7476
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
0a7476
index 7d15af9c0b..de0cbca083 100644
0a7476
--- a/src/qemu/qemu_conf.c
0a7476
+++ b/src/qemu/qemu_conf.c
0a7476
@@ -1650,7 +1650,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
0a7476
     char *sysfs_path = NULL;
0a7476
     char *hostdev_path = NULL;
0a7476
     const char *path = NULL;
0a7476
-    int val = -1;
0a7476
+    int val = 0;
0a7476
     int ret = -1;
0a7476
 
0a7476
     /* "sgio" is only valid for block disk; cdrom
0a7476
@@ -1682,11 +1682,14 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
0a7476
         goto cleanup;
0a7476
 
0a7476
     /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0.  */
0a7476
-    if (dev->type == VIR_DOMAIN_DEVICE_DISK)
0a7476
-        val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
0a7476
-    else
0a7476
-        val = (hostdev->source.subsys.u.scsi.sgio ==
0a7476
-               VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
0a7476
+    if (dev->type == VIR_DOMAIN_DEVICE_DISK &&
0a7476
+        disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED) {
0a7476
+        val = 1;
0a7476
+    } else {
0a7476
+        if (hostdev->source.subsys.u.scsi.sgio ==
0a7476
+            VIR_DOMAIN_DEVICE_SGIO_UNFILTERED)
0a7476
+            val = 1;
0a7476
+    }
0a7476
 
0a7476
     /* Do not do anything if unpriv_sgio is not supported by the kernel and the
0a7476
      * whitelist is enabled.  But if requesting unfiltered access, always call
0a7476
-- 
0a7476
2.21.0
0a7476