From: Michal Privoznik Date: Fri, 22 Jan 2021 08:29:54 +0000 (+0100) Subject: virsh: Fix XPATH in virshDomainDeviceAliasCompleter() X-Git-Tag: v7.1.0-rc1~513 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f023a8acd9c08ea3bc72bf8f968ad63426b033bd;p=thirdparty%2Flibvirt.git virsh: Fix XPATH in virshDomainDeviceAliasCompleter() The way this completer works is that it dumps XML of specified domain and then tries to look for @name attribute of element. However, the XPATH it uses is not correct which results in no aliases returned by the completer. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 4a3459f12a..e773af6552 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -316,14 +316,14 @@ virshDomainDeviceAliasCompleter(vshControl *ctl, if (virshDomainGetXML(ctl, cmd, domainXMLFlags, &xmldoc, &ctxt) < 0) return NULL; - naliases = virXPathNodeSet("./devices//alias/@name", ctxt, &aliases); + naliases = virXPathNodeSet("/domain/devices//alias[@name]", ctxt, &aliases); if (naliases < 0) return NULL; tmp = g_new0(char *, naliases + 1); for (i = 0; i < naliases; i++) { - if (!(tmp[i] = virXMLNodeContentString(aliases[i]))) + if (!(tmp[i] = virXMLPropString(aliases[i], "name"))) return NULL; }