On 02/17/2011 06:39 AM, Michal Privoznik wrote: > as written in docs, one must parse capabilities XML to get the right > count of NUMA nodes. > --- > tools/virsh.c | 27 ++++++++++++++++----------- > 1 files changed, 16 insertions(+), 11 deletions(-) > > - if (!info.nodes) { > - vshError(ctl, "%s", _("no NUMA nodes present")); > - goto cleanup; > - } > + ret = xPathULong(node_xml, > + (char*)"string(/capabilities/host/topology/cells/@num)", > + &nodes_cnt); > + > + if (ret) > + nodes_cnt = 1; As Matthias pointed out, we already have a parse function. If you ditch patch 1/2, then squash this into 2/2, does it all work for you (only compile-tested here)? diff --git i/tools/virsh.c w/tools/virsh.c index dd844ea..a2bff60 100644 --- i/tools/virsh.c +++ w/tools/virsh.c @@ -2287,7 +2287,8 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) unsigned long nodes_cnt; int all_given; char *node_xml; - + xmlDocPtr xml = NULL; + xmlXPathContextPtr ctxt = NULL; if (!vshConnectionUsability(ctl, ctl->conn)) return FALSE; @@ -2308,12 +2309,24 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - ret = xPathULong(node_xml, - (char*)"string(/capabilities/host/topology/cells/@num)", - &nodes_cnt); + xml = xmlReadDoc((const xmlChar *) node_xml, "capabilities.xml", NULL, + XML_PARSE_NOENT | XML_PARSE_NONET | + XML_PARSE_NOWARNING); + if (!xml) + goto cleanup; + + ctxt = xmlXPathNewContext(xml); + if (!ctxt) + goto cleanup; - if (ret) + ret = virXPathULong("string(/capabilities/host/topology/cells/@num)", + ctxt, &nodes_cnt); + if (ret == -1) { nodes_cnt = 1; + } else if (ret < 0) { + vshError(ctl, "%s", _("unable to determine number of nodes")); + goto cleanup; + } if (VIR_ALLOC_N(nodes, nodes_cnt) < 0) { vshError(ctl, "%s", _("could not allocate memory")); @@ -2357,6 +2370,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) cleanup: VIR_FREE(nodes); VIR_FREE(node_xml); + xmlXPathFreeContext(ctxt); return func_ret; } -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list