From 6ae8af2cb18a21a01852fb3324047b6a3800d6ce Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 9 Apr 2011 13:21:24 +0200 Subject: [PATCH] kvm tools: Fix 64-bit assumptions and type uglinesses MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Make the MIN_RAM_SIZE_MB constant 64-bit on 32-bit systems as well, otherwise we get this build failure: kvm-run.c: In function ‘kvm_cmd_run’: kvm-run.c:119: error: format ‘%lu’ expects type ‘long unsigned int’, but argument 2 has type ‘u64’ Also adjust affected printf format string - this necessiates the use of the sane Linux definition of u64 instead of the brain-dead int64_t variant. That also allows (and necessiates) the removal of the ugly PRIu64 format string hackery. Friends don't let friends use PRI* hackeries! :-) Signed-off-by: Ingo Molnar Signed-off-by: Pekka Enberg --- tools/kvm/include/linux/types.h | 4 ++-- tools/kvm/kvm-run.c | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/kvm/include/linux/types.h b/tools/kvm/include/linux/types.h index b989d2a200ff..8b608e7a6e4a 100644 --- a/tools/kvm/include/linux/types.h +++ b/tools/kvm/include/linux/types.h @@ -12,8 +12,8 @@ #define __s32 int32_t #define __u32 uint32_t -#define __s64 int64_t -#define __u64 uint64_t +#define __s64 long long +#define __u64 unsigned long long typedef __u64 u64; typedef __s64 s64; diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c index 8a9747b8782a..dcb7fb812909 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -26,7 +26,7 @@ #define DEFAULT_KVM_DEV "/dev/kvm" #define MB_SHIFT (20) -#define MIN_RAM_SIZE_MB (64UL) +#define MIN_RAM_SIZE_MB (64ULL) #define MIN_RAM_SIZE_BYTE (MIN_RAM_SIZE_MB << MB_SHIFT) static struct kvm *kvm; @@ -117,10 +117,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) } - if (ram_size < MIN_RAM_SIZE_MB) { - die("Not enough memory specified: %luMB (min %luMB)", ram_size, - MIN_RAM_SIZE_MB); - } + if (ram_size < MIN_RAM_SIZE_MB) + die("Not enough memory specified: %lluMB (min %lluMB)", ram_size, MIN_RAM_SIZE_MB); + ram_size <<= MB_SHIFT; if (!kvm_dev) @@ -188,7 +187,7 @@ panic_kvm: cpu->kvm_run->exit_reason, kvm_exit_reasons[cpu->kvm_run->exit_reason]); if (cpu->kvm_run->exit_reason == KVM_EXIT_UNKNOWN) - fprintf(stderr, "KVM exit code: 0x%" PRIu64 "\n", + fprintf(stderr, "KVM exit code: 0x%Lu\n", cpu->kvm_run->hw.hardware_exit_reason); disk_image__close(kvm->disk_image); kvm_cpu__show_registers(cpu); -- 2.39.5