99cbc7
From eec80321b1066ea326746fb70e99575e5d2f2954 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <eec80321b1066ea326746fb70e99575e5d2f2954@dist-git>
99cbc7
From: John Ferlan <jferlan@redhat.com>
99cbc7
Date: Tue, 29 Jan 2019 19:01:50 -0500
99cbc7
Subject: [PATCH] qemu: Fix logic error in qemuSetUnprivSGIO
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1669581 (RHEL7)
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1666605 (RHEL8)
99cbc7
99cbc7
RHEL-only
99cbc7
99cbc7
Commit 8b246c4bb had a logic error with using both DISK and
99cbc7
sgio which resulted in a DISK that didn't have sgio set falling
99cbc7
into the else clause and trying to deref a NULL @hostdev resulting
99cbc7
in a libvirtd crash:
99cbc7
99cbc7
Thread 1 (Thread 0x7ffbc6353700 (LWP 12642)):
99cbc7
 0  0x00007ffb958e7d7a in qemuSetUnprivSGIO
99cbc7
 1  0x00007ffb958d9d92 in qemuDomainAttachDeviceDiskLive
99cbc7
 2  0x00007ffb9594fce8 in qemuDomainAttachDeviceFlags
99cbc7
 3  0x00007ffbde399d71 in virDomainAttachDevice
99cbc7
 4  0x0000563b73ded4b2 in remoteDispatchDomainAttachDeviceHelper
99cbc7
99cbc7
for hotplug of XML:
99cbc7
99cbc7
<disk device="lun" type="block">
99cbc7
  <source dev="/dev/sdb"/>
99cbc7
  <driver name="qemu" type="raw"/>
99cbc7
  <target bus="scsi" dev="sdb"/>
99cbc7
</disk>
99cbc7
99cbc7
Signed-off-by: John Ferlan <jferlan@redhat.com>
99cbc7
Message-Id: <20190130000151.4479-3-jferlan@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_conf.c | 6 +++---
99cbc7
 1 file changed, 3 insertions(+), 3 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
99cbc7
index 5971f3eb64..768e9d8308 100644
99cbc7
--- a/src/qemu/qemu_conf.c
99cbc7
+++ b/src/qemu/qemu_conf.c
99cbc7
@@ -1679,9 +1679,9 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
     /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0.  */
99cbc7
-    if (dev->type == VIR_DOMAIN_DEVICE_DISK &&
99cbc7
-        disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED) {
99cbc7
-        val = 1;
99cbc7
+    if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
99cbc7
+        if (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED)
99cbc7
+            val = 1;
99cbc7
     } else {
99cbc7
         /* Only settable if <shareable/> was present for hostdev */
99cbc7
         if (qemuIsSharedHostdev(hostdev) &&
99cbc7
-- 
99cbc7
2.21.0
99cbc7