[libvirt] [PATCH] conf: Fix crash when src-hosts = NULL in virStorageFileBackendGlusterInit
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 namesnapshot_test/name descriptionSnapshot 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 0x7fc76d678e22 in virStorageFileInitAs (src=0x7fc760007ca0, uid=uid@entry=4294967295, gid=gid@entry=4294967295) at storage/storage_driver.c:2547 2 0x7fc76d678e9c in virStorageFileInit (src=optimized out) at storage/storage_driver.c:2567 3 0x7fc76bc13f9c 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 0x7fc782d4de4d in virDomainSnapshotCreateXML (domain=domain@entry=0x7fc760001f30, xmlDesc=0x7fc760001b80 domainsnapshot\nnamesnapshot_test/name\ndescriptionSnapshot Test/description\ndisks\ndisk name='vda' snapshot='external' type='network'\nsource protocol='gluster' name='gluster-vol1/gluster, flags=16) at libvirt.c:18488 7 0x7fc7837cb44c in remoteDispatchDomainSnapshotCreateXML (server=optimized out, msg=optimized out, ret=0x7fc76a60, args=0x7fc760001f90, rerr=0x7fc77344dc80, client=optimized out) at remote_dispatch.h:8605 Signed-off-by: Luyao Huang lhu...@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)) { -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: Fix crash when src-hosts = NULL in virStorageFileBackendGlusterInit
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 namesnapshot_test/name descriptionSnapshot 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 0x7fc76d678e22 in virStorageFileInitAs (src=0x7fc760007ca0, uid=uid@entry=4294967295, gid=gid@entry=4294967295) at storage/storage_driver.c:2547 2 0x7fc76d678e9c in virStorageFileInit (src=optimized out) at storage/storage_driver.c:2567 3 0x7fc76bc13f9c 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 0x7fc782d4de4d in virDomainSnapshotCreateXML (domain=domain@entry=0x7fc760001f30, xmlDesc=0x7fc760001b80 domainsnapshot\nnamesnapshot_test/name\ndescriptionSnapshot Test/description\ndisks\ndisk name='vda' snapshot='external' type='network'\nsource protocol='gluster' name='gluster-vol1/gluster, flags=16) at libvirt.c:18488 7 0x7fc7837cb44c in remoteDispatchDomainSnapshotCreateXML (server=optimized out, msg=optimized out, ret=0x7fc76a60, args=0x7fc760001f90, rerr=0x7fc77344dc80, client=optimized out) at remote_dispatch.h:8605 Signed-off-by: Luyao Huang lhu...@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 signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: Fix crash when src-hosts = NULL in virStorageFileBackendGlusterInit
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 namesnapshot_test/name descriptionSnapshot 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 0x7fc76d678e22 in virStorageFileInitAs (src=0x7fc760007ca0, uid=uid@entry=4294967295, gid=gid@entry=4294967295) at storage/storage_driver.c:2547 2 0x7fc76d678e9c in virStorageFileInit (src=optimized out) at storage/storage_driver.c:2567 3 0x7fc76bc13f9c 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 0x7fc782d4de4d in virDomainSnapshotCreateXML (domain=domain@entry=0x7fc760001f30, xmlDesc=0x7fc760001b80 domainsnapshot\nnamesnapshot_test/name\ndescriptionSnapshot Test/description\ndisks\ndisk name='vda' snapshot='external' type='network'\nsource protocol='gluster' name='gluster-vol1/gluster, flags=16) at libvirt.c:18488 7 0x7fc7837cb44c in remoteDispatchDomainSnapshotCreateXML (server=optimized out, msg=optimized out, ret=0x7fc76a60, args=0x7fc760001f90, rerr=0x7fc77344dc80, client=optimized out) at remote_dispatch.h:8605 Signed-off-by: Luyao Huang lhu...@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 :) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list