Blob Blame History Raw
From f6a05ac3cb33c473de8ed49b53d22910fc0140df Mon Sep 17 00:00:00 2001
Message-Id: <f6a05ac3cb33c473de8ed49b53d22910fc0140df@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Wed, 16 Jan 2019 15:54:31 -0500
Subject: [PATCH] RHEL: qemu: Fix logic error 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=1666605

RHEL-only

Commit c0f26a13c6 had a logic error with using both DISK and
sgio which resulted in a DISK that didn't have sgio set falling
into the else clause and trying to deref a NULL @hostdev resulting
in a libvirtd crash:

Thread 1 (Thread 0x7ffbc6353700 (LWP 12642)):
 0  0x00007ffb958e7d7a in qemuSetUnprivSGIO
 1  0x00007ffb958d9d92 in qemuDomainAttachDeviceDiskLive
 2  0x00007ffb9594fce8 in qemuDomainAttachDeviceFlags
 3  0x00007ffbde399d71 in virDomainAttachDevice
 4  0x0000563b73ded4b2 in remoteDispatchDomainAttachDeviceHelper

for hotplug of XML:

<disk device="lun" type="block">
  <source dev="/dev/sdb"/>
  <driver name="qemu" type="raw"/>
  <target bus="scsi" dev="sdb"/>
</disk>

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_conf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 590052b035..0674292fab 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1856,9 +1856,9 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
         return -1;
 
     /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0.  */
-    if (dev->type == VIR_DOMAIN_DEVICE_DISK &&
-        disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED) {
-        val = 1;
+    if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
+        if (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED)
+            val = 1;
     } else {
         /* Only settable if <shareable/> was present for hostdev */
         if (qemuIsSharedHostdev(hostdev) &&
-- 
2.25.0