Related: https://gitlab.com/libvirt/libvirt/-/issues/9 Signed-off-by: natto1784 <natto@xxxxxxxxxxxxx> --- .gitignore | 4 ++++ tools/virsh-completer-host.c | 12 ++++++++++++ tools/virsh-completer-host.h | 5 +++++ tools/virsh-host.c | 3 +++ 4 files changed, 24 insertions(+) diff --git a/.gitignore b/.gitignore index 4695391..62012f4 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,8 @@ tags # clangd related ignores .clangd +.cache/clangd compile_commands.json + +# ccls cache +.ccls-cache diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c index 40cb687..e481a73 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,14 @@ virshNodeSuspendTargetCompleter(vshControl *ctl G_GNUC_UNUSED, return virshEnumComplete(VIR_NODE_SUSPEND_TARGET_LAST, virshNodeSuspendTargetTypeToString); } + +char ** +virshVirtTypeCompleter(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 e71ccff..372ac14 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 ** +virshVirtTypeCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 2e3cbc3..b28f29f 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 = virshVirtTypeCompleter, .help = N_("virtualization type (/domain/@type)"), }, {.name = "emulatorbin", @@ -1577,6 +1578,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 = virshVirtTypeCompleter, .help = N_("virtualization type (/domain/@type)"), }, {.name = "emulator", @@ -1686,6 +1688,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 = virshVirtTypeCompleter, .help = N_("virtualization type (/domain/@type)"), }, {.name = "emulator", -- 2.35.1