kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Evans <matt@ozlabs.org>
To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Subject: [PATCH 05/28] kvm tools: 64-bit tidy; use PRIx64 when printf'ing u64s and link appropriately
Date: Tue, 06 Dec 2011 14:38:53 +1100	[thread overview]
Message-ID: <4EDD8E4D.5000309@ozlabs.org> (raw)
In-Reply-To: <cover.1323141075.git.matt@ozlabs.org>

On LP64 systems our u64s are just longs; remove the %llx'es in favour of PRIx64
etc.

This patch also adds CFLAGS to the final link, so that any -m64 is obeyed when
linking, too.

Signed-off-by: Matt Evans <matt@ozlabs.org>
---
 tools/kvm/Makefile       |    2 +-
 tools/kvm/builtin-run.c  |   14 ++++++++------
 tools/kvm/builtin-stat.c |    4 +++-
 tools/kvm/disk/core.c    |    4 +++-
 tools/kvm/mmio.c         |    4 +++-
 5 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile
index 009a6ba..57dc521 100644
--- a/tools/kvm/Makefile
+++ b/tools/kvm/Makefile
@@ -218,7 +218,7 @@ KVMTOOLS-VERSION-FILE:
 
 $(PROGRAM): $(DEPS) $(OBJS)
 	$(E) "  LINK    " $@
-	$(Q) $(CC) $(OBJS) $(LIBS) -o $@
+	$(Q) $(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $@
 
 $(GUEST_INIT): guest/init.c
 	$(E) "  LINK    " $@
diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index e4aa87e..7cf208d 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -42,6 +42,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
 #include <ctype.h>
 #include <stdio.h>
 
@@ -383,8 +385,8 @@ static int shmem_parser(const struct option *opt, const char *arg, int unset)
 		strcpy(handle, default_handle);
 	}
 	if (verbose) {
-		pr_info("shmem: phys_addr = %llx", phys_addr);
-		pr_info("shmem: size      = %llx", size);
+		pr_info("shmem: phys_addr = %"PRIx64, phys_addr);
+		pr_info("shmem: size      = %"PRIx64, size);
 		pr_info("shmem: handle    = %s", handle);
 		pr_info("shmem: create    = %d", create);
 	}
@@ -545,7 +547,7 @@ panic_kvm:
 		current_kvm_cpu->kvm_run->exit_reason,
 		kvm_exit_reasons[current_kvm_cpu->kvm_run->exit_reason]);
 	if (current_kvm_cpu->kvm_run->exit_reason == KVM_EXIT_UNKNOWN)
-		fprintf(stderr, "KVM exit code: 0x%Lu\n",
+		fprintf(stderr, "KVM exit code: 0x%"PRIx64"\n",
 			current_kvm_cpu->kvm_run->hw.hardware_exit_reason);
 
 	kvm_cpu__set_debug_fd(STDOUT_FILENO);
@@ -760,10 +762,10 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 		ram_size	= get_ram_size(nrcpus);
 
 	if (ram_size < MIN_RAM_SIZE_MB)
-		die("Not enough memory specified: %lluMB (min %lluMB)", ram_size, MIN_RAM_SIZE_MB);
+		die("Not enough memory specified: %"PRIu64"MB (min %lluMB)", ram_size, MIN_RAM_SIZE_MB);
 
 	if (ram_size > host_ram_size())
-		pr_warning("Guest memory size %lluMB exceeds host physical RAM size %lluMB", ram_size, host_ram_size());
+		pr_warning("Guest memory size %"PRIu64"MB exceeds host physical RAM size %"PRIu64"MB", ram_size, host_ram_size());
 
 	ram_size <<= MB_SHIFT;
 
@@ -878,7 +880,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 		virtio_blk__init_all(kvm);
 	}
 
-	printf("  # kvm run -k %s -m %Lu -c %d --name %s\n", kernel_filename, ram_size / 1024 / 1024, nrcpus, guest_name);
+	printf("  # kvm run -k %s -m %"PRId64" -c %d --name %s\n", kernel_filename, ram_size / 1024 / 1024, nrcpus, guest_name);
 
 	if (!kvm__load_kernel(kvm, kernel_filename, initrd_filename,
 				real_cmdline, vidmode))
diff --git a/tools/kvm/builtin-stat.c b/tools/kvm/builtin-stat.c
index e28eb5b..c1f2605 100644
--- a/tools/kvm/builtin-stat.c
+++ b/tools/kvm/builtin-stat.c
@@ -9,6 +9,8 @@
 #include <stdio.h>
 #include <string.h>
 #include <signal.h>
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
 
 #include <linux/virtio_balloon.h>
 
@@ -97,7 +99,7 @@ static int do_memstat(const char *name, int sock)
 			printf("The total amount of memory available (in bytes):");
 			break;
 		}
-		printf("%llu\n", stats[i].val);
+		printf("%"PRId64"\n", stats[i].val);
 	}
 	printf("\n");
 
