]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Provide completer for PCI backend drivers
authorAmneesh Singh <natto@weirdnatto.in>
Sat, 2 Apr 2022 10:31:47 +0000 (16:01 +0530)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 4 Apr 2022 14:30:48 +0000 (16:30 +0200)
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>
tools/virsh-completer-nodedev.c
tools/virsh-completer-nodedev.h
tools/virsh-nodedev.c

index bf6e809b5a28a4feef24ce15ac0728107df41aea..57544da15d42a8b0c63c180f1eb76d850060d6b7 100644 (file)
@@ -23,6 +23,7 @@
 #include "virsh-completer-nodedev.h"
 #include "virsh-util.h"
 #include "conf/node_device_conf.h"
+#include "conf/domain_conf.h"
 #include "viralloc.h"
 #include "virsh-nodedev.h"
 #include "virsh.h"
@@ -102,3 +103,15 @@ virshNodeDeviceCapabilityNameCompleter(vshControl *ctl,
 
     return virshCommaStringListComplete(cap_str, (const char **)tmp);
 }
+
+
+char **
+virshNodeDevicePCIBackendCompleter(vshControl *ctl G_GNUC_UNUSED,
+                                   const vshCmd *cmd G_GNUC_UNUSED,
+                                   unsigned int flags)
+{
+    virCheckFlags(0, NULL);
+
+    return virshEnumComplete(VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST,
+                             virDomainHostdevSubsysPCIBackendTypeToString);
+}
index 743f7b246558950bd920cd9ee28e00b66835feea..231b4c2c24b3374ef9aca962e92f3d728a087c68 100644 (file)
@@ -36,3 +36,7 @@ char **
 virshNodeDeviceCapabilityNameCompleter(vshControl *ctl,
                                        const vshCmd *cmd,
                                        unsigned int flags);
+
+char **virshNodeDevicePCIBackendCompleter(vshControl *ctl,
+                                          const vshCmd *cmd,
+                                          unsigned int flags);
index d01bdf699c679140055063cf64bfa24ab2af74b7..d21b2baab6a60c4a2fdf6cd6fa88e6da52cf8efb 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <config.h>
+#include "virsh-completer-nodedev.h"
 #include "virsh-nodedev.h"
 #include "virsh-util.h"
 
@@ -613,6 +614,7 @@ static const vshCmdOptDef opts_node_device_detach[] = {
     },
     {.name = "driver",
      .type = VSH_OT_STRING,
+     .completer = virshNodeDevicePCIBackendCompleter,
      .help = N_("pci device assignment backend driver (e.g. 'vfio' or 'kvm')")
     },
     {.name = NULL}