From 5d0eeb8cd7088e575c0a2b1d5759ccfb72c525c9 Mon Sep 17 00:00:00 2001 From: Amneesh Singh Date: Sat, 2 Apr 2022 16:01:47 +0530 Subject: [PATCH] virsh: Provide completer for PCI backend drivers Related: https://gitlab.com/libvirt/libvirt/-/issues/9 Signed-off-by: Amneesh Singh Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- tools/virsh-completer-nodedev.c | 13 +++++++++++++ tools/virsh-completer-nodedev.h | 4 ++++ tools/virsh-nodedev.c | 2 ++ 3 files changed, 19 insertions(+) diff --git a/tools/virsh-completer-nodedev.c b/tools/virsh-completer-nodedev.c index bf6e809b5a..57544da15d 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,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); +} diff --git a/tools/virsh-completer-nodedev.h b/tools/virsh-completer-nodedev.h index 743f7b2465..231b4c2c24 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 d01bdf699c..d21b2baab6 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -19,6 +19,7 @@ */ #include +#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}