mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Set KMEMSIZE for OpenVZ domains being defined
* src/openvz/openvz_driver.c: add a new openvzDomainSetMemoryInternal() function, used to initialize the KMEMSIZE parameter of a container.
This commit is contained in:
parent
4ab7995871
commit
8001eef5d0
@ -68,7 +68,12 @@ static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid);
|
||||
static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type);
|
||||
static int openvzDomainGetMaxVcpus(virDomainPtr dom);
|
||||
static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus);
|
||||
static int openvzDomainSetVcpusInternal(virConnectPtr conn, virDomainObjPtr vm, unsigned int nvcpus);
|
||||
static int openvzDomainSetVcpusInternal(virConnectPtr conn,
|
||||
virDomainObjPtr vm,
|
||||
unsigned int nvcpus);
|
||||
static int openvzDomainSetMemoryInternal(virConnectPtr conn,
|
||||
virDomainObjPtr vm,
|
||||
unsigned long memory);
|
||||
|
||||
static void openvzDriverLock(struct openvz_driver *driver)
|
||||
{
|
||||
@ -804,6 +809,14 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
}
|
||||
}
|
||||
|
||||
if (vm->def->memory > 0) {
|
||||
if (openvzDomainSetMemoryInternal(conn, vm, vm->def->memory) < 0) {
|
||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("Could not set memory size"));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
|
||||
if (dom)
|
||||
dom->id = -1;
|
||||
@ -1359,6 +1372,31 @@ static int openvzNumDefinedDomains(virConnectPtr conn) {
|
||||
return n;
|
||||
}
|
||||
|
||||
static int
|
||||
openvzDomainSetMemoryInternal(virConnectPtr conn, virDomainObjPtr vm,
|
||||
unsigned long mem)
|
||||
{
|
||||
char str_mem[16];
|
||||
const char *prog[] = { VZCTL, "--quiet", "set", PROGRAM_SENTINAL,
|
||||
"--kmemsize", str_mem, "--save", NULL
|
||||
};
|
||||
|
||||
/* memory has to be changed its format from kbyte to byte */
|
||||
snprintf(str_mem, sizeof(str_mem), "%lu", mem * 1024);
|
||||
|
||||
openvzSetProgramSentinal(prog, vm->def->name);
|
||||
if (virRun(conn, prog, NULL) < 0) {
|
||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not exec %s"), VZCTL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static virDriver openvzDriver = {
|
||||
VIR_DRV_OPENVZ,
|
||||
"OPENVZ",
|
||||
|
Loading…
x
Reference in New Issue
Block a user