diff --git a/tools/kvm/disk/core.c b/tools/kvm/disk/core.c
index 4915efd..a135851 100644
--- a/tools/kvm/disk/core.c
+++ b/tools/kvm/disk/core.c
@@ -4,6 +4,8 @@
 
 #include <sys/eventfd.h>
 #include <sys/poll.h>
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
 
 #define AIO_MAX 32
 
@@ -232,7 +234,7 @@ ssize_t disk_image__get_serial(struct disk_image *disk, void *buffer, ssize_t *l
 	if (fstat(disk->fd, &st) != 0)
 		return 0;
 
-	*len = snprintf(buffer, *len, "%llu%llu%llu", (u64)st.st_dev, (u64)st.st_rdev, (u64)st.st_ino);
+	*len = snprintf(buffer, *len, "%"PRId64"%"PRId64"%"PRId64, (u64)st.st_dev, (u64)st.st_rdev, (u64)st.st_ino);
 	return *len;
 }
 
diff --git a/tools/kvm/mmio.c b/tools/kvm/mmio.c
index de7320f..1158bff 100644
--- a/tools/kvm/mmio.c
+++ b/tools/kvm/mmio.c
@@ -9,6 +9,8 @@
 #include <linux/kvm.h>
 #include <linux/types.h>
 #include <linux/rbtree.h>
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
 
 #define mmio_node(n) rb_entry(n, struct mmio_mapping, node)
 
@@ -124,7 +126,7 @@ bool kvm__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len, u8 is_
 	if (mmio)
 		mmio->mmio_fn(phys_addr, data, len, is_write, mmio->ptr);
 	else
