[PATCH 3/3] virsh: Provide completer for PCI backend drivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Related: https://gitlab.com/libvirt/libvirt/-/issues/9
Signed-off-by: Amneesh Singh <natto@xxxxxxxxxxxxx>
---
 tools/virsh-completer-nodedev.c | 11 +++++++++++
 tools/virsh-completer-nodedev.h |  4 ++++
 tools/virsh-nodedev.c           |  2 ++
 3 files changed, 17 insertions(+)

diff --git a/tools/virsh-completer-nodedev.c b/tools/virsh-completer-nodedev.c
index bf6e809..58f0a9d 100644
--- a/tools/virsh-completer-nodedev.c
+++ b/tools/virsh-completer-nodedev.c
@@ -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,13 @@ 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);
+}
diff --git a/tools/virsh-completer-nodedev.h b/tools/virsh-completer-nodedev.h
index 743f7b2..231b4c2 100644
--- a/tools/virsh-completer-nodedev.h
+++ b/tools/virsh-completer-nodedev.h
@@ -36,3 +36,7 @@ char **
 virshNodeDeviceCapabilityNameCompleter(vshControl *ctl,
                                        const vshCmd *cmd,
                                        unsigned int flags);
+
+char **virshNodeDevicePCIBackendCompleter(vshControl *ctl,
+                                          const vshCmd *cmd,
+                                          unsigned int flags);
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index d01bdf6..d21b2ba 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -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}
-- 
2.35.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux