[libvirt] [PATCH] memtune: Let virsh know the unlimited value for memory tunables
Eric Blake
eblake at redhat.com
Tue Jan 11 15:19:30 UTC 2011
On 01/10/2011 10:18 PM, Nikunj A. Dadhania wrote:
> Display unlimited when the memory cgroup settings says so. Unlimited is
> represented by INT64_MAX in memory cgroup.
>
> Signed-off-by: Nikunj A. Dadhania <nikunj at linux.vnet.ibm.com>
> Reported-by: Justin Clift <jclift at redhat.com>
> ---
> include/libvirt/libvirt.h.in | 1 +
> src/lxc/lxc_driver.c | 2 +-
> src/qemu/qemu_driver.c | 2 +-
> src/util/cgroup.c | 27 +++++++++++++++++++++------
> src/util/cgroup.h | 6 +++---
> tools/virsh.c | 9 +++++++--
> 6 files changed, 34 insertions(+), 13 deletions(-)
>
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 3c6a54a..cb53f6b 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -696,6 +696,7 @@ typedef enum {
> */
>
> #define VIR_DOMAIN_MEMORY_FIELD_LENGTH 80
> +#define VIR_DOMAIN_MEMORY_PARAM_UNLIMITED (UINT64_MAX)
() aren't strictly necessary here, but don't hurt, either.
> @@ -907,7 +907,7 @@ int virCgroupSetMemoryHardLimit(virCgroupPtr group, unsigned long kb)
> *
> * Returns: 0 on success
> */
> -int virCgroupGetMemoryHardLimit(virCgroupPtr group, unsigned long *kb)
> +int virCgroupGetMemoryHardLimit(virCgroupPtr group, unsigned long long *kb)
So why is Get changed to ull, but Set remains with just unsigned long?
This patch is still incomplete. I think you need to touch both
functions, and also virCgroupSetMemory. Also, in virCgroupSetMemory,
you need to check for overflow, and fail if someone requests an
impossible amount of kb.
> {
> long long unsigned int limit_in_bytes;
> int ret;
> @@ -915,7 +915,12 @@ int virCgroupGetMemoryHardLimit(virCgroupPtr group, unsigned long *kb)
> VIR_CGROUP_CONTROLLER_MEMORY,
> "memory.limit_in_bytes", &limit_in_bytes);
> if (ret == 0)
> - *kb = (unsigned long) limit_in_bytes >> 10;
> + {
> + if (limit_in_bytes != INT64_MAX)
> + *kb = (unsigned long long) limit_in_bytes >> 10;
This cast is not necessary, since limit_in_bytes is already ull.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110111/5ec84dee/attachment-0001.sig>
More information about the libvir-list
mailing list