[libvirt] [PATCH] conf: fix crash when match a network iscsi hostdev with a host iscsi hostdev

Luyao Huang lhuang at redhat.com
Mon Dec 15 03:09:39 UTC 2014


https://bugzilla.redhat.com/show_bug.cgi?id=1174053

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
, 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.

backtrace like this:

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 at redhat.com>
---
 src/conf/domain_conf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5cf0b1a..eb63c93 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11184,7 +11184,9 @@ static int
 virDomainHostdevMatchSubsys(virDomainHostdevDefPtr a,
                             virDomainHostdevDefPtr b)
 {
-    if (a->source.subsys.type != b->source.subsys.type)
+    if (a->source.subsys.type != b->source.subsys.type ||
+        (a->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
+         a->source.subsys.u.scsi.protocol != b->source.subsys.u.scsi.protocol))
         return 0;
 
     switch (a->source.subsys.type) {
-- 
1.8.3.1




More information about the libvir-list mailing list