render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From d0f2fffa7c1a86f56f18143a1a14b9a32f8bcf16 Mon Sep 17 00:00:00 2001
Message-Id: <d0f2fffa7c1a86f56f18143a1a14b9a32f8bcf16@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Wed, 16 Jan 2019 15:54:31 -0500
Subject: [PATCH] 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 5971f3eb64..768e9d8308 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1679,9 +1679,9 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
         goto cleanup;
 
     /* 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.20.1