From 1a9a01959bd5f2425ddc5239d5625dfbb3f63aac Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Thu, 16 Jun 2011 17:04:31 +0300 Subject: [PATCH] kvm tools: Fix 'kvm run' on 32-bit machines with >2 GB of RAM This patch fixes the following nasty 'kvm run' startup problem that's caused by 'long' and 'u64' mixup in the code: $ ./kvm run Fatal: out of memory Signed-off-by: Pekka Enberg --- tools/kvm/include/kvm/kvm.h | 2 +- tools/kvm/kvm-run.c | 4 ++-- tools/kvm/kvm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index 4eeed87f2787..7d90d356e3e0 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -43,7 +43,7 @@ struct kvm { int nr_disks; }; -struct kvm *kvm__init(const char *kvm_dev, unsigned long ram_size); +struct kvm *kvm__init(const char *kvm_dev, u64 ram_size); int kvm__max_cpus(struct kvm *kvm); void kvm__init_ram(struct kvm *kvm); void kvm__delete(struct kvm *kvm); diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c index f121a2b81756..6ad55aa1d83c 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -324,8 +324,8 @@ static u64 host_ram_size(void) static u64 get_ram_size(int nr_cpus) { - long available; - long ram_size; + u64 available; + u64 ram_size; ram_size = 64 * (nr_cpus + 3); diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index 2c56a7928033..8874cf9192b8 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -236,7 +236,7 @@ int kvm__max_cpus(struct kvm *kvm) return ret; } -struct kvm *kvm__init(const char *kvm_dev, unsigned long ram_size) +struct kvm *kvm__init(const char *kvm_dev, u64 ram_size) { struct kvm_pit_config pit_config = { .flags = 0, }; struct kvm *kvm; -- 2.39.5