[PATCH 1/6] virsh: Add completer for '--file' option of 'dump' subcommand

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

The '--file' option of 'dump' command specifies where to store the
core dump file.

Partially-fixes: https://gitlab.com/libvirt/libvirt/-/work_items/9
Signed-off-by: Radoslaw Smigielski <rsmigiel@redhat.com>
---
 tools/virsh-domain.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index aa4f2a7a481b..f466976931c6 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5911,6 +5911,7 @@ static const vshCmdOptDef opts_dump[] = {
      .type = VSH_OT_STRING,
      .positional = true,
      .required = true,
+     .completer = vshCompletePathLocalExisting,
      .help = N_("where to dump the core")
     },
     VIRSH_COMMON_OPT_LIVE(N_("perform a live core dump if supported")),
-- 
2.54.0
Re: [PATCH 1/6] virsh: Add completer for '--file' option of 'dump' subcommand
Posted by Peter Krempa via Devel 2 months, 1 week ago
On Thu, Jul 09, 2026 at 15:00:57 +0200, Radosław Śmigielski via Devel wrote:
> From: Radoslaw Smigielski <rsmigiel@redhat.com>
> 
> The '--file' option of 'dump' command specifies where to store the
> core dump file.
> 
> Partially-fixes: https://gitlab.com/libvirt/libvirt/-/work_items/9
> Signed-off-by: Radoslaw Smigielski <rsmigiel@redhat.com>
> ---
>  tools/virsh-domain.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index aa4f2a7a481b..f466976931c6 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -5911,6 +5911,7 @@ static const vshCmdOptDef opts_dump[] = {
>       .type = VSH_OT_STRING,
>       .positional = true,
>       .required = true,
> +     .completer = vshCompletePathLocalExisting,

The dump target doesn't exist yet so this completer is not the correct
one:


/**
 * vshCompletePathLocalExisting:
 *
 * Complete a path to a existing file used as input. The file is used as input

                        ^^^^^^^^

 * for virsh so only local files are considered.





>       .help = N_("where to dump the core")
>      },
>      VIRSH_COMMON_OPT_LIVE(N_("perform a live core dump if supported")),
> -- 
> 2.54.0
> 

Re: [PATCH 1/6] virsh: Add completer for '--file' option of 'dump' subcommand
Posted by Peter Krempa via Devel 2 months, 1 week ago
On Fri, Jul 10, 2026 at 10:05:45 +0200, Peter Krempa via Devel wrote:
> On Thu, Jul 09, 2026 at 15:00:57 +0200, Radosław Śmigielski via Devel wrote:
> > From: Radoslaw Smigielski <rsmigiel@redhat.com>
> > 
> > The '--file' option of 'dump' command specifies where to store the
> > core dump file.
> > 
> > Partially-fixes: https://gitlab.com/libvirt/libvirt/-/work_items/9
> > Signed-off-by: Radoslaw Smigielski <rsmigiel@redhat.com>
> > ---
> >  tools/virsh-domain.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> > index aa4f2a7a481b..f466976931c6 100644
> > --- a/tools/virsh-domain.c
> > +++ b/tools/virsh-domain.c
> > @@ -5911,6 +5911,7 @@ static const vshCmdOptDef opts_dump[] = {
> >       .type = VSH_OT_STRING,
> >       .positional = true,
> >       .required = true,
> > +     .completer = vshCompletePathLocalExisting,
> 
> The dump target doesn't exist yet so this completer is not the correct
> one:
> 
> 
> /**
>  * vshCompletePathLocalExisting:
>  *
>  * Complete a path to a existing file used as input. The file is used as input
> 
>                         ^^^^^^^^
> 
>  * for virsh so only local files are considered.
>

To be clear: Any argument that is supposed to point to a file to be
created (doesn't exist) should be completed by a separate function
(which IIRC doesn't exist yet) even when it will do the exact same thing
as vshCompletePathLocalExisting. This is to prevent the need to go
trhough everything if we figure out that we want to do something else
than the readline default.