From 74e7c790666ef13bfaf7b8691583f93cb02b1aad Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Tue, 22 May 2018 11:54:44 +0200 Subject: [PATCH] Add NUMA support to virshAllocpagesPagesizeCompleter. Signed-off-by: Roland Schulz Signed-off-by: Michal Privoznik --- tools/virsh-completer.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index 2816e7b76b..1435d1d4c6 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -579,6 +579,9 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, double size = 0; size_t i = 0; const char *suffix = NULL; + const char *cellnum = NULL; + bool cellno = vshCommandOptBool(cmd, "cellno"); + char *path = NULL; char *pagesize = NULL; char *cap_xml = NULL; char **ret = NULL; @@ -595,7 +598,17 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, if (!(virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt))) goto error; - npages = virXPathNodeSet("/capabilities/host/cpu/pages", ctxt, &pages); + if (cellno && vshCommandOptStringQuiet(ctl, cmd, "cellno", &cellnum) > 0) { + if (virAsprintf(&path, + "/capabilities/host/topology/cells/cell[@id=\"%s\"]/pages", + cellnum) < 0) + goto error; + } else { + if (virAsprintf(&path, "/capabilities/host/cpu/pages") < 0) + goto error; + } + + npages = virXPathNodeSet(path, ctxt, &pages); if (npages <= 0) goto error; @@ -622,6 +635,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, VIR_FREE(pages[i]); VIR_FREE(pages); VIR_FREE(cap_xml); + VIR_FREE(path); VIR_FREE(pagesize); VIR_FREE(unit);