[libvirt] [PATCH v2] Fix indentation of virshAllocpagesPagesizeCompleter arguments.

Roland Schulz posted 1 patch 5 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180524090434.20338-1-schullzroll@gmail.com
Test syntax-check passed
tools/virsh-completer.c | 4 ++--
tools/virsh-completer.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
[libvirt] [PATCH v2] Fix indentation of virshAllocpagesPagesizeCompleter arguments.
Posted by Roland Schulz 5 years, 10 months ago
Signed-off-by: Roland Schulz <schullzroll@gmail.com>
---
 tools/virsh-completer.c | 4 ++--
 tools/virsh-completer.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index cbd5326d0..1df4d55af 100644
--- a/tools/virsh-completer.c
+++ b/tools/virsh-completer.c
@@ -568,8 +568,8 @@ virshSnapshotNameCompleter(vshControl *ctl,
 
 char **
 virshAllocpagesPagesizeCompleter(vshControl *ctl,
-                        const vshCmd *cmd ATTRIBUTE_UNUSED,
-                        unsigned int flags)
+                                 const vshCmd *cmd ATTRIBUTE_UNUSED,
+                                 unsigned int flags)
 {
     unsigned long long byteval = 0;
     xmlXPathContextPtr ctxt = NULL;
diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h
index c7b181879..8e4d46394 100644
--- a/tools/virsh-completer.h
+++ b/tools/virsh-completer.h
@@ -75,7 +75,7 @@ char ** virshSnapshotNameCompleter(vshControl *ctl,
                                    unsigned int flags);
 
 char ** virshAllocpagesPagesizeCompleter(vshControl *ctl,
-                                    const vshCmd *cmd,
-                                    unsigned int flags);
+                                         const vshCmd *cmd,
+                                         unsigned int flags);
 
 #endif
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] Fix indentation of virshAllocpagesPagesizeCompleter arguments.
Posted by Michal Privoznik 5 years, 10 months ago
On 05/24/2018 11:04 AM, Roland Schulz wrote:
> Signed-off-by: Roland Schulz <schullzroll@gmail.com>
> ---
>  tools/virsh-completer.c | 4 ++--
>  tools/virsh-completer.h | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)

ACKed and pushed.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] tools: virsh: Add virshCellnoCompleter.
Posted by Roland Schulz 5 years, 10 months ago
Signed-off-by: Roland Schulz <schullzroll@gmail.com>
---
 tools/virsh-completer.c | 58 +++++++++++++++++++++++++++++++++++++++++
 tools/virsh-completer.h |  3 +++
 tools/virsh-host.c      |  3 +++
 3 files changed, 64 insertions(+)

diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index 1df4d55af..b9ea42874 100644
--- a/tools/virsh-completer.c
+++ b/tools/virsh-completer.c
@@ -649,3 +649,61 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
     VIR_FREE(ret);
     goto cleanup;
 }
+
+char **
+virshCellnoCompleter(vshControl *ctl,
+                     const vshCmd *cmd ATTRIBUTE_UNUSED,
+                     unsigned int flags)
+{
+    xmlXPathContextPtr ctxt = NULL;
+    virshControlPtr priv = ctl->privData;
+    unsigned int ncells = 0;
+    xmlNodePtr *cells = NULL;
+    xmlDocPtr doc = NULL;
+    size_t i = 0;
+    char *cellid = NULL;
+    char *cap_xml = NULL;
+    char **ret = NULL;
+
+    virCheckFlags(0, NULL);
+
+    if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
+        goto error;
+
+    if (!(cap_xml = virConnectGetCapabilities(priv->conn)))
+        goto error;
+
+    if (!(doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)))
+        goto error;
+
+    ncells = virXPathNodeSet("/capabilities/host/topology/cells/cell", ctxt, &cells);
+    if (ncells <= 0)
+        goto error;
+
+    if (VIR_ALLOC_N(ret, ncells + 1))
+        goto error;
+
+    for (i = 0; i < ncells; i++) {
+        VIR_FREE(cellid);
+        cellid = virXMLPropString(cells[i], "id");
+        if (VIR_STRDUP(ret[i], cellid) < 0)
+            goto error;
+    }
+
+ cleanup:
+    xmlXPathFreeContext(ctxt);
+    VIR_FREE(cells);
+    xmlFreeDoc(doc);
+    VIR_FREE(cap_xml);
+    VIR_FREE(cellid);
+
+    return ret;
+
+ error:
+    if (ret) {
+        for (i = 0; i < ncells; i++)
+            VIR_FREE(ret[i]);
+    }
+    VIR_FREE(ret);
+    goto cleanup;
+}
diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h
index 8e4d46394..ee0234ce0 100644
--- a/tools/virsh-completer.h
+++ b/tools/virsh-completer.h
@@ -78,4 +78,7 @@ char ** virshAllocpagesPagesizeCompleter(vshControl *ctl,
                                          const vshCmd *cmd,
                                          unsigned int flags);
 
+char ** virshCellnoCompleter(vshControl *ctl,
+                             const vshCmd *cmd,
+                             unsigned int flags);
 #endif
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 293f06e9e..dfe58de30 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -149,6 +149,7 @@ static const vshCmdInfo info_freecell[] = {
 static const vshCmdOptDef opts_freecell[] = {
     {.name = "cellno",
      .type = VSH_OT_INT,
+     .completer = virshCellnoCompleter,
      .help = N_("NUMA cell number")
     },
     {.name = "all",
@@ -274,6 +275,7 @@ static const vshCmdInfo info_freepages[] = {
 static const vshCmdOptDef opts_freepages[] = {
     {.name = "cellno",
      .type = VSH_OT_INT,
+     .completer = virshCellnoCompleter,
      .help = N_("NUMA cell number")
     },
     {.name = "pagesize",
@@ -482,6 +484,7 @@ static const vshCmdOptDef opts_allocpages[] = {
     },
     {.name = "cellno",
      .type = VSH_OT_INT,
+     .completer = virshCellnoCompleter,
      .help = N_("NUMA cell number")
     },
     {.name = "add",
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tools: virsh: Add virshCellnoCompleter.
Posted by Michal Privoznik 5 years, 10 months ago
On 05/24/2018 11:04 AM, Roland Schulz wrote:
> Signed-off-by: Roland Schulz <schullzroll@gmail.com>
> ---
>  tools/virsh-completer.c | 58 +++++++++++++++++++++++++++++++++++++++++
>  tools/virsh-completer.h |  3 +++
>  tools/virsh-host.c      |  3 +++
>  3 files changed, 64 insertions(+)

I'm having some troubles applying this patch. Can you please rebase and
resend?

Michal

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