lxc: Exit on first error in lxcDomainGetMemoryParameters

There is no point in trying to fill params beyond the first error,
because when lxcDomainGetMemoryParameters returns -1 then the caller
cannot detect which values in params are valid.
This commit is contained in:
Matthias Bolte 2010-11-06 18:52:00 +01:00
parent 9562ca3f92
commit c3697a0ed5

View File

@ -823,7 +823,6 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
goto cleanup;
}
ret = 0;
for (i = 0; i < *nparams; i++) {
virMemoryParameterPtr param = &params[i];
val = 0;
@ -836,14 +835,12 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
if (rc != 0) {
virReportSystemError(-rc, "%s",
_("unable to get memory hard limit"));
ret = -1;
continue;
goto cleanup;
}
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_HARD_LIMIT) == NULL) {
lxcError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Field memory hard limit too long for destination"));
ret = -1;
continue;
goto cleanup;
}
param->value.ul = val;
break;
@ -853,14 +850,12 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
if (rc != 0) {
virReportSystemError(-rc, "%s",
_("unable to get memory soft limit"));
ret = -1;
continue;
goto cleanup;
}
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SOFT_LIMIT) == NULL) {
lxcError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Field memory soft limit too long for destination"));
ret = -1;
continue;
goto cleanup;
}
param->value.ul = val;
break;
@ -870,14 +865,12 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
if (rc != 0) {
virReportSystemError(-rc, "%s",
_("unable to get swap hard limit"));
ret = -1;
continue;
goto cleanup;
}
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT) == NULL) {
lxcError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Field swap hard limit too long for destination"));
ret = -1;
continue;
goto cleanup;
}
param->value.ul = val;
break;
@ -888,6 +881,8 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
}
}
ret = 0;
cleanup:
if (cgroup)
virCgroupFree(&cgroup);