1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

virsh: Provide completers for options taking comma separated list of disk targets

'--storage' of the 'undefine' command and '--migrate-disks' of the
'migrate' command take a list of disk targets as an argument.

We can simply combine 'virshDomainDiskTargetCompleter' with
'virshCommaStringListComplete' to provide the completions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2021-09-16 15:11:03 +02:00
parent 80f70c74a7
commit 119b139c76
3 changed files with 48 additions and 0 deletions

View File

@ -220,6 +220,42 @@ virshDomainDiskTargetCompleter(vshControl *ctl,
}
static char **
virshDomainDiskTargetListCompleter(vshControl *ctl,
const vshCmd *cmd,
const char *argname)
{
const char *curval = NULL;
g_auto(GStrv) targets = virshDomainDiskTargetCompleter(ctl, cmd, 0);
if (vshCommandOptStringQuiet(ctl, cmd, argname, &curval) < 0)
return NULL;
if (!targets)
return NULL;
return virshCommaStringListComplete(curval, (const char **) targets);
}
char **
virshDomainMigrateDisksCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int completeflags G_GNUC_UNUSED)
{
return virshDomainDiskTargetListCompleter(ctl, cmd, "migrate-disks");
}
char **
virshDomainUndefineStorageDisksCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int completeflags G_GNUC_UNUSED)
{
return virshDomainDiskTargetListCompleter(ctl, cmd, "storage");
}
char **
virshDomainEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,

View File

@ -166,3 +166,13 @@ char **
virshDomainStorageFileFormatCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char **
virshDomainMigrateDisksCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int completeflags);
char **
virshDomainUndefineStorageDisksCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int completeflags);

View File

@ -3552,6 +3552,7 @@ static const vshCmdOptDef opts_undefine[] = {
},
{.name = "storage",
.type = VSH_OT_STRING,
.completer = virshDomainUndefineStorageDisksCompleter,
.help = N_("remove associated storage volumes (comma separated list of "
"targets or source paths) (see domblklist)")
},
@ -10372,6 +10373,7 @@ static const vshCmdOptDef opts_migrate[] = {
},
{.name = "migrate-disks",
.type = VSH_OT_STRING,
.completer = virshDomainMigrateDisksCompleter,
.help = N_("comma separated list of disks to be migrated")
},
{.name = "disks-port",