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 <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Michal Privoznik
2026-06-22 15:49:13 +02:00
parent c48cceee57
commit d0b9488bcd
3 changed files with 19 additions and 0 deletions
+13
View File
@@ -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);
}
+5
View File
@@ -199,3 +199,8 @@ char **
virshDomainDirtyRateCalcModeCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char **
virshDomainNetTypeCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
+1
View File
@@ -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",