From: Luyao Huang Date: Mon, 15 Dec 2014 03:09:39 +0000 (+0800) Subject: conf: Fix libvirtd crash matching hostdev XML X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5fc1c51743643a02c0306d6c17fe86e9013ce342;p=libvirt.git conf: Fix libvirtd crash matching hostdev XML 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 --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 28518c2762..82ab2aaaac 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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);