unsigned long long bytes = 0;
unsigned long long max;
unsigned long kibibytes = 0;
- bool ret = true;
+ bool ret = false;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool current = vshCommandOptBool(cmd, "current");
max = 1024ull * ULONG_MAX;
else
max = ULONG_MAX;
- if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) {
- virshDomainFree(dom);
- return false;
- }
+ if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0)
+ goto cleanup;
kibibytes = VIR_DIV_UP(bytes, 1024);
if (!current && !live && !config) {
if (virDomainSetMemory(dom, kibibytes) != 0)
- ret = false;
+ goto cleanup;
} else {
if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0)
- ret = false;
+ goto cleanup;
}
+ ret = true;
+ cleanup:
virshDomainFree(dom);
return ret;
}
unsigned long long bytes = 0;
unsigned long long max;
unsigned long kibibytes = 0;
- bool ret = true;
+ bool ret = false;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool current = vshCommandOptBool(cmd, "current");
max = 1024ull * ULONG_MAX;
else
max = ULONG_MAX;
- if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) {
- virshDomainFree(dom);
- return false;
- }
+ if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0)
+ goto cleanup;
kibibytes = VIR_DIV_UP(bytes, 1024);
if (flags == 0) {
if (virDomainSetMaxMemory(dom, kibibytes) != 0) {
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
- ret = false;
+ goto cleanup;
}
} else {
if (virDomainSetMemoryFlags(dom, kibibytes, flags | VIR_DOMAIN_MEM_MAXIMUM) < 0) {
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
- ret = false;
+ goto cleanup;
}
}
+ ret = true;
+ cleanup:
virshDomainFree(dom);
return ret;
}