From patchwork Sat Apr 9 11:21:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ingo Molnar X-Patchwork-Id: 695831 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p39BLi0q017046 for ; Sat, 9 Apr 2011 11:21:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754309Ab1DILVe (ORCPT ); Sat, 9 Apr 2011 07:21:34 -0400 Received: from mx3.mail.elte.hu ([157.181.1.138]:34190 "EHLO mx3.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754259Ab1DILVe (ORCPT ); Sat, 9 Apr 2011 07:21:34 -0400 Received: from elvis.elte.hu ([157.181.1.14]) by mx3.mail.elte.hu with esmtp (Exim) id 1Q8WEJ-00071I-7l from ; Sat, 09 Apr 2011 13:21:32 +0200 Received: by elvis.elte.hu (Postfix, from userid 1004) id 9A8DA3E2378; Sat, 9 Apr 2011 13:21:25 +0200 (CEST) Date: Sat, 9 Apr 2011 13:21:24 +0200 From: Ingo Molnar To: Pekka Enberg Cc: KVM devel mailing list Subject: [PATCH] kvm tools: Fix 64-bit assumptions and type uglinesses Message-ID: <20110409112124.GA15296@elte.hu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) Received-SPF: neutral (mx3: 157.181.1.14 is neither permitted nor denied by domain of elte.hu) client-ip=157.181.1.14; envelope-from=mingo@elte.hu; helo=elvis.elte.hu; X-ELTE-SpamScore: -2.0 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-2.0 required=5.9 tests=BAYES_00 autolearn=no SpamAssassin version=3.3.1 -2.0 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 09 Apr 2011 11:21:45 +0000 (UTC) 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 --- tools/kvm/include/linux/types.h | 4 ++-- tools/kvm/kvm-run.c | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tools/kvm/include/linux/types.h b/tools/kvm/include/linux/types.h index b989d2a..8b608e7 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 9b0786a..5697d82 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -25,7 +25,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; @@ -114,10 +114,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) @@ -230,7 +229,7 @@ panic_kvm: kvm->kvm_run->exit_reason, kvm_exit_reasons[kvm->kvm_run->exit_reason]); if (kvm->kvm_run->exit_reason == KVM_EXIT_UNKNOWN) - fprintf(stderr, "KVM exit code: 0x%" PRIu64 "\n", + fprintf(stderr, "KVM exit code: 0x%Lu\n", kvm->kvm_run->hw.hardware_exit_reason); disk_image__close(kvm->disk_image); kvm__show_registers(kvm);