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:
Ján Tomko 2021-08-12 09:59:20 +02:00
parent fba265e2b2
commit bd1f40fe7d
7 changed files with 323 additions and 581 deletions

View File

@ -447,7 +447,6 @@ virshDomainIOThreadIdCompleter(vshControl *ctl,
g_autofree virDomainIOThreadInfoPtr *info = NULL;
size_t i;
int rc;
char **ret = NULL;
g_auto(GStrv) tmp = NULL;
virCheckFlags(0, NULL);
@ -456,7 +455,7 @@ virshDomainIOThreadIdCompleter(vshControl *ctl,
return NULL;
if ((rc = virDomainGetIOThreadInfo(dom, &info, flags)) < 0)
goto cleanup;
return NULL;
niothreads = rc;
@ -465,10 +464,7 @@ virshDomainIOThreadIdCompleter(vshControl *ctl,
for (i = 0; i < niothreads; i++)
tmp[i] = g_strdup_printf("%u", info[i]->iothread_id);
ret = g_steal_pointer(&tmp);
cleanup:
return ret;
return g_steal_pointer(&tmp);
}
@ -482,7 +478,6 @@ virshDomainVcpuCompleter(vshControl *ctl,
g_autoptr(xmlXPathContext) ctxt = NULL;
int nvcpus = 0;
unsigned int id;
char **ret = NULL;
g_auto(GStrv) tmp = NULL;
virCheckFlags(0, NULL);
@ -492,21 +487,18 @@ virshDomainVcpuCompleter(vshControl *ctl,
if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE,
&xml, &ctxt) < 0)
goto cleanup;
return NULL;
/* Query the max rather than the current vcpu count */
if (virXPathInt("string(/domain/vcpu)", ctxt, &nvcpus) < 0)
goto cleanup;
return NULL;
tmp = g_new0(char *, nvcpus + 1);
for (id = 0; id < nvcpus; id++)
tmp[id] = g_strdup_printf("%u", id);
ret = g_steal_pointer(&tmp);
cleanup:
return ret;
return g_steal_pointer(&tmp);
}
@ -522,7 +514,6 @@ virshDomainVcpulistCompleter(vshControl *ctl,
unsigned int id;
g_auto(GStrv) vcpulist = NULL;
const char *vcpuid = NULL;
char **ret = NULL;
virCheckFlags(0, NULL);
@ -530,25 +521,22 @@ virshDomainVcpulistCompleter(vshControl *ctl,
return NULL;
if (vshCommandOptStringQuiet(ctl, cmd, "vcpulist", &vcpuid) < 0)
goto cleanup;
return NULL;
if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE,
&xml, &ctxt) < 0)
goto cleanup;
return NULL;
/* Query the max rather than the current vcpu count */
if (virXPathInt("string(/domain/vcpu)", ctxt, &nvcpus) < 0)
goto cleanup;
return NULL;
vcpulist = g_new0(char *, nvcpus + 1);
for (id = 0; id < nvcpus; id++)
vcpulist[id] = g_strdup_printf("%u", id);
ret = virshCommaStringListComplete(vcpuid, (const char **)vcpulist);
cleanup:
return ret;
return virshCommaStringListComplete(vcpuid, (const char **)vcpulist);
}

View File

