]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Add completer for '--type' option of 'attach-interface' command
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 22 Jun 2026 10:51:39 +0000 (12:51 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 22 Jun 2026 13:49:13 +0000 (15:49 +0200)
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>
tools/virsh-completer-domain.c
tools/virsh-completer-domain.h
tools/virsh-domain.c

index 912826c434a12f99070c711a28f62afc31ba5d9c..8bdf68ac091d71de1087de1ec5ebffb4129c303e 100644 (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);
+}
index f5cda4dd15b24b2cc8de0183fc0bdaca4b27d603..dfbc10acaaa8825b11b4c29f7b0c55a69448855d 100644 (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);
index 8a6f868e346af966994e79b686db944b0c453d2e..aa4f2a7a481bd182759a4f067fe2df63cf446bdf 100644 (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",