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