From: Michal Privoznik Date: Mon, 22 Jun 2026 10:51:39 +0000 (+0200) Subject: virsh: Add completer for '--type' option of 'attach-interface' command X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0b9488bcddb9911e3493dab3352bcddde9ed293;p=thirdparty%2Flibvirt.git virsh: Add completer for '--type' option of 'attach-interface' command The '--type' option of 'attach-interface' command is translated from string into int using virDomainNetTypeFromString(), IOW the expected value is from virDomainNetType enum. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 912826c434..8bdf68ac09 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -35,6 +35,7 @@ #include "virkeynametable_linux.h" #include "virkeynametable_osx.h" #include "virkeynametable_win32.h" +#include "conf/domain_conf.h" #include "conf/storage_conf.h" #include "conf/numa_conf.h" @@ -1119,3 +1120,15 @@ virshDomainDirtyRateCalcModeCompleter(vshControl *ctl G_GNUC_UNUSED, return vshEnumComplete(VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST, virshDomainDirtyRateCalcModeTypeToString); } + + +char ** +virshDomainNetTypeCompleter(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int flags) +{ + virCheckFlags(0, NULL); + + return vshEnumComplete(VIR_DOMAIN_NET_TYPE_LAST, + virDomainNetTypeToString); +} diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index f5cda4dd15..dfbc10acaa 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -199,3 +199,8 @@ char ** virshDomainDirtyRateCalcModeCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** +virshDomainNetTypeCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 8a6f868e34..aa4f2a7a48 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -837,6 +837,7 @@ static const vshCmdOptDef opts_attach_interface[] = { .type = VSH_OT_STRING, .positional = true, .required = true, + .completer = virshDomainNetTypeCompleter, .help = N_("network interface type") }, {.name = "source",