diff options
author | Amneesh Singh <natto@weirdnatto.in> | 2022-04-02 16:01:45 +0530 |
---|---|---|
committer | Michal Privoznik <mprivozn@redhat.com> | 2022-04-04 16:30:40 +0200 |
commit | 11ad758910551c2b419a3d65b7f763f1caae08ae (patch) | |
tree | 5324cfa0fde30648a907cde42334048f87cc9b69 /tools | |
parent | 5c033461848e8045198e5eb7620c4bfea6b287c6 (diff) | |
download | libvirt-11ad758910551c2b419a3d65b7f763f1caae08ae.tar.gz |
virsh: Provide completer for virtualization types
Related: https://gitlab.com/libvirt/libvirt/-/issues/9
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/virsh-completer-host.c | 13 | ||||
-rw-r--r-- | tools/virsh-completer-host.h | 5 | ||||
-rw-r--r-- | tools/virsh-host.c | 4 |
3 files changed, 22 insertions, 0 deletions
diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c index cbdc3f0d49..2da51012d9 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 "conf/domain_conf.h" static char * virshPagesizeNodeToString(xmlNodePtr node) @@ -180,3 +181,15 @@ virshNodeSuspendTargetCompleter(vshControl *ctl G_GNUC_UNUSED, return virshEnumComplete(VIR_NODE_SUSPEND_TARGET_LAST, virshNodeSuspendTargetTypeToString); } + + +char ** +virshDomainVirtTypeCompleter(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int flags) +{ + virCheckFlags(0, NULL); + + return virshEnumComplete(VIR_DOMAIN_VIRT_LAST, + virDomainVirtTypeToString); +} diff --git a/tools/virsh-completer-host.h b/tools/virsh-completer-host.h index e71ccff536..11b2d1ae2b 100644 --- a/tools/virsh-completer-host.h +++ b/tools/virsh-completer-host.h @@ -41,3 +41,8 @@ char ** virshNodeSuspendTargetCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** +virshDomainVirtTypeCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 1e83d19fa1..738265a69b 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -77,6 +77,7 @@ static const vshCmdInfo info_domcapabilities[] = { static const vshCmdOptDef opts_domcapabilities[] = { {.name = "virttype", .type = VSH_OT_STRING, + .completer = virshDomainVirtTypeCompleter, .help = N_("virtualization type (/domain/@type)"), }, {.name = "emulatorbin", @@ -559,6 +560,7 @@ static const vshCmdInfo info_maxvcpus[] = { static const vshCmdOptDef opts_maxvcpus[] = { {.name = "type", .type = VSH_OT_STRING, + .completer = virshDomainVirtTypeCompleter, .help = N_("domain type") }, {.name = NULL} @@ -1577,6 +1579,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_compare[] = { VIRSH_COMMON_OPT_FILE(N_("file containing an XML CPU description")), {.name = "virttype", .type = VSH_OT_STRING, + .completer = virshDomainVirtTypeCompleter, .help = N_("virtualization type (/domain/@type)"), }, {.name = "emulator", @@ -1686,6 +1689,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_baseline[] = { VIRSH_COMMON_OPT_FILE(N_("file containing XML CPU descriptions")), {.name = "virttype", .type = VSH_OT_STRING, + .completer = virshDomainVirtTypeCompleter, .help = N_("virtualization type (/domain/@type)"), }, {.name = "emulator", |