[libvirt] [PATCH] conf: Fix crash when src->hosts = NULL in virStorageFileBackendGlusterInit

lhuang lhuang at redhat.com
Wed Nov 12 08:56:09 UTC 2014


On 11/12/2014 04:50 PM, Peter Krempa wrote:
> On 11/12/14 09:47, Luyao Huang wrote:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1162974
>>
>> When do external snapshot for a gluster disk with no host name(ip) in
>> snapshot xml, libvirtd will crash. Because when node do not have a children
>> in virDomainStorageHostParse, libvirt will return 0, but donnot get hosts for
>> virStorageFileBackendGlusterInit.
>>
>> snpahost.xml:
>>
>> <domainsnapshot>
>> <name>snapshot_test</name>
>> <description>Snapshot Test</description>
>> <disks>
>> <disk name='vda' snapshot='external' type='network'>
>> <source protocol='gluster' name='gluster-vol1/gluster.img.snap'/>
>> </disk>
>> </disks>
>> </domainsnapshot>
>>
>> Back trace:
>> virsh snapshot-create r6 snapshot.xml --disk-only
>>
>> 0  virStorageFileBackendGlusterInit (src=0x7fc760007ca0) at storage/storage_backend_gluster.c:577
>> 1  0x00007fc76d678e22 in virStorageFileInitAs (src=0x7fc760007ca0, uid=uid at entry=4294967295, gid=gid at entry=4294967295) at storage/storage_driver.c:2547
>> 2  0x00007fc76d678e9c in virStorageFileInit (src=<optimized out>) at storage/storage_driver.c:2567
>> 3  0x00007fc76bc13f9c in qemuDomainSnapshotPrepareDiskExternal (reuse=false, active=true, snapdisk=0x7fc7600019b8, disk=0x7fc7641e4880, conn=0x7fc76426cc10)
>>      at qemu/qemu_driver.c:12995
>> 4  qemuDomainSnapshotPrepare (flags=<synthetic pointer>, def=0x7fc760002570, vm=0x7fc76422b530, conn=0x7fc76426cc10) at qemu/qemu_driver.c:13156
>> 5  qemuDomainSnapshotCreateXML (domain=0x7fc760001f30, xmlDesc=<optimized out>, flags=16) at qemu/qemu_driver.c:13896
>> 6  0x00007fc782d4de4d in virDomainSnapshotCreateXML (domain=domain at entry=0x7fc760001f30,
>>      xmlDesc=0x7fc760001b80 "<domainsnapshot>\n<name>snapshot_test</name>\n<description>Snapshot Test</description>\n<disks>\n<disk name='vda' snapshot='external' type='network'>\n<source protocol='gluster' name='gluster-vol1/gluster."..., flags=16) at libvirt.c:18488
>> 7  0x00007fc7837cb44c in remoteDispatchDomainSnapshotCreateXML (server=<optimized out>, msg=<optimized out>, ret=0x7fc760000a60, args=0x7fc760001f90, rerr=0x7fc77344dc80,
>>
>>      client=<optimized out>) at remote_dispatch.h:8605
>>
>> Signed-off-by: Luyao Huang <lhuang at redhat.com>
>> ---
>>   src/conf/domain_conf.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index 2c65276..34c1c12 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -4150,7 +4150,12 @@ virDomainStorageHostParse(xmlNodePtr node,
>>   
>>       memset(&host, 0, sizeof(host));
>>   
>> -    child = node->children;
>> +    if ((child = node->children) == NULL) {
>> +        virReportError(VIR_ERR_XML_ERROR, "%s",
>> +                               _("Can not find a host in xml"));
>> +        goto cleanup;
>> +    }
>> +
>>       while (child != NULL) {
>>           if (child->type == XML_ELEMENT_NODE &&
>>               xmlStrEqual(child->name, BAD_CAST "host")) {
>>
> NACK,
>
> some protocols may use implicit host names. We want to check it for
> gluster only in this case.
>
> Also Jan already sent a patch for this so there's no need to resend this.
>
> Peter
okay, i didn't see my e-mail box before i send this :)




More information about the libvir-list mailing list