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