[PATCH 4/6] virsh: Add completer for '--type' option of 'domdisplay' command

Radosław Śmigielski via Devel posted 6 patches 2 months, 1 week ago
There is a newer version of this series
[PATCH 4/6] virsh: Add completer for '--type' option of 'domdisplay' command
Posted by Radosław Śmigielski via Devel 2 months, 1 week ago
From: Radoslaw Smigielski <rsmigiel@redhat.com>

The '--type' option of 'domdisplay' command selects a particular
graphical display scheme (vnc, spice, rdp, or dbus).

Partially-fixes: https://gitlab.com/libvirt/libvirt/-/work_items/9
Signed-off-by: Radoslaw Smigielski <rsmigiel@redhat.com>
---
 tools/virsh-completer-domain.c | 13 +++++++++++++
 tools/virsh-completer-domain.h |  5 +++++
 tools/virsh-domain.c           |  1 +
 3 files changed, 19 insertions(+)

diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
index 8bdf68ac091d..4c0ddb01d855 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -1132,3 +1132,16 @@ virshDomainNetTypeCompleter(vshControl *ctl G_GNUC_UNUSED,
     return vshEnumComplete(VIR_DOMAIN_NET_TYPE_LAST,
                            virDomainNetTypeToString);
 }
+
+
+char **
+virshDomainDisplayTypeCompleter(vshControl *ctl G_GNUC_UNUSED,
+                                const vshCmd *cmd G_GNUC_UNUSED,
+                                unsigned int flags)
+{
+    static const char *types[] = {"vnc", "spice", "rdp", "dbus", NULL};
+
+    virCheckFlags(0, NULL);
+
+    return vshCommaStringListComplete(NULL, types);
+}
diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h
index dfbc10acaaa8..3aab7bedae20 100644
--- a/tools/virsh-completer-domain.h
+++ b/tools/virsh-completer-domain.h
@@ -204,3 +204,8 @@ char **
 virshDomainNetTypeCompleter(vshControl *ctl,
                             const vshCmd *cmd,
                             unsigned int flags);
+
+char **
+virshDomainDisplayTypeCompleter(vshControl *ctl,
+                                const vshCmd *cmd,
+                                unsigned int flags);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 79823072ad26..a546532b7dd2 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -12181,6 +12181,7 @@ static const vshCmdOptDef opts_domdisplay[] = {
     {.name = "type",
      .type = VSH_OT_STRING,
      .positional = true,
+     .completer = virshDomainDisplayTypeCompleter,
      .help = N_("select particular graphical display "
                 "(e.g. \"vnc\", \"spice\", \"rdp\", \"dbus\")")
     },
-- 
2.54.0
Re: [PATCH 4/6] virsh: Add completer for '--type' option of 'domdisplay' command
Posted by Peter Krempa via Devel 2 months, 1 week ago
On Thu, Jul 09, 2026 at 15:01:00 +0200, Radosław Śmigielski via Devel wrote:
> From: Radoslaw Smigielski <rsmigiel@redhat.com>
> 
> The '--type' option of 'domdisplay' command selects a particular
> graphical display scheme (vnc, spice, rdp, or dbus).
> 
> Partially-fixes: https://gitlab.com/libvirt/libvirt/-/work_items/9
> Signed-off-by: Radoslaw Smigielski <rsmigiel@redhat.com>
> ---
>  tools/virsh-completer-domain.c | 13 +++++++++++++
>  tools/virsh-completer-domain.h |  5 +++++
>  tools/virsh-domain.c           |  1 +
>  3 files changed, 19 insertions(+)
> 
> diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
> index 8bdf68ac091d..4c0ddb01d855 100644
> --- a/tools/virsh-completer-domain.c
> +++ b/tools/virsh-completer-domain.c
> @@ -1132,3 +1132,16 @@ virshDomainNetTypeCompleter(vshControl *ctl G_GNUC_UNUSED,
>      return vshEnumComplete(VIR_DOMAIN_NET_TYPE_LAST,
>                             virDomainNetTypeToString);
>  }
> +
> +
> +char **
> +virshDomainDisplayTypeCompleter(vshControl *ctl G_GNUC_UNUSED,
> +                                const vshCmd *cmd G_GNUC_UNUSED,
> +                                unsigned int flags)
> +{
> +    static const char *types[] = {"vnc", "spice", "rdp", "dbus", NULL};

This duplicates the list of supported types and is missing some that
were added meanwhile. Duplicating it means that it will be forgotten in
the future too when some new type is added.

Use virDomainGraphicsTypeToString adn VIR_DOMAIN_GRAPHICS_TYPE_LAST
via the normal enum completer.