Signed-off-by: Roland Schulz <schullzr...@gmail.com>
---
 tools/virsh-completer.c | 15 ++++++++++++++-
 tools/virsh-host.c      |  2 +-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index 2816e7b76..21c73f048 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;
 
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 293f06e9e..793a10452 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -473,7 +473,7 @@ static const vshCmdOptDef opts_allocpages[] = {
      .type = VSH_OT_INT,
      .flags = VSH_OFLAG_REQ,
      .completer = virshAllocpagesPagesizeCompleter,
-     .help = N_("page size (in kibibytes)")
+     .help = N_("page size")
     },
     {.name = "pagecount",
      .type = VSH_OT_INT,
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to