render / rpms / libvirt

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