
On Tue, Oct 27, 2009 at 04:12:47PM +0900, Yuji NISHIDA wrote:
Hi all,
This patch is to set KMEMSIZE for OpenVZ. This function is used for initializing the parameter of KMEMSIZE to start container. openvzDomainSetMemory should be left for another purpose so I added new one.
I think users should specify memory as kbyte ( or bigger ).
That's the definition all entry points for memory use KB as the unit. so that's what you get in the driver and XML format files.
--- src/openvz/openvz_driver.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-)
Your mail agent made garbage (nearly) of the patch, in the future please provide your patches as attachement.
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index f64ad1e..5c1fefa 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -69,6 +69,7 @@ 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 openvzDomainSetMemoryInternal(virConnectPtr conn, virDomainObjPtr vm, unsigned long memory);
static void openvzDriverLock(struct openvz_driver *driver) { @@ -803,6 +804,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; @@ -1364,6 +1373,29 @@ static int openvzNumDefinedDomains(virConnectPtr conn) { return ninactive; }
+static int openvzDomainSetMemoryInternal(virConnectPtr conn, virDomainObjPtr vm, + unsigned long mem) { + struct openvz_driver *driver = conn->privateData;
That variable is unused. Compiling the code show the warning. How did you miss this ?
+ 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",
That said the patch looks sensible to me, I applied it by hand, cleaned up the formatting, and removed the unused variable. thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/