1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-02 20:58:33 +03:00

virsh: Add mountpoint completion to domfsfreeze/domfsthaw command

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Lin Ma 2021-04-22 18:38:18 +08:00 committed by Michal Privoznik
parent c226ae47fc
commit 14c36b107d
3 changed files with 48 additions and 0 deletions

View File

@ -872,3 +872,44 @@ virshKeycodeNameCompleter(vshControl *ctl,
return g_steal_pointer(&tmp);
}
char **
virshDomainFSMountpointsCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags)
{
g_auto(GStrv) tmp = NULL;
virDomainPtr dom = NULL;
int rc = -1;
size_t i;
virDomainFSInfoPtr *info = NULL;
size_t ninfos = 0;
char **ret = NULL;
virCheckFlags(0, NULL);
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return NULL;
rc = virDomainGetFSInfo(dom, &info, 0);
if (rc <= 0) {
goto cleanup;
}
ninfos = rc;
tmp = g_new0(char *, ninfos + 1);
for (i = 0; i < ninfos; i++) {
tmp[i] = g_strdup(info[i]->mountpoint);
}
ret = g_steal_pointer(&tmp);
cleanup:
if (info) {
for (i = 0; i < ninfos; i++)
virDomainFSInfoFree(info[i]);
VIR_FREE(info);
}
virshDomainFree(dom);
return ret;
}

View File

@ -118,3 +118,7 @@ char ** virshCodesetNameCompleter(vshControl *ctl,
char ** virshKeycodeNameCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char ** virshDomainFSMountpointsCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);

View File

@ -13872,6 +13872,7 @@ static const vshCmdOptDef opts_domfstrim[] = {
},
{.name = "mountpoint",
.type = VSH_OT_STRING,
.completer = virshDomainFSMountpointsCompleter,
.help = N_("which mount point to trim")
},
{.name = NULL}
@ -13920,6 +13921,7 @@ static const vshCmdOptDef opts_domfsfreeze[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "mountpoint",
.type = VSH_OT_ARGV,
.completer = virshDomainFSMountpointsCompleter,
.help = N_("mountpoint path to be frozen")
},
{.name = NULL}
@ -13969,6 +13971,7 @@ static const vshCmdOptDef opts_domfsthaw[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "mountpoint",
.type = VSH_OT_ARGV,
.completer = virshDomainFSMountpointsCompleter,
.help = N_("mountpoint path to be thawed")
},
{.name = NULL}