libvirt/SOURCES/libvirt-qemu-Alter-val-usage-in-qemuSetUnprivSGIO.patch
2021-10-08 13:11:11 +00:00

61 lines
2.1 KiB
Diff

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