]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Fix libvirtd crash matching hostdev XML
authorLuyao Huang <lhuang@redhat.com>
Mon, 15 Dec 2014 03:09:39 +0000 (11:09 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 15 Dec 2014 12:09:07 +0000 (07:09 -0500)
https://bugzilla.redhat.com/show_bug.cgi?id=1174053

Introduced by commit id '17bddc46f' - fix a libvirtd crash when
matching a network iscsi hostdev with a host iscsi hostdev.

When we use attach-device to coldplug a network iscsi hostdev,
libvirt will check if there is already a device in XML. But if
the 'b' is a host iscsi hostdev and 'a' is a network iscsi hostdev,
then libvirtd will crash in virDomainHostdevMatchSubsysSCSIiSCSI
because 'b' doesn't have a hostname.

Add a check in virDomainHostdevMatchSubsys, if the a's protocol
and b's protocol is not the same.

Following is the backtrace:

0  0x00007f850d6bc307 in virDomainHostdevMatchSubsysSCSIiSCSI at conf/domain_conf.c:10889
1  virDomainHostdevMatchSubsys at conf/domain_conf.c:10911
2  virDomainHostdevMatch at conf/domain_conf.c:10973
3  virDomainHostdevFind at conf/domain_conf.c:10998
4  0x00007f84f6a10560 in qemuDomainAttachDeviceConfig at qemu/qemu_driver.c:7223
5  qemuDomainAttachDeviceFlags at qemu/qemu_driver.c:7554

Signed-off-by: Luyao Huang <lhuang@redhat.com>
src/conf/domain_conf.c

index 28518c27627cd612ee34210ba274ff786880619e..82ab2aaaac65a76172c6a9a64c390dc3765c16b8 100644 (file)
@@ -11196,6 +11196,9 @@ virDomainHostdevMatchSubsys(virDomainHostdevDefPtr a,
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
         return virDomainHostdevMatchSubsysUSB(a, b);
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
+        if (a->source.subsys.u.scsi.protocol !=
+            b->source.subsys.u.scsi.protocol)
+            return 0;
         if (a->source.subsys.u.scsi.protocol ==
             VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
             return virDomainHostdevMatchSubsysSCSIiSCSI(a, b);