On 04/26/2012 05:16 AM, Guido Günther wrote: > --- > This is a reworked version of the patch already sent, now adding > handling for "unlimited" (represented by LONG_MAX in openvz) as well as > a schema testcase. I also switched all value to unsigned long long to > avoid overflows. > Note that privvmpages is the amount of memory available to the > application. The total memory usage of the container might be higher due > to used kernel memory. This does probably warrant an extra tunable > later. O.k. to apply? > Cheers, > -- Guido > > > +static int > +openvzReadMemConf(virDomainDefPtr def, int veid) > +{ > + int ret; > + char *temp = NULL; > + unsigned long long barrier, limit; > + const char *param; > + unsigned long kb_per_pages; > + > + kb_per_pages = sysconf(_SC_PAGESIZE) / 1024; In general, you should be prepared for sysconf() to fail... > + if (kb_per_pages == -1) { but you already divided by 1024, so failure will no longer show as -1 at this point. > + > + if (sscanf(output, "%llu %llu", barrier, limit) != 2) { sscanf() can't detect overflow. I'd rather use virStrToLong_ull() for safety. > + > +static int > +openvzDomainGetMemoryParameters(virDomainPtr domain, > + virTypedParameterPtr params, > + int *nparams, > + unsigned int flags) > +{ > + int i, result = -1; > + const char *name; > + long kb_per_pages; > + unsigned long long barrier, limit, val; > + > + virCheckFlags(0, -1); > + > + kb_per_pages = sysconf(_SC_PAGESIZE) / 1024; > + if (kb_per_pages == -1) { Oops, another inability to detect failure. > + > +static int > +openvzDomainSetMemoryParameters(virDomainPtr domain, > + virTypedParameterPtr params, > + int nparams, > + unsigned int flags) > +{ > + int i, result = -1; > + long kb_per_pages; > + > + kb_per_pages = sysconf(_SC_PAGESIZE) / 1024; > + if (kb_per_pages == -1) { And again. But the bulk of this patch looks reasonable. Would you mind respinning a v2 to address the nits, and we can probably get this in 0.9.12 even if it misses rc1. -- Eric Blake eblake@xxxxxxxxxx +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list