virsh: Add vshCompletePathLocalCreate completer for output paths

Add a completer callback for local file paths used as command output,
where the target file may not exist yet.

Use it for 'dump', 'save', and 'blockcopy' commands, and fix
'screenshot' to use it instead of vshCompletePathLocalExisting.

Partially-fixes: https://gitlab.com/libvirt/libvirt/-/work_items/9
Signed-off-by: Radoslaw Smigielski <rsmigiel@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Radoslaw Smigielski
2026-08-13 16:50:36 +02:00
committed by Peter Krempa
parent ded31a922d
commit 6593d1d588
3 changed files with 26 additions and 1 deletions
+4 -1
View File
@@ -2629,6 +2629,7 @@ static const vshCmdOptDef opts_blockcopy[] = {
{.name = "dest",
.type = VSH_OT_STRING,
.unwanted_positional = true,
.completer = vshCompletePathLocalCreate,
.help = N_("path of the copy to create")
},
{.name = "bandwidth",
@@ -4651,6 +4652,7 @@ static const vshCmdOptDef opts_save[] = {
.type = VSH_OT_STRING,
.positional = true,
.required = true,
.completer = vshCompletePathLocalCreate,
.help = N_("where to save the data")
},
{.name = "bypass-cache",
@@ -5911,6 +5913,7 @@ static const vshCmdOptDef opts_dump[] = {
.type = VSH_OT_STRING,
.positional = true,
.required = true,
.completer = vshCompletePathLocalCreate,
.help = N_("where to dump the core")
},
VIRSH_COMMON_OPT_LIVE(N_("perform a live core dump if supported")),
@@ -6081,7 +6084,7 @@ static const vshCmdOptDef opts_screenshot[] = {
{.name = "file",
.type = VSH_OT_STRING,
.unwanted_positional = true,
.completer = vshCompletePathLocalExisting,
.completer = vshCompletePathLocalCreate,
.help = N_("where to store the screenshot")
},
{.name = "screen",
+17
View File
@@ -172,6 +172,23 @@ vshCompletePathLocalExisting(vshControl *ctl G_GNUC_UNUSED,
}
/**
* vshCompletePathLocalCreate:
*
* Complete a path to local file used as output.
* The outout file may not exist yet.
*
* Note: For now this is a no-op.
*/
char **
vshCompletePathLocalCreate(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
unsigned int completerflags G_GNUC_UNUSED)
{
return NULL;
}
/**
* vshCompleteEmpty:
*
+5
View File
@@ -35,6 +35,11 @@ vshCompletePathLocalExisting(vshControl *ctl,
const vshCmd *cmd,
unsigned int completerflags);
char **
vshCompletePathLocalCreate(vshControl *ctl,
const vshCmd *cmd,
unsigned int completerflags);
char **
vshCompleteEmpty(vshControl *ctl,
const vshCmd *cmd,