@ -81,7 +81,7 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title,
/* fall back to xml */
if (virshDomainGetXMLFromDom(ctl, dom, flags, &doc, &ctxt) < 0)
goto cleanup;
return NULL;
if (title)
desc = virXPathString("string(./title[1])", ctxt);
@ -91,8 +91,6 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title,
if (!desc)
desc = g_strdup("");
cleanup:
return desc;
}
@ -299,7 +297,6 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR];
unsigned int nr_stats;
size_t i;
bool ret = false;
int rv = 0;
int period = -1;
bool config = vshCommandOptBool(cmd, "config");
@ -326,26 +323,25 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
* This is not really an unsigned long, but it
*/
if ((rv = vshCommandOptInt(ctl, cmd, "period", &period)) < 0)
goto cleanup;
return false;
if (rv > 0) {
if (period < 0) {
vshError(ctl, _("Invalid collection period value '%d'"), period);
goto cleanup;
return false;
}
if (virDomainSetMemoryStatsPeriod(dom, period, flags) < 0) {
vshError(ctl, "%s",
_("Unable to change balloon collection period."));
} else {
ret = true;
return false;
}
goto cleanup;
return true;
}
nr_stats = virDomainMemoryStats(dom, stats, VIR_DOMAIN_MEMORY_STAT_NR, 0);
if (nr_stats == -1) {
vshError(ctl, _("Failed to get memory statistics for domain %s"), name);
goto cleanup;
return false;
}
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);
}
ret = true;
cleanup:
return ret;
return true;
}
/*
@ -578,7 +572,6 @@ static const vshCmdOptDef opts_domblklist[] = {
static bool
cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
unsigned int flags = 0;
g_autoptr(xmlDoc) xmldoc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
@ -594,11 +587,11 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
details = vshCommandOptBool(cmd, "details");
if (virshDomainGetXML(ctl, cmd, flags, &xmldoc, &ctxt) < 0)
goto cleanup;
return false;
ndisks = virXPathNodeSet("./devices/disk", ctxt, &disks);
if (ndisks < 0)
goto cleanup;
return false;
if (details)
table = vshTableNew(_("Type"), _("Device"), _("Target"), _("Source"), NULL);
@ -606,7 +599,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
table = vshTableNew(_("Target"), _("Source"), NULL);
if (!table)
goto cleanup;
return false;
for (i = 0; i < ndisks; i++) {
g_autofree char *type = NULL;
@ -621,14 +614,14 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
device = virXPathString("string(./@device)", ctxt);
if (!type || !device) {
vshPrint(ctl, "unable to query block list details");
goto cleanup;
return false;
}
}
target = virXPathString("string(./target/@dev)", ctxt);
if (!target) {
vshError(ctl, "unable to query block list");
goto cleanup;
return false;
}
if (STREQ_NULLABLE(type, "nvme")) {
@ -640,7 +633,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
!(addrNode = virXPathNode("./source/address", ctxt)) ||
virPCIDeviceAddressParseXML(addrNode, &addr) < 0) {
vshError(ctl, "Unable to query NVMe disk address");
goto cleanup;
return false;
}
source = g_strdup_printf("nvme://%04x:%02x:%02x.%d/%s",
@ -657,20 +650,17 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
if (details) {
if (vshTableRowAppend(table, type, device, target,
NULLSTR_MINUS(source), NULL) < 0)
goto cleanup;
return false;
} else {
if (vshTableRowAppend(table, target,
NULLSTR_MINUS(source), NULL) < 0)
goto cleanup;
return false;
}
}
vshTablePrintToStdout(table, ctl);
ret = true;
cleanup:
return ret;
return true;
}
/*
@ -694,7 +684,6 @@ static const vshCmdOptDef opts_domiflist[] = {
static bool
cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
unsigned int flags = 0;
g_autoptr(xmlDoc) xmldoc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
@ -707,16 +696,16 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_XML_INACTIVE;
if (virshDomainGetXML(ctl, cmd, flags, &xmldoc, &ctxt) < 0)
goto cleanup;
return false;
ninterfaces = virXPathNodeSet("./devices/interface", ctxt, &interfaces);
if (ninterfaces < 0)
goto cleanup;
return false;
table = vshTableNew(_("Interface"), _("Type"),
_("Source"), _("Model"), _("MAC"), NULL);
if (!table)
goto cleanup;
return false;
for (i = 0; i < ninterfaces; i++) {
g_autofree char *type = NULL;
@ -745,15 +734,12 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
model ? model : "-",
mac ? mac : "-",
NULL) < 0)
goto cleanup;
return false;
}
vshTablePrintToStdout(table, ctl);
ret = true;
cleanup:
return ret;
return true;
}
/*
@ -798,7 +784,6 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
g_autofree xmlNodePtr *interfaces = NULL;
int ninterfaces;
unsigned int flags = 0;
bool ret = false;
if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0)
return false;
@ -807,7 +792,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
flags = VIR_DOMAIN_XML_INACTIVE;
if (virshDomainGetXML(ctl, cmd, flags, &xml, &ctxt) < 0)
goto cleanup;
return false;
/* normalize the mac addr */
if (virMacAddrParse(iface, &macaddr) == 0)
@ -819,7 +804,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
if ((ninterfaces = virXPathNodeSet(xpath, ctxt, &interfaces)) < 0) {
vshError(ctl, _("Failed to extract interface information"));
goto cleanup;
return false;
}
if (ninterfaces < 1) {
@ -828,10 +813,10 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
else
vshError(ctl, _("Interface (dev: %s) not found."), iface);
goto cleanup;
return false;
} else if (ninterfaces > 1) {
vshError(ctl, _("multiple matching interfaces found"));
goto cleanup;
return false;
}
ctxt->node = interfaces[0];
@ -841,11 +826,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
else
vshPrint(ctl, "%s up", iface);
ret = true;
cleanup:
return ret;
return true;
}
/*
@ -870,16 +851,13 @@ static bool
cmdDomControl(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshDomain) dom = NULL;
bool ret = true;
virDomainControlInfo info;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
if (virDomainGetControlInfo(dom, &info, 0) < 0) {
ret = false;
goto cleanup;
}
if (virDomainGetControlInfo(dom, &info, 0) < 0)
return false;
if (info.state != VIR_DOMAIN_CONTROL_OK &&
info.state != VIR_DOMAIN_CONTROL_ERROR) {
@ -895,8 +873,7 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd)
virshDomainControlStateToString(info.state));
}
cleanup:
return ret;
return true;
}
/*
@ -977,7 +954,6 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
const char *field = NULL;
int rc, nparams = 0;
size_t i;
bool ret = false;
bool human = vshCommandOptBool(cmd, "human"); /* human readable output */
if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
@ -988,7 +964,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
API contract.
*/
if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0)
goto cleanup;
return false;
if (!device)
device = "";
@ -1002,7 +978,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
if (rc < 0) {
/* try older API if newer is not supported */
if (last_error->code != VIR_ERR_NO_SUPPORT)
goto cleanup;
return false;
vshResetLibvirtError();
@ -1010,7 +986,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
sizeof(stats)) == -1) {
vshError(ctl, _("Failed to get block stats %s %s"),
name, device);
goto cleanup;
return false;
}
/* human friendly output */
@ -1028,7 +1004,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
params = g_new0(virTypedParameter, nparams);
if (virDomainBlockStatsFlags(dom, device, params, &nparams, 0) < 0) {
vshError(ctl, _("Failed to get block stats for domain '%s' device '%s'"), name, device);
goto cleanup;
return false;
}
/* set for prettier output */
@ -1077,10 +1053,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
}
}
ret = true;
cleanup:
return ret;
return true;
}
#undef DOMBLKSTAT_LEGACY_PRINT
@ -1114,17 +1087,16 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd)
g_autoptr(virshDomain) dom = NULL;
const char *name = NULL, *device = NULL;
virDomainInterfaceStatsStruct stats;
bool ret = false;
if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
return false;
if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0)
goto cleanup;
return false;
if (virDomainInterfaceStats(dom, device, &stats, sizeof(stats)) == -1) {
vshError(ctl, _("Failed to get interface stats %s %s"), name, device);
goto cleanup;
return false;
}
if (stats.rx_bytes >= 0)
@ -1151,10 +1123,7 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd)
if (stats.tx_drop >= 0)
vshPrint(ctl, "%s tx_drop %lld\n", device, stats.tx_drop);
ret = true;
cleanup:
return ret;
return true;
}
/*
@ -1386,17 +1355,14 @@ static bool
cmdDomstate(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshDomain) dom = NULL;
bool ret = true;
bool showReason = vshCommandOptBool(cmd, "reason");
int state, reason;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
if ((state = virshDomainState(ctl, dom, &reason)) < 0) {
ret = false;
goto cleanup;
}
if ((state = virshDomainState(ctl, dom, &reason)) < 0)
return false;
if (showReason) {
vshPrint(ctl, "%s (%s)\n",
@ -1407,8 +1373,7 @@ cmdDomstate(vshControl *ctl, const vshCmd *cmd)
virshDomainStateToString(state));
}
cleanup:
return ret;
return true;
}
/*
@ -1449,7 +1414,6 @@ static bool
cmdDomTime(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshDomain) dom = NULL;
bool ret = false;
bool now = vshCommandOptBool(cmd, "now");
bool pretty = vshCommandOptBool(cmd, "pretty");
bool rtcSync = vshCommandOptBool(cmd, "sync");
@ -1470,7 +1434,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
if (rv < 0) {
/* invalid integer format */
goto cleanup;
return false;
} else if (rv > 0) {
/* valid integer to set */
doSet = true;
@ -1479,18 +1443,18 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
if (doSet || now || rtcSync) {
if (now && ((seconds = time(NULL)) == (time_t) -1)) {
vshError(ctl, _("Unable to get current time"));
goto cleanup;
return false;
}
if (rtcSync)
flags |= VIR_DOMAIN_TIME_SYNC;
if (virDomainSetTime(dom, seconds, nseconds, flags) < 0)
goto cleanup;
return false;
} else {
if (virDomainGetTime(dom, &seconds, &nseconds, flags) < 0)
goto cleanup;
return false;
if (pretty) {
g_autoptr(GDateTime) then = NULL;
@ -1505,9 +1469,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
}
}
ret = true;
cleanup:
return ret;
return true;
}
/*

File diff suppressed because it is too large Load Diff

View File

@ -97,7 +97,6 @@ static const vshCmdOptDef opts_domcapabilities[] = {
static bool
cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
g_autofree char *caps = NULL;
const char *virttype = NULL;
const char *emulatorbin = NULL;
@ -110,19 +109,18 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd)
vshCommandOptStringReq(ctl, cmd, "emulatorbin", &emulatorbin) < 0 ||
vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 ||
vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0)
return ret;
return false;
caps = virConnectGetDomainCapabilities(priv->conn, emulatorbin,
arch, machine, virttype, flags);
if (!caps) {
vshError(ctl, "%s", _("failed to get emulator capabilities"));
goto cleanup;
return false;
}
vshPrint(ctl, "%s\n", caps);
ret = true;
cleanup:
return ret;
return true;
}
/*
@ -154,7 +152,6 @@ static const vshCmdOptDef opts_freecell[] = {
static bool
cmdFreecell(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
int cell = -1;
unsigned long long memory = 0;
g_autofree xmlNodePtr *nodes = NULL;
@ -177,13 +174,13 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
if (all) {
if (!(cap_xml = virConnectGetCapabilities(priv->conn))) {
vshError(ctl, "%s", _("unable to get node capabilities"));
goto cleanup;
return false;
}
xml = virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt);
if (!xml) {
vshError(ctl, "%s", _("unable to get node capabilities"));
goto cleanup;
return false;
}
nodes_cnt = virXPathNodeSet("/capabilities/host/topology/cells/cell",
@ -192,7 +189,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
if (nodes_cnt == -1) {
vshError(ctl, "%s", _("could not get information about "
"NUMA topology"));
goto cleanup;
return false;
}
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");
if (virStrToLong_ulp(val, NULL, 10, &id)) {
vshError(ctl, "%s", _("conversion from string failed"));
goto cleanup;
return false;
}
nodes_id[i] = id;
if (virNodeGetCellsFreeMemory(priv->conn, &(nodes_free[i]),
id, 1) != 1) {
vshError(ctl, _("failed to get free memory for NUMA node "
"number: %lu"), id);
goto cleanup;
return false;
}
}
@ -225,21 +222,18 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
} else {
if (cellno) {
if (virNodeGetCellsFreeMemory(priv->conn, &memory, cell, 1) != 1)
goto cleanup;
return false;
vshPrint(ctl, "%d: %llu KiB\n", cell, (memory/1024));
} else {
if ((memory = virNodeGetFreeMemory(priv->conn)) == 0)
goto cleanup;
return false;
vshPrint(ctl, "%s: %llu KiB\n", _("Total"), (memory/1024));
}
}
ret = true;
cleanup:
return ret;
return true;
}
@ -476,7 +470,6 @@ static const vshCmdOptDef opts_allocpages[] = {
static bool
cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
bool add = vshCommandOptBool(cmd, "add");
bool all = vshCommandOptBool(cmd, "all");
bool cellno = vshCommandOptBool(cmd, "cellno");
@ -511,13 +504,13 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
if (!(cap_xml = virConnectGetCapabilities(priv->conn))) {
vshError(ctl, "%s", _("unable to get node capabilities"));
goto cleanup;
return false;
}
xml = virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt);
if (!xml) {
vshError(ctl, "%s", _("unable to get node capabilities"));
goto cleanup;
return false;
}
nodes_cnt = virXPathNodeSet("/capabilities/host/topology/cells/cell",
@ -526,7 +519,7 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
if (nodes_cnt == -1) {
vshError(ctl, "%s", _("could not get information about "
"NUMA topology"));
goto cleanup;
return false;
}
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");
if (virStrToLong_ulp(val, NULL, 10, &id)) {
vshError(ctl, "%s", _("conversion from string failed"));
goto cleanup;
return false;
}
if (virNodeAllocPages(priv->conn, 1, pageSizes,
pageCounts, id, 1, flags) < 0)
goto cleanup;
return false;
}
} else {
if (virNodeAllocPages(priv->conn, 1, pageSizes, pageCounts,
startCell, cellCount, flags) < 0)
goto cleanup;
return false;
}
ret = true;
cleanup:
return ret;
return true;
}
@ -583,7 +574,6 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
virshControl *priv = ctl->privData;
bool ret = false;
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
return false;
@ -591,7 +581,7 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
if ((caps = virConnectGetDomainCapabilities(priv->conn, NULL, NULL, NULL,
type, 0))) {
if (!(xml = virXMLParseStringCtxt(caps, _("(domainCapabilities)"), &ctxt)))
goto cleanup;
return false;
ignore_value(virXPathInt("string(./vcpu[1]/@max)", ctxt, &vcpus));
} else {
@ -599,13 +589,11 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
}
if (vcpus < 0 && (vcpus = virConnectGetMaxVcpus(priv->conn, type)) < 0)
goto cleanup;
return false;
vshPrint(ctl, "%d\n", vcpus);
ret = true;
cleanup:
return ret;
return true;
}
/*
@ -673,13 +661,12 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
g_autofree unsigned char *cpumap = NULL;
unsigned int online;
bool pretty = vshCommandOptBool(cmd, "pretty");
bool ret = false;
virshControl *priv = ctl->privData;
cpunum = virNodeGetCPUMap(priv->conn, &cpumap, &online, 0);
if (cpunum < 0) {
vshError(ctl, "%s", _("Unable to get cpu map"));
goto cleanup;
return false;
}
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));
if (!str)
goto cleanup;
return false;
vshPrint(ctl, "%s", str);
} else {
for (cpu = 0; cpu < cpunum; cpu++)
@ -698,10 +685,7 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
}
vshPrint(ctl, "\n");
ret = true;
cleanup:
return ret;
return true;
}
/*
@ -767,7 +751,6 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
int cpuNum = VIR_NODE_CPU_STATS_ALL_CPUS;
g_autofree virNodeCPUStatsPtr params = NULL;
int nparams = 0;
bool ret = false;
unsigned long long cpu_stats[VIRSH_CPU_LAST] = { 0 };
bool present[VIRSH_CPU_LAST] = { false };
virshControl *priv = ctl->privData;
@ -791,7 +774,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
for (i = 0; i < 2; i++) {
if (virNodeGetCPUStats(priv->conn, cpuNum, params, &nparams, 0) != 0) {
vshError(ctl, "%s", _("Unable to get node cpu stats"));
goto cleanup;
return false;
}
for (j = 0; j < nparams; j++) {
@ -845,10 +828,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
}
}
ret = true;
cleanup:
return ret;
return true;
}
/*
@ -879,7 +859,6 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
size_t i;
int cellNum = VIR_NODE_MEMORY_STATS_ALL_CELLS;
g_autofree virNodeMemoryStatsPtr params = NULL;
bool ret = false;
virshControl *priv = ctl->privData;
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) {
vshError(ctl, "%s",
_("Unable to get number of memory stats"));
goto cleanup;
return false;
}
if (nparams == 0) {
/* nothing to output */
ret = true;
goto cleanup;
return true;
}
/* now go get all the memory parameters */
params = g_new0(virNodeMemoryStats, nparams);
if (virNodeGetMemoryStats(priv->conn, cellNum, params, &nparams, 0) != 0) {
vshError(ctl, "%s", _("Unable to get memory stats"));
goto cleanup;
return false;
}
for (i = 0; i < nparams; i++)
vshPrint(ctl, "%-7s: %20llu KiB\n", params[i].field, params[i].value);
ret = true;
cleanup:
return ret;
return true;
}
/*

View File

@ -122,11 +122,11 @@ vshFindNodeDevice(vshControl *ctl, const char *value)
narr = vshStringToArray(value, &arr);
if (narr != 2) {
vshError(ctl, _("Malformed device value '%s'"), value);
goto cleanup;
return NULL;
}
if (!virValidateWWN(arr[0]) || !virValidateWWN(arr[1]))
goto cleanup;
return NULL;
dev = virNodeDeviceLookupSCSIHostByWWN(priv->conn, arr[0], arr[1], 0);
} else {
@ -135,10 +135,9 @@ vshFindNodeDevice(vshControl *ctl, const char *value)
if (!dev) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), value);
goto cleanup;
return NULL;
}
cleanup:
return dev;
}

View File

@ -529,17 +529,16 @@ virshMakeCloneXML(const char *origxml, const char *newname)
doc = virXMLParseStringCtxt(origxml, _("(volume_definition)"), &ctxt);
if (!doc)
goto cleanup;
return NULL;
obj = xmlXPathEval(BAD_CAST "/volume/name", ctxt);
if (obj == NULL || obj->nodesetval == NULL ||
obj->nodesetval->nodeTab == NULL)
goto cleanup;
return NULL;
xmlNodeSetContent(obj->nodesetval->nodeTab[0], (const xmlChar *)newname);
xmlDocDumpMemory(doc, &newxml, &size);
cleanup:
return newxml;
}

View File

@ -432,7 +432,6 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
bool report)
{
size_t i;
const vshCmdOptDef *ret = NULL;
g_autofree char *alias = NULL;
if (STREQ(name, helpopt.name))
@ -457,7 +456,7 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
if (report)
vshError(ctl, _("invalid '=' after option --%s"),
opt->name);
goto cleanup;
return NULL;
}
*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 (report)
vshError(ctl, _("option --%s already seen"), name);
goto cleanup;
return NULL;
}
*opts_seen |= 1ULL << i;
*opt_index = i;
ret = opt;
goto cleanup;
return opt;
}
}
@ -479,8 +477,7 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
vshError(ctl, _("command '%s' doesn't support option --%s"),
cmd->name, name);
}
cleanup:
return ret;
return NULL;
}
static const vshCmdOptDef *