mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-29 20:11:16 +00:00
openvz: remove unneeded labels
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
29a760a97a
commit
049ddf57da
@ -858,18 +858,15 @@ openvzLocateConfDir(void)
|
|||||||
{
|
{
|
||||||
const char *conf_dir_list[] = {"/etc/vz/conf", "/usr/local/etc/conf", NULL};
|
const char *conf_dir_list[] = {"/etc/vz/conf", "/usr/local/etc/conf", NULL};
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
char *ret = NULL;
|
|
||||||
|
|
||||||
while (conf_dir_list[i]) {
|
while (conf_dir_list[i]) {
|
||||||
if (virFileExists(conf_dir_list[i])) {
|
if (virFileExists(conf_dir_list[i]))
|
||||||
ret = g_strdup(conf_dir_list[i]);
|
return g_strdup(conf_dir_list[i]);
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
return NULL;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Richard Steven's classic readline() function */
|
/* Richard Steven's classic readline() function */
|
||||||
|
@ -1554,12 +1554,9 @@ openvzDomainSetMemoryInternal(virDomainObjPtr vm,
|
|||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (virRun(prog, NULL) < 0)
|
if (virRun(prog, NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1641,7 +1638,6 @@ openvzDomainGetMemoryParameters(virDomainPtr domain,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
int result = -1;
|
|
||||||
const char *name;
|
const char *name;
|
||||||
long kb_per_pages;
|
long kb_per_pages;
|
||||||
unsigned long long barrier, limit, val;
|
unsigned long long barrier, limit, val;
|
||||||
@ -1650,7 +1646,7 @@ openvzDomainGetMemoryParameters(virDomainPtr domain,
|
|||||||
|
|
||||||
kb_per_pages = openvzKBPerPages();
|
kb_per_pages = openvzKBPerPages();
|
||||||
if (kb_per_pages < 0)
|
if (kb_per_pages < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (*nparams == 0) {
|
if (*nparams == 0) {
|
||||||
*nparams = OPENVZ_NB_MEM_PARAM;
|
*nparams = OPENVZ_NB_MEM_PARAM;
|
||||||
@ -1664,44 +1660,42 @@ openvzDomainGetMemoryParameters(virDomainPtr domain,
|
|||||||
case 0:
|
case 0:
|
||||||
name = "privvmpages";
|
name = "privvmpages";
|
||||||
if (openvzDomainGetBarrierLimit(domain, name, &barrier, &limit) < 0)
|
if (openvzDomainGetBarrierLimit(domain, name, &barrier, &limit) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
val = (limit == LONG_MAX) ? VIR_DOMAIN_MEMORY_PARAM_UNLIMITED : limit * kb_per_pages;
|
val = (limit == LONG_MAX) ? VIR_DOMAIN_MEMORY_PARAM_UNLIMITED : limit * kb_per_pages;
|
||||||
if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_HARD_LIMIT,
|
if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_HARD_LIMIT,
|
||||||
VIR_TYPED_PARAM_ULLONG, val) < 0)
|
VIR_TYPED_PARAM_ULLONG, val) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
name = "privvmpages";
|
name = "privvmpages";
|
||||||
if (openvzDomainGetBarrierLimit(domain, name, &barrier, &limit) < 0)
|
if (openvzDomainGetBarrierLimit(domain, name, &barrier, &limit) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
val = (barrier == LONG_MAX) ? VIR_DOMAIN_MEMORY_PARAM_UNLIMITED : barrier * kb_per_pages;
|
val = (barrier == LONG_MAX) ? VIR_DOMAIN_MEMORY_PARAM_UNLIMITED : barrier * kb_per_pages;
|
||||||
if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_SOFT_LIMIT,
|
if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_SOFT_LIMIT,
|
||||||
VIR_TYPED_PARAM_ULLONG, val) < 0)
|
VIR_TYPED_PARAM_ULLONG, val) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
name = "vmguarpages";
|
name = "vmguarpages";
|
||||||
if (openvzDomainGetBarrierLimit(domain, name, &barrier, &limit) < 0)
|
if (openvzDomainGetBarrierLimit(domain, name, &barrier, &limit) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
val = (barrier == LONG_MAX) ? 0ull : barrier * kb_per_pages;
|
val = (barrier == LONG_MAX) ? 0ull : barrier * kb_per_pages;
|
||||||
if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_MIN_GUARANTEE,
|
if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_MIN_GUARANTEE,
|
||||||
VIR_TYPED_PARAM_ULLONG, val) < 0)
|
VIR_TYPED_PARAM_ULLONG, val) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*nparams > OPENVZ_NB_MEM_PARAM)
|
if (*nparams > OPENVZ_NB_MEM_PARAM)
|
||||||
*nparams = OPENVZ_NB_MEM_PARAM;
|
*nparams = OPENVZ_NB_MEM_PARAM;
|
||||||
result = 0;
|
|
||||||
|
|
||||||
cleanup:
|
return 0;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1712,12 +1706,11 @@ openvzDomainSetMemoryParameters(virDomainPtr domain,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
int result = -1;
|
|
||||||
long kb_per_pages;
|
long kb_per_pages;
|
||||||
|
|
||||||
kb_per_pages = openvzKBPerPages();
|
kb_per_pages = openvzKBPerPages();
|
||||||
if (kb_per_pages < 0)
|
if (kb_per_pages < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
if (virTypedParamsValidate(params, nparams,
|
if (virTypedParamsValidate(params, nparams,
|
||||||
@ -1737,29 +1730,28 @@ openvzDomainSetMemoryParameters(virDomainPtr domain,
|
|||||||
if (STREQ(param->field, VIR_DOMAIN_MEMORY_HARD_LIMIT)) {
|
if (STREQ(param->field, VIR_DOMAIN_MEMORY_HARD_LIMIT)) {
|
||||||
if (openvzDomainGetBarrierLimit(domain, "privvmpages",
|
if (openvzDomainGetBarrierLimit(domain, "privvmpages",
|
||||||
&barrier, &limit) < 0)
|
&barrier, &limit) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
limit = params[i].value.ul / kb_per_pages;
|
limit = params[i].value.ul / kb_per_pages;
|
||||||
if (openvzDomainSetBarrierLimit(domain, "privvmpages",
|
if (openvzDomainSetBarrierLimit(domain, "privvmpages",
|
||||||
barrier, limit) < 0)
|
barrier, limit) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else if (STREQ(param->field, VIR_DOMAIN_MEMORY_SOFT_LIMIT)) {
|
} else if (STREQ(param->field, VIR_DOMAIN_MEMORY_SOFT_LIMIT)) {
|
||||||
if (openvzDomainGetBarrierLimit(domain, "privvmpages",
|
if (openvzDomainGetBarrierLimit(domain, "privvmpages",
|
||||||
&barrier, &limit) < 0)
|
&barrier, &limit) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
barrier = params[i].value.ul / kb_per_pages;
|
barrier = params[i].value.ul / kb_per_pages;
|
||||||
if (openvzDomainSetBarrierLimit(domain, "privvmpages",
|
if (openvzDomainSetBarrierLimit(domain, "privvmpages",
|
||||||
barrier, limit) < 0)
|
barrier, limit) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else if (STREQ(param->field, VIR_DOMAIN_MEMORY_MIN_GUARANTEE)) {
|
} else if (STREQ(param->field, VIR_DOMAIN_MEMORY_MIN_GUARANTEE)) {
|
||||||
barrier = params[i].value.ul / kb_per_pages;
|
barrier = params[i].value.ul / kb_per_pages;
|
||||||
if (openvzDomainSetBarrierLimit(domain, "vmguarpages",
|
if (openvzDomainSetBarrierLimit(domain, "vmguarpages",
|
||||||
barrier, LONG_MAX) < 0)
|
barrier, LONG_MAX) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = 0;
|
|
||||||
cleanup:
|
return 0;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user