-		fprintf(stderr, "Warning: Ignoring MMIO %s at %016llx (length %u)\n",
+		fprintf(stderr, "Warning: Ignoring MMIO %s at %016"PRIx64" (length %u)\n",
 			to_direction(is_write), phys_addr, len);
 	br_read_unlock();
 

  parent reply	other threads:[~2011-12-06  3:38 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1323141075.git.matt@ozlabs.org>
2011-12-06  3:37 ` [PATCH 01/28] kvm tools: Split x86 arch-specific bits into x86/ Matt Evans
2011-12-06  8:07   ` Sasha Levin
2011-12-06 10:10     ` Pekka Enberg
2011-12-06  3:37 ` [PATCH 02/28] kvm tools: Only build/init i8042 on x86 Matt Evans
2011-12-06  8:11   ` Sasha Levin
2011-12-06 18:59   ` Scott Wood
2011-12-07  7:39     ` Matt Evans
2011-12-06  3:37 ` [PATCH 03/28] kvm tools: Add Makefile parameter for kernel include path Matt Evans
2011-12-06  3:38 ` [PATCH 04/28] kvm tools: Re-arrange Makefile to heed CFLAGS before checking for optional libs Matt Evans
2011-12-06  3:38 ` Matt Evans [this message]
2011-12-06  8:13   ` [PATCH 05/28] kvm tools: 64-bit tidy; use PRIx64 when printf'ing u64s and link appropriately Sasha Levin
2011-12-06  8:28     ` Ingo Molnar
2011-12-06 10:05       ` Paul Mackerras
2011-12-06 10:24         ` Ingo Molnar
2011-12-07  7:01           ` Matt Evans
2011-12-07  8:16             ` Ingo Molnar
2011-12-07 12:49               ` Paolo Bonzini
2011-12-07 17:21                 ` Pekka Enberg
2011-12-07 17:14               ` Pekka Enberg
2011-12-08  3:14                 ` Matt Evans
2011-12-08  4:49                   ` Ingo Molnar
2011-12-08  4:56                     ` Matt Evans
2011-12-08  5:47                       ` Matt Evans
2011-12-08  5:49                         ` Ingo Molnar
2011-12-08  6:17                           ` Matt Evans
2011-12-06  3:39 ` [PATCH 06/28] kvm tools: Add arch-specific KVM_RUN exit handling via kvm_cpu__handle_exit() Matt Evans
2011-12-06  3:39 ` [PATCH 07/28] kvm tools: Move 'kvm__recommended_cpus' to arch-specific code Matt Evans
2011-12-06  8:20   ` Sasha Levin
2011-12-07  6:17     ` Matt Evans
2011-12-07  6:34       ` Sasha Levin
2011-12-07  7:19         ` Matt Evans
2011-12-07  7:24           ` Alexander Graf
2011-12-07  7:28             ` Matt Evans
2011-12-07  8:29               ` Sasha Levin
2011-12-07 14:11                 ` Avi Kivity
2011-12-07 14:22                   ` Sasha Levin
2011-12-07 14:25                     ` Avi Kivity
2011-12-07 15:00                       ` Alexander Graf
2011-12-07 15:25                         ` Sasha Levin
2011-12-07 15:58                           ` Alexander Graf
2011-12-20 15:23                 ` Alexander Graf
2011-12-21 22:17                   ` Paul Mackerras
2011-12-23 14:05                     ` Alexander Graf
2011-12-20 15:20           ` Alexander Graf
2011-12-06  3:39 ` [PATCH 08/28] kvm tools: Fix KVM_RUN exit code check Matt Evans
2011-12-06  8:22   ` Sasha Levin
2011-12-07  0:32     ` Matt Evans
2011-12-07  6:44       ` Alexander Graf
2011-12-07 14:12         ` Avi Kivity
2011-12-07 15:01           ` Alexander Graf
2011-12-07 15:05             ` Avi Kivity
2011-12-08  3:03     ` Matt Evans
2011-12-08  5:31       ` Sasha Levin
2011-12-22 10:03         ` Avi Kivity
2011-12-22 10:18           ` Sasha Levin
2011-12-22 10:21             ` Avi Kivity
2011-12-22 10:34               ` Sasha Levin
2011-12-06  3:39 ` [PATCH 09/28] kvm tools: Add kvm__arch_periodic_poll() Matt Evans
2011-12-06  3:40 ` [PATCH 10/28] kvm tools: term.h needs to include stdbool.h Matt Evans
2011-12-06  3:40 ` [PATCH 11/28] kvm tools: kvm.c needs to include sys/stat.h for mkdir Matt Evans
2011-12-06  3:40 ` [PATCH 12/28] kvm tools: Move arch-specific cmdline init into kvm__arch_set_cmdline() Matt Evans
2011-12-06  3:40 ` [PATCH 13/28] kvm tools: Add CONSOLE_HV term type and allow it to be selected Matt Evans
2011-12-06  3:40 ` [PATCH 14/28] kvm tools: Fix term_getc(), term_getc_iov() endian bugs Matt Evans
2011-12-06 10:24   ` Pekka Enberg
2011-12-06 12:00     ` Asias He
2011-12-07  2:39       ` Matt Evans
2011-12-06  3:40 ` [PATCH 15/28] kvm tools: Allow initrd_check() to match a cpio Matt Evans
2011-12-06 10:26   ` Pekka Enberg
2011-12-06  3:41 ` [PATCH 16/28] kvm tools: Allow load_flat_binary() to load an initrd alongside Matt Evans
2011-12-06 10:29   ` Pekka Enberg
2011-12-06 12:04     ` Cyrill Gorcunov
2011-12-07  0:42       ` Matt Evans
2011-12-07  6:33         ` Cyrill Gorcunov
2011-12-06  3:41 ` [PATCH 17/28] kvm tools: Only call symbol__init() if we have BFD Matt Evans
2011-12-06  8:26   ` Sasha Levin
2011-12-07  3:03     ` Matt Evans
2011-12-06  3:41 ` [PATCH 18/28] kvm tools: Initialise PCI before devices start getting registered with PCI Matt Evans
2011-12-06  3:41 ` [PATCH 19/28] kvm tools: Perform CPU and firmware setup after devices are added Matt Evans
2011-12-06  3:41 ` [PATCH 20/28] kvm tools: Init IRQs after determining nrcpus Matt Evans
2011-12-06  3:41 ` [PATCH 21/28] kvm tools: Add --hugetlbfs option to specify memory path Matt Evans
2011-12-06  8:32   ` Sasha Levin
2011-12-07  0:35     ` Matt Evans
2011-12-07  6:01       ` Sasha Levin
2011-12-06  3:42 ` [PATCH 22/28] kvm tools: Move PCI_MAX_DEVICES to pci.h Matt Evans
2011-12-06  3:42 ` [PATCH 23/28] kvm tools: Endian-sanitise pci.h and PCI device setup Matt Evans
2011-12-06 10:25   ` Pekka Enberg
2011-12-06 10:28     ` Cyrill Gorcunov
2011-12-06 11:41       ` Pekka Enberg
2011-12-06 11:47         ` Cyrill Gorcunov
2011-12-06 11:58           ` Pekka Enberg
2011-12-06 12:10             ` Cyrill Gorcunov
2011-12-06 13:29               ` Pekka Enberg
2011-12-06 13:38                 ` Cyrill Gorcunov
2011-12-07  2:58                   ` Matt Evans
2011-12-06  3:42 ` [PATCH 24/28] kvm tools: Fix virtio-pci endian bug when reading VIRTIO_PCI_QUEUE_NUM Matt Evans
2011-12-06 10:26   ` Pekka Enberg
2011-12-06 11:28     ` Asias He
2011-12-06 11:39       ` Pekka Enberg
2011-12-06 13:15     ` Sasha Levin
2011-12-06  3:42 ` [PATCH 25/28] kvm tools: Correctly set virtio-pci bar_size and remove hardwired address Matt Evans
2011-12-06  3:42 ` [PATCH 26/28] kvm tools: Add pci__config_{rd,wr}(), pci__find_dev() and fix PCI config register addressing Matt Evans
2011-12-06  3:43 ` [PATCH 27/28] kvm tools: Arch-specific define for PCI MMIO allocation area Matt Evans
2011-12-06  3:43 ` [PATCH 28/28] kvm tools: Create arch-specific kvm_cpu__emulate_io() Matt Evans
2011-12-06  8:54   ` Sasha Levin
2011-12-07  6:36     ` Matt Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EDD8E4D.5000309@ozlabs.org \
    --to=matt@ozlabs.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).