render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
9119d9
From f9669867ec4a8ae7bc3eed9b8b02be4a7adc5e2f Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <f9669867ec4a8ae7bc3eed9b8b02be4a7adc5e2f@dist-git>
9119d9
From: "Pradipta Kr. Banerjee" <pradipta.banerjee@gmail.com>
9119d9
Date: Tue, 16 Sep 2014 11:47:31 -0400
9119d9
Subject: [PATCH] storage_conf: Fix libvirtd crash when defining scsi storage
9119d9
 pool
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1141943
9119d9
9119d9
Since 9f781da69de02745acb719e78982df9aeccfcd7b
9119d9
9119d9
Resolve a libvirtd crash in virStoragePoolSourceFindDuplicate()
9119d9
when there is an existing SCSI pool defined with adapter type as
9119d9
'scsi_host' and defining a new SCSI pool with adapter type as
9119d9
'fc_host' and parent attribute missing or vice versa.
9119d9
9119d9
For example, if there is an existing SCSI pool with adapter type
9119d9
as 'scsi_host' defined using the following XML
9119d9
9119d9
<pool type='scsi'>
9119d9
  <name>TEST_SCSI_POOL</name>
9119d9
    <source>
9119d9
       <adapter type='scsi_host' name='scsi_host1'/>
9119d9
    </source>
9119d9
    <target>
9119d9
        <path>/dev/disk/by-path</path>
9119d9
    </target>
9119d9
</pool>
9119d9
9119d9
When defining another SCSI pool with adapter type as 'fc_host' using the
9119d9
following XML will crash libvirtd
9119d9
9119d9
<pool type='scsi'>
9119d9
  <name>TEST_SCSI_FC_POOL</name>
9119d9
  <source>
9119d9
     <adapter type='fc_host' wwnn='1234567890abcdef' wwpn='abcdef1234567890'/>
9119d9
  </source>
9119d9
  <target>
9119d9
     <path>/dev/disk/by-path</path>
9119d9
  </target>
9119d9
</pool>
9119d9
9119d9
Same is true for the reverse case as well where there exists a SCSI pool
9119d9
with adapter type as 'fc_host' and another SCSI pool is defined with
9119d9
adapter type as 'scsi_host'.
9119d9
9119d9
This happens because for fc_host 'name' is optional attribute whereas for
9119d9
scsi_host its mandatory. However the check in libvirt for finding duplicate
9119d9
storage pools didn't take that into account while comparing
9119d9
9119d9
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
9119d9
(cherry picked from commit 119b6dfc40cff5c90cdc2a77df01191727332b4b)
9119d9
Signed-off-by: John Ferlan <jferlan@redhat.com>
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/conf/storage_conf.c | 4 ++++
9119d9
 1 file changed, 4 insertions(+)
9119d9
9119d9
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
9119d9
index e72a869..d42cde7 100644
9119d9
--- a/src/conf/storage_conf.c
9119d9
+++ b/src/conf/storage_conf.c
9119d9
@@ -2117,6 +2117,8 @@ virStoragePoolSourceFindDuplicate(virStoragePoolObjListPtr pools,
9119d9
             break;
9119d9
         case VIR_STORAGE_POOL_SCSI:
9119d9
             if (pool->def->source.adapter.type ==
9119d9
+                VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST &&
9119d9
+                def->source.adapter.type ==
9119d9
                 VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
9119d9
                 if (STREQ(pool->def->source.adapter.data.fchost.wwnn,
9119d9
                           def->source.adapter.data.fchost.wwnn) &&
9119d9
@@ -2124,6 +2126,8 @@ virStoragePoolSourceFindDuplicate(virStoragePoolObjListPtr pools,
9119d9
                           def->source.adapter.data.fchost.wwpn))
9119d9
                     matchpool = pool;
9119d9
             } else if (pool->def->source.adapter.type ==
9119d9
+                       VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST &&
9119d9
+                       def->source.adapter.type ==
9119d9
                        VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
9119d9
                 if (pool->def->source.adapter.data.scsi_host.name) {
9119d9
                     if (STREQ(pool->def->source.adapter.data.scsi_host.name,
9119d9
-- 
9119d9
2.1.0
9119d9