]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add NUMA support to virshAllocpagesPagesizeCompleter.
authorRoland Schulz <schullzroll@gmail.com>
Tue, 22 May 2018 09:54:44 +0000 (11:54 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 22 May 2018 13:32:10 +0000 (15:32 +0200)
Signed-off-by: Roland Schulz <schullzroll@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-completer.c

index 2816e7b76b23a90598c1a8ae540187b8cb17170f..1435d1d4c64d021600fd2f5b5fa2047ff8cfaf7a 100644 (file)
@@ -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);