const char *path = NULL;
unsigned long long size = 0;
unsigned int flags = 0;
- bool ret = false;
if (vshCommandOptStringReq(ctl, cmd, "path", (const char **) &path) < 0)
return false;
if (virDomainBlockResize(dom, path, size, flags) < 0) {
vshError(ctl, _("Failed to resize block device '%s'"), path);
- } else {
- vshPrintExtra(ctl, _("Block device '%s' is resized"), path);
- ret = true;
+ return false;
}
- return ret;
+ vshPrintExtra(ctl, _("Block device '%s' is resized"), path);
+ return true;
}
#ifndef WIN32
{
g_autoptr(virshDomain) dom = NULL;
const char *name;
- bool ret = true;
if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
return false;
- if (virDomainSuspend(dom) == 0) {
- vshPrintExtra(ctl, _("Domain '%s' suspended\n"), name);
- } else {
+ if (virDomainSuspend(dom) != 0) {
vshError(ctl, _("Failed to suspend domain '%s'"), name);
- ret = false;
+ return false;
}
- return ret;
+ vshPrintExtra(ctl, _("Domain '%s' suspended\n"), name);
+ return true;
}
/*
cmdResume(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshDomain) dom = NULL;
- bool ret = true;
const char *name;
if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
return false;
- if (virDomainResume(dom) == 0) {
- vshPrintExtra(ctl, _("Domain '%s' resumed\n"), name);
- } else {
+ if (virDomainResume(dom) != 0) {
vshError(ctl, _("Failed to resume domain '%s'"), name);
- ret = false;
+ return false;
}
- return ret;
+ vshPrintExtra(ctl, _("Domain '%s' resumed\n"), name);
+ return true;
}
/*
cmdReset(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshDomain) dom = NULL;
- bool ret = true;
const char *name;
if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
return false;
- if (virDomainReset(dom, 0) == 0) {
- vshPrintExtra(ctl, _("Domain '%s' was reset\n"), name);
- } else {
+ if (virDomainReset(dom, 0) != 0) {
vshError(ctl, _("Failed to reset domain '%s'"), name);
- ret = false;
+ return false;
}
- return ret;
+ vshPrintExtra(ctl, _("Domain '%s' was reset\n"), name);
+ return true;
}
/*
{
g_autoptr(virshDomain) dom = NULL;
const char *from = NULL;
- bool ret = true;
char *buffer;
unsigned int flags = 0;
virshControl *priv = ctl->privData;
dom = virDomainDefineXML(priv->conn, buffer);
VIR_FREE(buffer);
- if (dom != NULL) {
- vshPrintExtra(ctl, _("Domain '%s' defined from %s\n"),
- virDomainGetName(dom), from);
- } else {
+ if (!dom) {
vshError(ctl, _("Failed to define domain from %s"), from);
- ret = false;
+ return false;
}
- return ret;
+
+ vshPrintExtra(ctl, _("Domain '%s' defined from %s\n"),
+ virDomainGetName(dom), from);
+ return true;
}
/*
cmdDestroy(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshDomain) dom = NULL;
- bool ret = true;
const char *name;
unsigned int flags = 0;
int result;
else
result = virDomainDestroy(dom);
- if (result == 0) {
- vshPrintExtra(ctl, _("Domain '%s' destroyed\n"), name);
- } else {
+ if (result < 0) {
vshError(ctl, _("Failed to destroy domain '%s'"), name);
- ret = false;
+ return false;
}
- return ret;
+ vshPrintExtra(ctl, _("Domain '%s' destroyed\n"), name);
+ return true;
}
/*
cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshDomain) dom = NULL;
- bool ret = true;
g_autofree char *dump = NULL;
unsigned int flags = 0;
bool inactive = vshCommandOptBool(cmd, "inactive");
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
- dump = virDomainGetXMLDesc(dom, flags);
- if (dump != NULL) {
- vshPrint(ctl, "%s", dump);
- } else {
- ret = false;
- }
+ if (!(dump = virDomainGetXMLDesc(dom, flags)))
+ return false;
- return ret;
+ vshPrint(ctl, "%s", dump);
+ return true;
}
/*
static bool
cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
{
- bool ret = true;
const char *format = NULL;
const char *configFile = NULL;
g_autofree char *configData = NULL;
return false;
xmlData = virConnectDomainXMLFromNative(priv->conn, format, configData, flags);
- if (xmlData != NULL) {
- vshPrint(ctl, "%s", xmlData);
- } else {
- ret = false;
- }
+ if (!xmlData)
+ return false;
- return ret;
+ vshPrint(ctl, "%s", xmlData);
+ return true;
}
/*