mirror of https://gitee.com/openkylin/libvirt.git
tools: virsh: Add virshCellnoCompleter.
Signed-off-by: Roland Schulz <schullzroll@gmail.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
11a2550c27
commit
c7151b0e4d
|
@ -756,3 +756,58 @@ virshNodedevEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
|
||||||
virStringListFree(ret);
|
virStringListFree(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char **
|
||||||
|
virshCellnoCompleter(vshControl *ctl,
|
||||||
|
const vshCmd *cmd ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
|
virshControlPtr priv = ctl->privData;
|
||||||
|
unsigned int ncells = 0;
|
||||||
|
xmlNodePtr *cells = NULL;
|
||||||
|
xmlDocPtr doc = NULL;
|
||||||
|
size_t i = 0;
|
||||||
|
char *cap_xml = NULL;
|
||||||
|
char **ret = NULL;
|
||||||
|
|
||||||
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
|
if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (!(cap_xml = virConnectGetCapabilities(priv->conn)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (!(doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
ncells = virXPathNodeSet("/capabilities/host/topology/cells/cell", ctxt, &cells);
|
||||||
|
if (ncells <= 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (VIR_ALLOC_N(ret, ncells + 1))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
for (i = 0; i < ncells; i++) {
|
||||||
|
if (!(ret[i] = virXMLPropString(cells[i], "id")))
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
xmlXPathFreeContext(ctxt);
|
||||||
|
VIR_FREE(cells);
|
||||||
|
xmlFreeDoc(doc);
|
||||||
|
VIR_FREE(cap_xml);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (ret) {
|
||||||
|
for (i = 0; i < ncells; i++)
|
||||||
|
VIR_FREE(ret[i]);
|
||||||
|
}
|
||||||
|
VIR_FREE(ret);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
|
@ -94,4 +94,7 @@ char ** virshNodedevEventNameCompleter(vshControl *ctl,
|
||||||
const vshCmd *cmd,
|
const vshCmd *cmd,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
|
char ** virshCellnoCompleter(vshControl *ctl,
|
||||||
|
const vshCmd *cmd,
|
||||||
|
unsigned int flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -149,6 +149,7 @@ static const vshCmdInfo info_freecell[] = {
|
||||||
static const vshCmdOptDef opts_freecell[] = {
|
static const vshCmdOptDef opts_freecell[] = {
|
||||||
{.name = "cellno",
|
{.name = "cellno",
|
||||||
.type = VSH_OT_INT,
|
.type = VSH_OT_INT,
|
||||||
|
.completer = virshCellnoCompleter,
|
||||||
.help = N_("NUMA cell number")
|
.help = N_("NUMA cell number")
|
||||||
},
|
},
|
||||||
{.name = "all",
|
{.name = "all",
|
||||||
|
@ -274,6 +275,7 @@ static const vshCmdInfo info_freepages[] = {
|
||||||
static const vshCmdOptDef opts_freepages[] = {
|
static const vshCmdOptDef opts_freepages[] = {
|
||||||
{.name = "cellno",
|
{.name = "cellno",
|
||||||
.type = VSH_OT_INT,
|
.type = VSH_OT_INT,
|
||||||
|
.completer = virshCellnoCompleter,
|
||||||
.help = N_("NUMA cell number")
|
.help = N_("NUMA cell number")
|
||||||
},
|
},
|
||||||
{.name = "pagesize",
|
{.name = "pagesize",
|
||||||
|
@ -483,6 +485,7 @@ static const vshCmdOptDef opts_allocpages[] = {
|
||||||
},
|
},
|
||||||
{.name = "cellno",
|
{.name = "cellno",
|
||||||
.type = VSH_OT_INT,
|
.type = VSH_OT_INT,
|
||||||
|
.completer = virshCellnoCompleter,
|
||||||
.help = N_("NUMA cell number")
|
.help = N_("NUMA cell number")
|
||||||
},
|
},
|
||||||
{.name = "add",
|
{.name = "add",
|
||||||
|
|
Loading…
Reference in New Issue