[PATCH 2/3] virsh: Provide completer for CPU architectures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Related: https://gitlab.com/libvirt/libvirt/-/issues/9
Signed-off-by: Amneesh Singh <natto@xxxxxxxxxxxxx>
---
 src/util/virarch.c           |  2 +-
 src/util/virarch.h           |  2 +-
 tools/virsh-completer-host.c | 12 ++++++++++++
 tools/virsh-completer-host.h |  5 +++++
 tools/virsh-host.c           |  4 ++++
 5 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/util/virarch.c b/src/util/virarch.c
index 2134dd6..b1ea85e 100644
--- a/src/util/virarch.c
+++ b/src/util/virarch.c
@@ -123,7 +123,7 @@ virArchEndian virArchGetEndian(virArch arch)
  *
  * Return the string name of the architecture
  */
-const char *virArchToString(virArch arch)
+const char *virArchToString(int arch)
 {
     if (arch >= VIR_ARCH_LAST)
         arch = VIR_ARCH_NONE;
diff --git a/src/util/virarch.h b/src/util/virarch.h
index 81b1b27..7daa0f1 100644
--- a/src/util/virarch.h
+++ b/src/util/virarch.h
@@ -110,7 +110,7 @@ typedef enum {
 
 unsigned int virArchGetWordSize(virArch arch);
 virArchEndian virArchGetEndian(virArch arch);
-const char *virArchToString(virArch arch);
+const char *virArchToString(int arch);
 virArch virArchFromString(const char *name);
 
 virArch virArchFromHost(void);
diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c
index 14c68d3..67a7687 100644
--- a/tools/virsh-completer-host.c
+++ b/tools/virsh-completer-host.c
@@ -27,6 +27,7 @@
 #include "virxml.h"
 #include "virutil.h"
 #include "virsh-host.h"
+#include "virarch.h"
 #include "conf/domain_conf.h"
 
 static char *
@@ -192,3 +193,14 @@ virshVirtTypeCompleter(vshControl *ctl G_GNUC_UNUSED,
     return virshEnumComplete(VIR_DOMAIN_VIRT_LAST,
                              virDomainVirtTypeToString);
 }
+
+char **
+virshArchCompleter(vshControl *ctl G_GNUC_UNUSED,
+                   const vshCmd *cmd G_GNUC_UNUSED,
+                   unsigned int flags)
+{
+    virCheckFlags(0, NULL);
+
+    return virshEnumComplete(VIR_ARCH_LAST,
+                             virArchToString);
+}
diff --git a/tools/virsh-completer-host.h b/tools/virsh-completer-host.h
index 372ac14..b34163c 100644
--- a/tools/virsh-completer-host.h
+++ b/tools/virsh-completer-host.h
@@ -46,3 +46,8 @@ char **
 virshVirtTypeCompleter(vshControl *ctl,
                        const vshCmd *cmd,
                        unsigned int flags);
+
+char **
+virshArchCompleter(vshControl *ctl,
+                   const vshCmd *cmd,
+                   unsigned int flags);
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 664f9fd..8f94d2a 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -86,6 +86,7 @@ static const vshCmdOptDef opts_domcapabilities[] = {
     },
     {.name = "arch",
      .type = VSH_OT_STRING,
+     .completer = virshArchCompleter,
      .help = N_("domain architecture (/domain/os/type/@arch)"),
     },
     {.name = "machine",
@@ -1312,6 +1313,7 @@ static const vshCmdInfo info_cpu_models[] = {
 static const vshCmdOptDef opts_cpu_models[] = {
     {.name = "arch",
      .type = VSH_OT_DATA,
+     .completer = virshArchCompleter,
      .flags = VSH_OFLAG_REQ,
      .help = N_("architecture")
     },
@@ -1588,6 +1590,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_compare[] = {
     },
     {.name = "arch",
      .type = VSH_OT_STRING,
+     .completer = virshArchCompleter,
      .help = N_("CPU architecture (/domain/os/type/@arch)"),
     },
     {.name = "machine",
@@ -1698,6 +1701,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_baseline[] = {
     },
     {.name = "arch",
      .type = VSH_OT_STRING,
+     .completer = virshArchCompleter,
      .help = N_("CPU architecture (/domain/os/type/@arch)"),
     },
     {.name = "machine",
-- 
2.35.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux