mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
tools: virsh: remove redundant labels
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
fba265e2b2
commit
bd1f40fe7d
@ -447,7 +447,6 @@ virshDomainIOThreadIdCompleter(vshControl *ctl,
|
|||||||
g_autofree virDomainIOThreadInfoPtr *info = NULL;
|
g_autofree virDomainIOThreadInfoPtr *info = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
int rc;
|
int rc;
|
||||||
char **ret = NULL;
|
|
||||||
g_auto(GStrv) tmp = NULL;
|
g_auto(GStrv) tmp = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
@ -456,7 +455,7 @@ virshDomainIOThreadIdCompleter(vshControl *ctl,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((rc = virDomainGetIOThreadInfo(dom, &info, flags)) < 0)
|
if ((rc = virDomainGetIOThreadInfo(dom, &info, flags)) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
niothreads = rc;
|
niothreads = rc;
|
||||||
|
|
||||||
@ -465,10 +464,7 @@ virshDomainIOThreadIdCompleter(vshControl *ctl,
|
|||||||
for (i = 0; i < niothreads; i++)
|
for (i = 0; i < niothreads; i++)
|
||||||
tmp[i] = g_strdup_printf("%u", info[i]->iothread_id);
|
tmp[i] = g_strdup_printf("%u", info[i]->iothread_id);
|
||||||
|
|
||||||
ret = g_steal_pointer(&tmp);
|
return g_steal_pointer(&tmp);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -482,7 +478,6 @@ virshDomainVcpuCompleter(vshControl *ctl,
|
|||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
int nvcpus = 0;
|
int nvcpus = 0;
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
char **ret = NULL;
|
|
||||||
g_auto(GStrv) tmp = NULL;
|
g_auto(GStrv) tmp = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
@ -492,21 +487,18 @@ virshDomainVcpuCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE,
|
if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE,
|
||||||
&xml, &ctxt) < 0)
|
&xml, &ctxt) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
/* Query the max rather than the current vcpu count */
|
/* Query the max rather than the current vcpu count */
|
||||||
if (virXPathInt("string(/domain/vcpu)", ctxt, &nvcpus) < 0)
|
if (virXPathInt("string(/domain/vcpu)", ctxt, &nvcpus) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
tmp = g_new0(char *, nvcpus + 1);
|
tmp = g_new0(char *, nvcpus + 1);
|
||||||
|
|
||||||
for (id = 0; id < nvcpus; id++)
|
for (id = 0; id < nvcpus; id++)
|
||||||
tmp[id] = g_strdup_printf("%u", id);
|
tmp[id] = g_strdup_printf("%u", id);
|
||||||
|
|
||||||
ret = g_steal_pointer(&tmp);
|
return g_steal_pointer(&tmp);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -522,7 +514,6 @@ virshDomainVcpulistCompleter(vshControl *ctl,
|
|||||||
unsigned int id;
|
unsigned int id;
|
||||||
g_auto(GStrv) vcpulist = NULL;
|
g_auto(GStrv) vcpulist = NULL;
|
||||||
const char *vcpuid = NULL;
|
const char *vcpuid = NULL;
|
||||||
char **ret = NULL;
|
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
@ -530,25 +521,22 @@ virshDomainVcpulistCompleter(vshControl *ctl,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (vshCommandOptStringQuiet(ctl, cmd, "vcpulist", &vcpuid) < 0)
|
if (vshCommandOptStringQuiet(ctl, cmd, "vcpulist", &vcpuid) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE,
|
if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE,
|
||||||
&xml, &ctxt) < 0)
|
&xml, &ctxt) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
/* Query the max rather than the current vcpu count */
|
/* Query the max rather than the current vcpu count */
|
||||||
if (virXPathInt("string(/domain/vcpu)", ctxt, &nvcpus) < 0)
|
if (virXPathInt("string(/domain/vcpu)", ctxt, &nvcpus) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
vcpulist = g_new0(char *, nvcpus + 1);
|
vcpulist = g_new0(char *, nvcpus + 1);
|
||||||
|
|
||||||
for (id = 0; id < nvcpus; id++)
|
for (id = 0; id < nvcpus; id++)
|
||||||
vcpulist[id] = g_strdup_printf("%u", id);
|
vcpulist[id] = g_strdup_printf("%u", id);
|
||||||
|
|
||||||
ret = virshCommaStringListComplete(vcpuid, (const char **)vcpulist);
|
return virshCommaStringListComplete(vcpuid, (const char **)vcpulist);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title,
|
|||||||
|
|
||||||
/* fall back to xml */
|
/* fall back to xml */
|
||||||
if (virshDomainGetXMLFromDom(ctl, dom, flags, &doc, &ctxt) < 0)
|
if (virshDomainGetXMLFromDom(ctl, dom, flags, &doc, &ctxt) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (title)
|
if (title)
|
||||||
desc = virXPathString("string(./title[1])", ctxt);
|
desc = virXPathString("string(./title[1])", ctxt);
|
||||||
@ -91,8 +91,6 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title,
|
|||||||
if (!desc)
|
if (!desc)
|
||||||
desc = g_strdup("");
|
desc = g_strdup("");
|
||||||
|
|
||||||
cleanup:
|
|
||||||
|
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +297,6 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR];
|
virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR];
|
||||||
unsigned int nr_stats;
|
unsigned int nr_stats;
|
||||||
size_t i;
|
size_t i;
|
||||||
bool ret = false;
|
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
int period = -1;
|
int period = -1;
|
||||||
bool config = vshCommandOptBool(cmd, "config");
|
bool config = vshCommandOptBool(cmd, "config");
|
||||||
@ -326,26 +323,25 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
* This is not really an unsigned long, but it
|
* This is not really an unsigned long, but it
|
||||||
*/
|
*/
|
||||||
if ((rv = vshCommandOptInt(ctl, cmd, "period", &period)) < 0)
|
if ((rv = vshCommandOptInt(ctl, cmd, "period", &period)) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
if (rv > 0) {
|
if (rv > 0) {
|
||||||
if (period < 0) {
|
if (period < 0) {
|
||||||
vshError(ctl, _("Invalid collection period value '%d'"), period);
|
vshError(ctl, _("Invalid collection period value '%d'"), period);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainSetMemoryStatsPeriod(dom, period, flags) < 0) {
|
if (virDomainSetMemoryStatsPeriod(dom, period, flags) < 0) {
|
||||||
vshError(ctl, "%s",
|
vshError(ctl, "%s",
|
||||||
_("Unable to change balloon collection period."));
|
_("Unable to change balloon collection period."));
|
||||||
} else {
|
return false;
|
||||||
ret = true;
|
|
||||||
}
|
}
|
||||||
goto cleanup;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nr_stats = virDomainMemoryStats(dom, stats, VIR_DOMAIN_MEMORY_STAT_NR, 0);
|
nr_stats = virDomainMemoryStats(dom, stats, VIR_DOMAIN_MEMORY_STAT_NR, 0);
|
||||||
if (nr_stats == -1) {
|
if (nr_stats == -1) {
|
||||||
vshError(ctl, _("Failed to get memory statistics for domain %s"), name);
|
vshError(ctl, _("Failed to get memory statistics for domain %s"), name);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nr_stats; i++) {
|
for (i = 0; i < nr_stats; i++) {
|
||||||
@ -377,9 +373,7 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
vshPrint(ctl, "hugetlb_pgfail %llu\n", stats[i].val);
|
vshPrint(ctl, "hugetlb_pgfail %llu\n", stats[i].val);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -578,7 +572,6 @@ static const vshCmdOptDef opts_domblklist[] = {
|
|||||||
static bool
|
static bool
|
||||||
cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
|
cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
g_autoptr(xmlDoc) xmldoc = NULL;
|
g_autoptr(xmlDoc) xmldoc = NULL;
|
||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
@ -594,11 +587,11 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
|
|||||||
details = vshCommandOptBool(cmd, "details");
|
details = vshCommandOptBool(cmd, "details");
|
||||||
|
|
||||||
if (virshDomainGetXML(ctl, cmd, flags, &xmldoc, &ctxt) < 0)
|
if (virshDomainGetXML(ctl, cmd, flags, &xmldoc, &ctxt) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
ndisks = virXPathNodeSet("./devices/disk", ctxt, &disks);
|
ndisks = virXPathNodeSet("./devices/disk", ctxt, &disks);
|
||||||
if (ndisks < 0)
|
if (ndisks < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (details)
|
if (details)
|
||||||
table = vshTableNew(_("Type"), _("Device"), _("Target"), _("Source"), NULL);
|
table = vshTableNew(_("Type"), _("Device"), _("Target"), _("Source"), NULL);
|
||||||
@ -606,7 +599,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
|
|||||||
table = vshTableNew(_("Target"), _("Source"), NULL);
|
table = vshTableNew(_("Target"), _("Source"), NULL);
|
||||||
|
|
||||||
if (!table)
|
if (!table)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
for (i = 0; i < ndisks; i++) {
|
for (i = 0; i < ndisks; i++) {
|
||||||
g_autofree char *type = NULL;
|
g_autofree char *type = NULL;
|
||||||
@ -621,14 +614,14 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
|
|||||||
device = virXPathString("string(./@device)", ctxt);
|
device = virXPathString("string(./@device)", ctxt);
|
||||||
if (!type || !device) {
|
if (!type || !device) {
|
||||||
vshPrint(ctl, "unable to query block list details");
|
vshPrint(ctl, "unable to query block list details");
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
target = virXPathString("string(./target/@dev)", ctxt);
|
target = virXPathString("string(./target/@dev)", ctxt);
|
||||||
if (!target) {
|
if (!target) {
|
||||||
vshError(ctl, "unable to query block list");
|
vshError(ctl, "unable to query block list");
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STREQ_NULLABLE(type, "nvme")) {
|
if (STREQ_NULLABLE(type, "nvme")) {
|
||||||
@ -640,7 +633,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
|
|||||||
!(addrNode = virXPathNode("./source/address", ctxt)) ||
|
!(addrNode = virXPathNode("./source/address", ctxt)) ||
|
||||||
virPCIDeviceAddressParseXML(addrNode, &addr) < 0) {
|
virPCIDeviceAddressParseXML(addrNode, &addr) < 0) {
|
||||||
vshError(ctl, "Unable to query NVMe disk address");
|
vshError(ctl, "Unable to query NVMe disk address");
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
source = g_strdup_printf("nvme://%04x:%02x:%02x.%d/%s",
|
source = g_strdup_printf("nvme://%04x:%02x:%02x.%d/%s",
|
||||||
@ -657,20 +650,17 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (details) {
|
if (details) {
|
||||||
if (vshTableRowAppend(table, type, device, target,
|
if (vshTableRowAppend(table, type, device, target,
|
||||||
NULLSTR_MINUS(source), NULL) < 0)
|
NULLSTR_MINUS(source), NULL) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (vshTableRowAppend(table, target,
|
if (vshTableRowAppend(table, target,
|
||||||
NULLSTR_MINUS(source), NULL) < 0)
|
NULLSTR_MINUS(source), NULL) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vshTablePrintToStdout(table, ctl);
|
vshTablePrintToStdout(table, ctl);
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -694,7 +684,6 @@ static const vshCmdOptDef opts_domiflist[] = {
|
|||||||
static bool
|
static bool
|
||||||
cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
|
cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
g_autoptr(xmlDoc) xmldoc = NULL;
|
g_autoptr(xmlDoc) xmldoc = NULL;
|
||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
@ -707,16 +696,16 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
|
|||||||
flags |= VIR_DOMAIN_XML_INACTIVE;
|
flags |= VIR_DOMAIN_XML_INACTIVE;
|
||||||
|
|
||||||
if (virshDomainGetXML(ctl, cmd, flags, &xmldoc, &ctxt) < 0)
|
if (virshDomainGetXML(ctl, cmd, flags, &xmldoc, &ctxt) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
ninterfaces = virXPathNodeSet("./devices/interface", ctxt, &interfaces);
|
ninterfaces = virXPathNodeSet("./devices/interface", ctxt, &interfaces);
|
||||||
if (ninterfaces < 0)
|
if (ninterfaces < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
table = vshTableNew(_("Interface"), _("Type"),
|
table = vshTableNew(_("Interface"), _("Type"),
|
||||||
_("Source"), _("Model"), _("MAC"), NULL);
|
_("Source"), _("Model"), _("MAC"), NULL);
|
||||||
if (!table)
|
if (!table)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
for (i = 0; i < ninterfaces; i++) {
|
for (i = 0; i < ninterfaces; i++) {
|
||||||
g_autofree char *type = NULL;
|
g_autofree char *type = NULL;
|
||||||
@ -745,15 +734,12 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
|
|||||||
model ? model : "-",
|
model ? model : "-",
|
||||||
mac ? mac : "-",
|
mac ? mac : "-",
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vshTablePrintToStdout(table, ctl);
|
vshTablePrintToStdout(table, ctl);
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -798,7 +784,6 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
|
|||||||
g_autofree xmlNodePtr *interfaces = NULL;
|
g_autofree xmlNodePtr *interfaces = NULL;
|
||||||
int ninterfaces;
|
int ninterfaces;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0)
|
||||||
return false;
|
return false;
|
||||||
@ -807,7 +792,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
|
|||||||
flags = VIR_DOMAIN_XML_INACTIVE;
|
flags = VIR_DOMAIN_XML_INACTIVE;
|
||||||
|
|
||||||
if (virshDomainGetXML(ctl, cmd, flags, &xml, &ctxt) < 0)
|
if (virshDomainGetXML(ctl, cmd, flags, &xml, &ctxt) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
/* normalize the mac addr */
|
/* normalize the mac addr */
|
||||||
if (virMacAddrParse(iface, &macaddr) == 0)
|
if (virMacAddrParse(iface, &macaddr) == 0)
|
||||||
@ -819,7 +804,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
if ((ninterfaces = virXPathNodeSet(xpath, ctxt, &interfaces)) < 0) {
|
if ((ninterfaces = virXPathNodeSet(xpath, ctxt, &interfaces)) < 0) {
|
||||||
vshError(ctl, _("Failed to extract interface information"));
|
vshError(ctl, _("Failed to extract interface information"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ninterfaces < 1) {
|
if (ninterfaces < 1) {
|
||||||
@ -828,10 +813,10 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
|
|||||||
else
|
else
|
||||||
vshError(ctl, _("Interface (dev: %s) not found."), iface);
|
vshError(ctl, _("Interface (dev: %s) not found."), iface);
|
||||||
|
|
||||||
goto cleanup;
|
return false;
|
||||||
} else if (ninterfaces > 1) {
|
} else if (ninterfaces > 1) {
|
||||||
vshError(ctl, _("multiple matching interfaces found"));
|
vshError(ctl, _("multiple matching interfaces found"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxt->node = interfaces[0];
|
ctxt->node = interfaces[0];
|
||||||
@ -841,11 +826,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
|
|||||||
else
|
else
|
||||||
vshPrint(ctl, "%s up", iface);
|
vshPrint(ctl, "%s up", iface);
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -870,16 +851,13 @@ static bool
|
|||||||
cmdDomControl(vshControl *ctl, const vshCmd *cmd)
|
cmdDomControl(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
bool ret = true;
|
|
||||||
virDomainControlInfo info;
|
virDomainControlInfo info;
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (virDomainGetControlInfo(dom, &info, 0) < 0) {
|
if (virDomainGetControlInfo(dom, &info, 0) < 0)
|
||||||
ret = false;
|
return false;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info.state != VIR_DOMAIN_CONTROL_OK &&
|
if (info.state != VIR_DOMAIN_CONTROL_OK &&
|
||||||
info.state != VIR_DOMAIN_CONTROL_ERROR) {
|
info.state != VIR_DOMAIN_CONTROL_ERROR) {
|
||||||
@ -895,8 +873,7 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virshDomainControlStateToString(info.state));
|
virshDomainControlStateToString(info.state));
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
return true;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -977,7 +954,6 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
const char *field = NULL;
|
const char *field = NULL;
|
||||||
int rc, nparams = 0;
|
int rc, nparams = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
bool ret = false;
|
|
||||||
bool human = vshCommandOptBool(cmd, "human"); /* human readable output */
|
bool human = vshCommandOptBool(cmd, "human"); /* human readable output */
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
|
if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
|
||||||
@ -988,7 +964,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
API contract.
|
API contract.
|
||||||
*/
|
*/
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (!device)
|
if (!device)
|
||||||
device = "";
|
device = "";
|
||||||
@ -1002,7 +978,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
/* try older API if newer is not supported */
|
/* try older API if newer is not supported */
|
||||||
if (last_error->code != VIR_ERR_NO_SUPPORT)
|
if (last_error->code != VIR_ERR_NO_SUPPORT)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
vshResetLibvirtError();
|
vshResetLibvirtError();
|
||||||
|
|
||||||
@ -1010,7 +986,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
sizeof(stats)) == -1) {
|
sizeof(stats)) == -1) {
|
||||||
vshError(ctl, _("Failed to get block stats %s %s"),
|
vshError(ctl, _("Failed to get block stats %s %s"),
|
||||||
name, device);
|
name, device);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* human friendly output */
|
/* human friendly output */
|
||||||
@ -1028,7 +1004,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
params = g_new0(virTypedParameter, nparams);
|
params = g_new0(virTypedParameter, nparams);
|
||||||
if (virDomainBlockStatsFlags(dom, device, params, &nparams, 0) < 0) {
|
if (virDomainBlockStatsFlags(dom, device, params, &nparams, 0) < 0) {
|
||||||
vshError(ctl, _("Failed to get block stats for domain '%s' device '%s'"), name, device);
|
vshError(ctl, _("Failed to get block stats for domain '%s' device '%s'"), name, device);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set for prettier output */
|
/* set for prettier output */
|
||||||
@ -1077,10 +1053,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
#undef DOMBLKSTAT_LEGACY_PRINT
|
#undef DOMBLKSTAT_LEGACY_PRINT
|
||||||
|
|
||||||
@ -1114,17 +1087,16 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
const char *name = NULL, *device = NULL;
|
const char *name = NULL, *device = NULL;
|
||||||
virDomainInterfaceStatsStruct stats;
|
virDomainInterfaceStatsStruct stats;
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
|
if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (virDomainInterfaceStats(dom, device, &stats, sizeof(stats)) == -1) {
|
if (virDomainInterfaceStats(dom, device, &stats, sizeof(stats)) == -1) {
|
||||||
vshError(ctl, _("Failed to get interface stats %s %s"), name, device);
|
vshError(ctl, _("Failed to get interface stats %s %s"), name, device);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stats.rx_bytes >= 0)
|
if (stats.rx_bytes >= 0)
|
||||||
@ -1151,10 +1123,7 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (stats.tx_drop >= 0)
|
if (stats.tx_drop >= 0)
|
||||||
vshPrint(ctl, "%s tx_drop %lld\n", device, stats.tx_drop);
|
vshPrint(ctl, "%s tx_drop %lld\n", device, stats.tx_drop);
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1386,17 +1355,14 @@ static bool
|
|||||||
cmdDomstate(vshControl *ctl, const vshCmd *cmd)
|
cmdDomstate(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
bool ret = true;
|
|
||||||
bool showReason = vshCommandOptBool(cmd, "reason");
|
bool showReason = vshCommandOptBool(cmd, "reason");
|
||||||
int state, reason;
|
int state, reason;
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((state = virshDomainState(ctl, dom, &reason)) < 0) {
|
if ((state = virshDomainState(ctl, dom, &reason)) < 0)
|
||||||
ret = false;
|
return false;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showReason) {
|
if (showReason) {
|
||||||
vshPrint(ctl, "%s (%s)\n",
|
vshPrint(ctl, "%s (%s)\n",
|
||||||
@ -1407,8 +1373,7 @@ cmdDomstate(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virshDomainStateToString(state));
|
virshDomainStateToString(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
return true;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1449,7 +1414,6 @@ static bool
|
|||||||
cmdDomTime(vshControl *ctl, const vshCmd *cmd)
|
cmdDomTime(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
bool ret = false;
|
|
||||||
bool now = vshCommandOptBool(cmd, "now");
|
bool now = vshCommandOptBool(cmd, "now");
|
||||||
bool pretty = vshCommandOptBool(cmd, "pretty");
|
bool pretty = vshCommandOptBool(cmd, "pretty");
|
||||||
bool rtcSync = vshCommandOptBool(cmd, "sync");
|
bool rtcSync = vshCommandOptBool(cmd, "sync");
|
||||||
@ -1470,7 +1434,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
/* invalid integer format */
|
/* invalid integer format */
|
||||||
goto cleanup;
|
return false;
|
||||||
} else if (rv > 0) {
|
} else if (rv > 0) {
|
||||||
/* valid integer to set */
|
/* valid integer to set */
|
||||||
doSet = true;
|
doSet = true;
|
||||||
@ -1479,18 +1443,18 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (doSet || now || rtcSync) {
|
if (doSet || now || rtcSync) {
|
||||||
if (now && ((seconds = time(NULL)) == (time_t) -1)) {
|
if (now && ((seconds = time(NULL)) == (time_t) -1)) {
|
||||||
vshError(ctl, _("Unable to get current time"));
|
vshError(ctl, _("Unable to get current time"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtcSync)
|
if (rtcSync)
|
||||||
flags |= VIR_DOMAIN_TIME_SYNC;
|
flags |= VIR_DOMAIN_TIME_SYNC;
|
||||||
|
|
||||||
if (virDomainSetTime(dom, seconds, nseconds, flags) < 0)
|
if (virDomainSetTime(dom, seconds, nseconds, flags) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (virDomainGetTime(dom, &seconds, &nseconds, flags) < 0)
|
if (virDomainGetTime(dom, &seconds, &nseconds, flags) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (pretty) {
|
if (pretty) {
|
||||||
g_autoptr(GDateTime) then = NULL;
|
g_autoptr(GDateTime) then = NULL;
|
||||||
@ -1505,9 +1469,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -97,7 +97,6 @@ static const vshCmdOptDef opts_domcapabilities[] = {
|
|||||||
static bool
|
static bool
|
||||||
cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd)
|
cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
g_autofree char *caps = NULL;
|
g_autofree char *caps = NULL;
|
||||||
const char *virttype = NULL;
|
const char *virttype = NULL;
|
||||||
const char *emulatorbin = NULL;
|
const char *emulatorbin = NULL;
|
||||||
@ -110,19 +109,18 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd)
|
|||||||
vshCommandOptStringReq(ctl, cmd, "emulatorbin", &emulatorbin) < 0 ||
|
vshCommandOptStringReq(ctl, cmd, "emulatorbin", &emulatorbin) < 0 ||
|
||||||
vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 ||
|
vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 ||
|
||||||
vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0)
|
vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0)
|
||||||
return ret;
|
return false;
|
||||||
|
|
||||||
caps = virConnectGetDomainCapabilities(priv->conn, emulatorbin,
|
caps = virConnectGetDomainCapabilities(priv->conn, emulatorbin,
|
||||||
arch, machine, virttype, flags);
|
arch, machine, virttype, flags);
|
||||||
if (!caps) {
|
if (!caps) {
|
||||||
vshError(ctl, "%s", _("failed to get emulator capabilities"));
|
vshError(ctl, "%s", _("failed to get emulator capabilities"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vshPrint(ctl, "%s\n", caps);
|
vshPrint(ctl, "%s\n", caps);
|
||||||
ret = true;
|
|
||||||
cleanup:
|
return true;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -154,7 +152,6 @@ static const vshCmdOptDef opts_freecell[] = {
|
|||||||
static bool
|
static bool
|
||||||
cmdFreecell(vshControl *ctl, const vshCmd *cmd)
|
cmdFreecell(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
int cell = -1;
|
int cell = -1;
|
||||||
unsigned long long memory = 0;
|
unsigned long long memory = 0;
|
||||||
g_autofree xmlNodePtr *nodes = NULL;
|
g_autofree xmlNodePtr *nodes = NULL;
|
||||||
@ -177,13 +174,13 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (all) {
|
if (all) {
|
||||||
if (!(cap_xml = virConnectGetCapabilities(priv->conn))) {
|
if (!(cap_xml = virConnectGetCapabilities(priv->conn))) {
|
||||||
vshError(ctl, "%s", _("unable to get node capabilities"));
|
vshError(ctl, "%s", _("unable to get node capabilities"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
xml = virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt);
|
xml = virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
vshError(ctl, "%s", _("unable to get node capabilities"));
|
vshError(ctl, "%s", _("unable to get node capabilities"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes_cnt = virXPathNodeSet("/capabilities/host/topology/cells/cell",
|
nodes_cnt = virXPathNodeSet("/capabilities/host/topology/cells/cell",
|
||||||
@ -192,7 +189,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (nodes_cnt == -1) {
|
if (nodes_cnt == -1) {
|
||||||
vshError(ctl, "%s", _("could not get information about "
|
vshError(ctl, "%s", _("could not get information about "
|
||||||
"NUMA topology"));
|
"NUMA topology"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes_free = g_new0(unsigned long long, nodes_cnt);
|
nodes_free = g_new0(unsigned long long, nodes_cnt);
|
||||||
@ -203,14 +200,14 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
|
|||||||
g_autofree char *val = virXMLPropString(nodes[i], "id");
|
g_autofree char *val = virXMLPropString(nodes[i], "id");
|
||||||
if (virStrToLong_ulp(val, NULL, 10, &id)) {
|
if (virStrToLong_ulp(val, NULL, 10, &id)) {
|
||||||
vshError(ctl, "%s", _("conversion from string failed"));
|
vshError(ctl, "%s", _("conversion from string failed"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
nodes_id[i] = id;
|
nodes_id[i] = id;
|
||||||
if (virNodeGetCellsFreeMemory(priv->conn, &(nodes_free[i]),
|
if (virNodeGetCellsFreeMemory(priv->conn, &(nodes_free[i]),
|
||||||
id, 1) != 1) {
|
id, 1) != 1) {
|
||||||
vshError(ctl, _("failed to get free memory for NUMA node "
|
vshError(ctl, _("failed to get free memory for NUMA node "
|
||||||
"number: %lu"), id);
|
"number: %lu"), id);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,21 +222,18 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
|
|||||||
} else {
|
} else {
|
||||||
if (cellno) {
|
if (cellno) {
|
||||||
if (virNodeGetCellsFreeMemory(priv->conn, &memory, cell, 1) != 1)
|
if (virNodeGetCellsFreeMemory(priv->conn, &memory, cell, 1) != 1)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
vshPrint(ctl, "%d: %llu KiB\n", cell, (memory/1024));
|
vshPrint(ctl, "%d: %llu KiB\n", cell, (memory/1024));
|
||||||
} else {
|
} else {
|
||||||
if ((memory = virNodeGetFreeMemory(priv->conn)) == 0)
|
if ((memory = virNodeGetFreeMemory(priv->conn)) == 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
vshPrint(ctl, "%s: %llu KiB\n", _("Total"), (memory/1024));
|
vshPrint(ctl, "%s: %llu KiB\n", _("Total"), (memory/1024));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -476,7 +470,6 @@ static const vshCmdOptDef opts_allocpages[] = {
|
|||||||
static bool
|
static bool
|
||||||
cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
|
cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
bool add = vshCommandOptBool(cmd, "add");
|
bool add = vshCommandOptBool(cmd, "add");
|
||||||
bool all = vshCommandOptBool(cmd, "all");
|
bool all = vshCommandOptBool(cmd, "all");
|
||||||
bool cellno = vshCommandOptBool(cmd, "cellno");
|
bool cellno = vshCommandOptBool(cmd, "cellno");
|
||||||
@ -511,13 +504,13 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
if (!(cap_xml = virConnectGetCapabilities(priv->conn))) {
|
if (!(cap_xml = virConnectGetCapabilities(priv->conn))) {
|
||||||
vshError(ctl, "%s", _("unable to get node capabilities"));
|
vshError(ctl, "%s", _("unable to get node capabilities"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
xml = virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt);
|
xml = virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
vshError(ctl, "%s", _("unable to get node capabilities"));
|
vshError(ctl, "%s", _("unable to get node capabilities"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes_cnt = virXPathNodeSet("/capabilities/host/topology/cells/cell",
|
nodes_cnt = virXPathNodeSet("/capabilities/host/topology/cells/cell",
|
||||||
@ -526,7 +519,7 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (nodes_cnt == -1) {
|
if (nodes_cnt == -1) {
|
||||||
vshError(ctl, "%s", _("could not get information about "
|
vshError(ctl, "%s", _("could not get information about "
|
||||||
"NUMA topology"));
|
"NUMA topology"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nodes_cnt; i++) {
|
for (i = 0; i < nodes_cnt; i++) {
|
||||||
@ -534,22 +527,20 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
|
|||||||
g_autofree char *val = virXMLPropString(nodes[i], "id");
|
g_autofree char *val = virXMLPropString(nodes[i], "id");
|
||||||
if (virStrToLong_ulp(val, NULL, 10, &id)) {
|
if (virStrToLong_ulp(val, NULL, 10, &id)) {
|
||||||
vshError(ctl, "%s", _("conversion from string failed"));
|
vshError(ctl, "%s", _("conversion from string failed"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virNodeAllocPages(priv->conn, 1, pageSizes,
|
if (virNodeAllocPages(priv->conn, 1, pageSizes,
|
||||||
pageCounts, id, 1, flags) < 0)
|
pageCounts, id, 1, flags) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (virNodeAllocPages(priv->conn, 1, pageSizes, pageCounts,
|
if (virNodeAllocPages(priv->conn, 1, pageSizes, pageCounts,
|
||||||
startCell, cellCount, flags) < 0)
|
startCell, cellCount, flags) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -583,7 +574,6 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
|
|||||||
g_autoptr(xmlDoc) xml = NULL;
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
virshControl *priv = ctl->privData;
|
virshControl *priv = ctl->privData;
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
|
||||||
return false;
|
return false;
|
||||||
@ -591,7 +581,7 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if ((caps = virConnectGetDomainCapabilities(priv->conn, NULL, NULL, NULL,
|
if ((caps = virConnectGetDomainCapabilities(priv->conn, NULL, NULL, NULL,
|
||||||
type, 0))) {
|
type, 0))) {
|
||||||
if (!(xml = virXMLParseStringCtxt(caps, _("(domainCapabilities)"), &ctxt)))
|
if (!(xml = virXMLParseStringCtxt(caps, _("(domainCapabilities)"), &ctxt)))
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
ignore_value(virXPathInt("string(./vcpu[1]/@max)", ctxt, &vcpus));
|
ignore_value(virXPathInt("string(./vcpu[1]/@max)", ctxt, &vcpus));
|
||||||
} else {
|
} else {
|
||||||
@ -599,13 +589,11 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vcpus < 0 && (vcpus = virConnectGetMaxVcpus(priv->conn, type)) < 0)
|
if (vcpus < 0 && (vcpus = virConnectGetMaxVcpus(priv->conn, type)) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
vshPrint(ctl, "%d\n", vcpus);
|
vshPrint(ctl, "%d\n", vcpus);
|
||||||
ret = true;
|
|
||||||
|
|
||||||
cleanup:
|
return true;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -673,13 +661,12 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
|
|||||||
g_autofree unsigned char *cpumap = NULL;
|
g_autofree unsigned char *cpumap = NULL;
|
||||||
unsigned int online;
|
unsigned int online;
|
||||||
bool pretty = vshCommandOptBool(cmd, "pretty");
|
bool pretty = vshCommandOptBool(cmd, "pretty");
|
||||||
bool ret = false;
|
|
||||||
virshControl *priv = ctl->privData;
|
virshControl *priv = ctl->privData;
|
||||||
|
|
||||||
cpunum = virNodeGetCPUMap(priv->conn, &cpumap, &online, 0);
|
cpunum = virNodeGetCPUMap(priv->conn, &cpumap, &online, 0);
|
||||||
if (cpunum < 0) {
|
if (cpunum < 0) {
|
||||||
vshError(ctl, "%s", _("Unable to get cpu map"));
|
vshError(ctl, "%s", _("Unable to get cpu map"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vshPrint(ctl, "%-15s %d\n", _("CPUs present:"), cpunum);
|
vshPrint(ctl, "%-15s %d\n", _("CPUs present:"), cpunum);
|
||||||
@ -690,7 +677,7 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
|
|||||||
g_autofree char *str = virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(cpunum));
|
g_autofree char *str = virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(cpunum));
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
goto cleanup;
|
return false;
|
||||||
vshPrint(ctl, "%s", str);
|
vshPrint(ctl, "%s", str);
|
||||||
} else {
|
} else {
|
||||||
for (cpu = 0; cpu < cpunum; cpu++)
|
for (cpu = 0; cpu < cpunum; cpu++)
|
||||||
@ -698,10 +685,7 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
|
|||||||
}
|
}
|
||||||
vshPrint(ctl, "\n");
|
vshPrint(ctl, "\n");
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -767,7 +751,6 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
|
|||||||
int cpuNum = VIR_NODE_CPU_STATS_ALL_CPUS;
|
int cpuNum = VIR_NODE_CPU_STATS_ALL_CPUS;
|
||||||
g_autofree virNodeCPUStatsPtr params = NULL;
|
g_autofree virNodeCPUStatsPtr params = NULL;
|
||||||
int nparams = 0;
|
int nparams = 0;
|
||||||
bool ret = false;
|
|
||||||
unsigned long long cpu_stats[VIRSH_CPU_LAST] = { 0 };
|
unsigned long long cpu_stats[VIRSH_CPU_LAST] = { 0 };
|
||||||
bool present[VIRSH_CPU_LAST] = { false };
|
bool present[VIRSH_CPU_LAST] = { false };
|
||||||
virshControl *priv = ctl->privData;
|
virshControl *priv = ctl->privData;
|
||||||
@ -791,7 +774,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
|
|||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
if (virNodeGetCPUStats(priv->conn, cpuNum, params, &nparams, 0) != 0) {
|
if (virNodeGetCPUStats(priv->conn, cpuNum, params, &nparams, 0) != 0) {
|
||||||
vshError(ctl, "%s", _("Unable to get node cpu stats"));
|
vshError(ctl, "%s", _("Unable to get node cpu stats"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < nparams; j++) {
|
for (j = 0; j < nparams; j++) {
|
||||||
@ -845,10 +828,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -879,7 +859,6 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
|
|||||||
size_t i;
|
size_t i;
|
||||||
int cellNum = VIR_NODE_MEMORY_STATS_ALL_CELLS;
|
int cellNum = VIR_NODE_MEMORY_STATS_ALL_CELLS;
|
||||||
g_autofree virNodeMemoryStatsPtr params = NULL;
|
g_autofree virNodeMemoryStatsPtr params = NULL;
|
||||||
bool ret = false;
|
|
||||||
virshControl *priv = ctl->privData;
|
virshControl *priv = ctl->privData;
|
||||||
|
|
||||||
if (vshCommandOptInt(ctl, cmd, "cell", &cellNum) < 0)
|
if (vshCommandOptInt(ctl, cmd, "cell", &cellNum) < 0)
|
||||||
@ -889,29 +868,25 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (virNodeGetMemoryStats(priv->conn, cellNum, NULL, &nparams, 0) != 0) {
|
if (virNodeGetMemoryStats(priv->conn, cellNum, NULL, &nparams, 0) != 0) {
|
||||||
vshError(ctl, "%s",
|
vshError(ctl, "%s",
|
||||||
_("Unable to get number of memory stats"));
|
_("Unable to get number of memory stats"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nparams == 0) {
|
if (nparams == 0) {
|
||||||
/* nothing to output */
|
/* nothing to output */
|
||||||
ret = true;
|
return true;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now go get all the memory parameters */
|
/* now go get all the memory parameters */
|
||||||
params = g_new0(virNodeMemoryStats, nparams);
|
params = g_new0(virNodeMemoryStats, nparams);
|
||||||
if (virNodeGetMemoryStats(priv->conn, cellNum, params, &nparams, 0) != 0) {
|
if (virNodeGetMemoryStats(priv->conn, cellNum, params, &nparams, 0) != 0) {
|
||||||
vshError(ctl, "%s", _("Unable to get memory stats"));
|
vshError(ctl, "%s", _("Unable to get memory stats"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nparams; i++)
|
for (i = 0; i < nparams; i++)
|
||||||
vshPrint(ctl, "%-7s: %20llu KiB\n", params[i].field, params[i].value);
|
vshPrint(ctl, "%-7s: %20llu KiB\n", params[i].field, params[i].value);
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -122,11 +122,11 @@ vshFindNodeDevice(vshControl *ctl, const char *value)
|
|||||||
narr = vshStringToArray(value, &arr);
|
narr = vshStringToArray(value, &arr);
|
||||||
if (narr != 2) {
|
if (narr != 2) {
|
||||||
vshError(ctl, _("Malformed device value '%s'"), value);
|
vshError(ctl, _("Malformed device value '%s'"), value);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virValidateWWN(arr[0]) || !virValidateWWN(arr[1]))
|
if (!virValidateWWN(arr[0]) || !virValidateWWN(arr[1]))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
dev = virNodeDeviceLookupSCSIHostByWWN(priv->conn, arr[0], arr[1], 0);
|
dev = virNodeDeviceLookupSCSIHostByWWN(priv->conn, arr[0], arr[1], 0);
|
||||||
} else {
|
} else {
|
||||||
@ -135,10 +135,9 @@ vshFindNodeDevice(vshControl *ctl, const char *value)
|
|||||||
|
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
vshError(ctl, "%s '%s'", _("Could not find matching device"), value);
|
vshError(ctl, "%s '%s'", _("Could not find matching device"), value);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,17 +529,16 @@ virshMakeCloneXML(const char *origxml, const char *newname)
|
|||||||
|
|
||||||
doc = virXMLParseStringCtxt(origxml, _("(volume_definition)"), &ctxt);
|
doc = virXMLParseStringCtxt(origxml, _("(volume_definition)"), &ctxt);
|
||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
obj = xmlXPathEval(BAD_CAST "/volume/name", ctxt);
|
obj = xmlXPathEval(BAD_CAST "/volume/name", ctxt);
|
||||||
if (obj == NULL || obj->nodesetval == NULL ||
|
if (obj == NULL || obj->nodesetval == NULL ||
|
||||||
obj->nodesetval->nodeTab == NULL)
|
obj->nodesetval->nodeTab == NULL)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
xmlNodeSetContent(obj->nodesetval->nodeTab[0], (const xmlChar *)newname);
|
xmlNodeSetContent(obj->nodesetval->nodeTab[0], (const xmlChar *)newname);
|
||||||
xmlDocDumpMemory(doc, &newxml, &size);
|
xmlDocDumpMemory(doc, &newxml, &size);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return newxml;
|
return newxml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
tools/vsh.c
11
tools/vsh.c
@ -432,7 +432,6 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
|
|||||||
bool report)
|
bool report)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
const vshCmdOptDef *ret = NULL;
|
|
||||||
g_autofree char *alias = NULL;
|
g_autofree char *alias = NULL;
|
||||||
|
|
||||||
if (STREQ(name, helpopt.name))
|
if (STREQ(name, helpopt.name))
|
||||||
@ -457,7 +456,7 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
|
|||||||
if (report)
|
if (report)
|
||||||
vshError(ctl, _("invalid '=' after option --%s"),
|
vshError(ctl, _("invalid '=' after option --%s"),
|
||||||
opt->name);
|
opt->name);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
*optstr = g_strdup(value + 1);
|
*optstr = g_strdup(value + 1);
|
||||||
}
|
}
|
||||||
@ -466,12 +465,11 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
|
|||||||
if ((*opts_seen & (1ULL << i)) && opt->type != VSH_OT_ARGV) {
|
if ((*opts_seen & (1ULL << i)) && opt->type != VSH_OT_ARGV) {
|
||||||
if (report)
|
if (report)
|
||||||
vshError(ctl, _("option --%s already seen"), name);
|
vshError(ctl, _("option --%s already seen"), name);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
*opts_seen |= 1ULL << i;
|
*opts_seen |= 1ULL << i;
|
||||||
*opt_index = i;
|
*opt_index = i;
|
||||||
ret = opt;
|
return opt;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,8 +477,7 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
|
|||||||
vshError(ctl, _("command '%s' doesn't support option --%s"),
|
vshError(ctl, _("command '%s' doesn't support option --%s"),
|
||||||
cmd->name, name);
|
cmd->name, name);
|
||||||
}
|
}
|
||||||
cleanup:
|
return NULL;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const vshCmdOptDef *
|
static const vshCmdOptDef *
|
||||||
|
Loading…
Reference in New Issue
Block a user