Richard W.M. Jones
2016-Aug-27 08:11 UTC
[Libguestfs] [PATCH 0/3] lib: Don't assert fail if port is missing in XML (RHBZ#1370424).
Simple fix for this assert-fail found in: https://bugzilla.redhat.com/show_bug.cgi?id=1370424 Rich.
Richard W.M. Jones
2016-Aug-27 08:12 UTC
[Libguestfs] [PATCH 1/3] lib: Don't assert fail if port is missing in XML (RHBZ#1370424).
--- src/libvirt-domain.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index b096fb3..7d5da2f 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -604,15 +604,20 @@ for_each_disk (guestfs_h *g, for (hi = 0; hi < xphost->nodesetval->nodeNr ; hi++) { xmlChar *name, *port; xmlNodePtr h = xphost->nodesetval->nodeTab[hi]; + int r; assert (h); assert (h->type == XML_ELEMENT_NODE); - name = xmlGetProp(h, BAD_CAST "name"); - assert(name); - port = xmlGetProp(h, BAD_CAST "port"); - assert (port); - debug (g, _("disk[%zu]: host: %s:%s"), i, name, port); - if (asprintf(&server[hi], "%s:%s", name, port) == -1) { + name = xmlGetProp (h, BAD_CAST "name"); + assert (name); // libvirt checks this + port = xmlGetProp (h, BAD_CAST "port"); + debug (g, "disk[%zu]: hostname: %s port: %s", + i, name, port ? (char *) port : "(not set)"); + if (port) + r = asprintf (&server[hi], "%s:%s", name, port); + else + r = asprintf (&server[hi], "%s", name); + if (r == -1) { perrorf (g, "asprintf"); return -1; } -- 2.7.4
Richard W.M. Jones
2016-Aug-27 08:12 UTC
[Libguestfs] [PATCH 2/3] tests: Add a regression test for RHBZ#1370424.
Regression test for previous commit which just tests that guestfs_add_domain doesn't assert-fail on guests with no port attribute. --- tests/regressions/Makefile.am | 2 ++ tests/regressions/rhbz1370424.sh | 42 +++++++++++++++++++++++++++++++++++++++ tests/regressions/rhbz1370424.xml | 28 ++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100755 tests/regressions/rhbz1370424.sh create mode 100644 tests/regressions/rhbz1370424.xml diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am index 77a5ff5..407c5b0 100644 --- a/tests/regressions/Makefile.am +++ b/tests/regressions/Makefile.am @@ -48,6 +48,7 @@ EXTRA_DIST = \ rhbz1232192.sh \ rhbz1232192.xml \ rhbz1285847.sh \ + rhbz1370424.sh \ test-noexec-stack.pl TESTS = \ @@ -77,6 +78,7 @@ TESTS = \ rhbz1175196.sh \ rhbz1232192.sh \ rhbz1285847.sh \ + rhbz1370424.sh \ test-big-heap \ test-noexec-stack.pl \ $(SLOW_TESTS) diff --git a/tests/regressions/rhbz1370424.sh b/tests/regressions/rhbz1370424.sh new file mode 100755 index 0000000..5b21a32 --- /dev/null +++ b/tests/regressions/rhbz1370424.sh @@ -0,0 +1,42 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2016 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Regression test for: +# https://bugzilla.redhat.com/show_bug.cgi?id=1370424 +# Handle a network disk without a port attribute. + +set -e +export LANG=C + +if [ -n "$SKIP_TEST_RHBZ1370424_SH" ]; then + echo "$0: test skipped because environment variable is set" + exit 77 +fi + +if [ "$(guestfish get-backend)" = "uml" ]; then + echo "$0: test skipped because UML backend does not support network" + exit 77 +fi + +guestfish <<EOF +-add-domain rhbz1370424 \ + libvirturi:test://$(pwd)/rhbz1370424.xml \ + readonly:true +# The test is just that the above command does not segfault. +# We don't need to do anything else here. +EOF diff --git a/tests/regressions/rhbz1370424.xml b/tests/regressions/rhbz1370424.xml new file mode 100644 index 0000000..059ea21 --- /dev/null +++ b/tests/regressions/rhbz1370424.xml @@ -0,0 +1,28 @@ +<node> + <domain type='test'> + <name>rhbz1370424</name> + <memory>1048576</memory> + <vcpu>2</vcpu> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <devices> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <source protocol='gluster' name='gluster-vol/test.qcow2'> + <host name='localhost'/> + </source> + <backingStore/> + <target dev='vda' bus='virtio'/> + <alias name='virtio-disk0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> + </disk> + </devices> + </domain> +</node> -- 2.7.4
Richard W.M. Jones
2016-Aug-27 08:12 UTC
[Libguestfs] [PATCH 3/3] lib: Remove some unnecessary translation of debugging messages.
--- src/libvirt-domain.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7d5da2f..d54814f 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -433,7 +433,7 @@ libvirt_selinux_label (guestfs_h *g, xmlDocPtr doc, if (nr_nodes == 0) return 0; if (nr_nodes > 1) { - debug (g, _("ignoring %zu nodes matching '%s'"), nr_nodes, xpath_expr); + debug (g, "ignoring %zu nodes matching '%s'", nr_nodes, xpath_expr); return 0; } @@ -552,7 +552,7 @@ for_each_disk (guestfs_h *g, } else if (STREQ (type, "network")) { /* type = "network", use source/@name */ int hi; - debug (g, _("disk[%zu]: network device"), i); + debug (g, "disk[%zu]: network device", i); xpathCtx->node = nodes->nodeTab[i]; /* Get the protocol (e.g. "rbd"). Required. */ @@ -567,7 +567,7 @@ for_each_disk (guestfs_h *g, XML_ATTRIBUTE_NODE); attr = (xmlAttrPtr) xpprotocol->nodesetval->nodeTab[0]; protocol = (char *) xmlNodeListGetString (doc, attr->children, 1); - debug (g, _("disk[%zu]: protocol: %s"), i, protocol); + debug (g, "disk[%zu]: protocol: %s", i, protocol); /* <source name="..."> is the path/exportname. Optional. */ xpfilename = xmlXPathEvalExpression (BAD_CAST "./source/@name", @@ -586,7 +586,7 @@ for_each_disk (guestfs_h *g, assert (xpusername->nodesetval->nodeTab[0]->type == XML_ATTRIBUTE_NODE); attr = (xmlAttrPtr) xpusername->nodesetval->nodeTab[0]; username = (char *) xmlNodeListGetString (doc, attr->children, 1); - debug (g, _("disk[%zu]: username: %s"), i, username); + debug (g, "disk[%zu]: username: %s", i, username); } xphost = xmlXPathEvalExpression (BAD_CAST "./source/host", @@ -639,7 +639,7 @@ for_each_disk (guestfs_h *g, XML_ATTRIBUTE_NODE); attr = (xmlAttrPtr) xpfilename->nodesetval->nodeTab[0]; filename = (char *) xmlNodeListGetString (doc, attr->children, 1); - debug (g, _("disk[%zu]: filename: %s"), i, filename); + debug (g, "disk[%zu]: filename: %s", i, filename); } else /* For network protocols (eg. nbd), name may be omitted. */ -- 2.7.4
Possibly Parallel Threads
- [PATCH 0/5] rbd improvements
- [PATCH] libvirt: read disk paths from pools (RHBZ#1366049)
- [PATCH v2] libvirt: read disk paths from pools (RHBZ#1366049)
- [PATCH 0/7] Various fixes for Ceph drives and parsing libvirt XML.
- [PATCH v2 0/5] Fix SELinux security contexts so we can access shared disks (RHBZ#912499).