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:
parent
80f70c74a7
commit
119b139c76
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user