[PATCH 1/5] kvm tools: Abolishment of uint*_t types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Clean uint*_t type from the code.

Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
 tools/kvm/8250-serial.c            |   41 ++++++++++++-----------
 tools/kvm/bios/e820.c              |   16 +++++-----
 tools/kvm/disk-image.c             |   24 +++++++-------
 tools/kvm/include/kvm/cpufeature.h |    8 ++--
 tools/kvm/include/kvm/disk-image.h |   24 +++++++-------
 tools/kvm/include/kvm/e820.h       |   18 +++++-----
 tools/kvm/include/kvm/interrupt.h  |    6 ++--
 tools/kvm/include/kvm/ioport.h     |   21 ++++++------
 tools/kvm/include/kvm/kvm-cpu.h    |    1 -
 tools/kvm/include/kvm/kvm.h        |   20 ++++++------
 tools/kvm/include/kvm/pci.h        |   62 ++++++++++++++++++------------------
 tools/kvm/include/kvm/qcow.h       |    2 +-
 tools/kvm/include/kvm/segment.h    |    6 ++--
 tools/kvm/include/kvm/threadpool.h |    2 -
 tools/kvm/include/kvm/virtio.h     |   16 +++++-----
 tools/kvm/include/linux/types.h    |   14 +-------
 tools/kvm/ioport.c                 |   15 +++++----
 tools/kvm/kvm-cpu.c                |   46 +++++++++++++-------------
 tools/kvm/kvm-run.c                |    4 +--
 tools/kvm/kvm.c                    |    3 +-
 tools/kvm/mmio.c                   |    7 ++--
 tools/kvm/pci.c                    |   17 +++++-----
 tools/kvm/qcow.c                   |    6 ++--
 tools/kvm/rtc.c                    |   10 +++---
 tools/kvm/util/parse-options.c     |    1 -
 tools/kvm/virtio/blk.c             |   26 +++++++-------
 tools/kvm/virtio/console.c         |   43 ++++++++++++-------------
 tools/kvm/virtio/core.c            |    8 ++--
 tools/kvm/virtio/net.c             |   30 +++++++++---------
 tools/kvm/virtio/rng.c             |   15 ++++-----
 30 files changed, 247 insertions(+), 265 deletions(-)

diff --git a/tools/kvm/8250-serial.c b/tools/kvm/8250-serial.c
index 6d4b216..4892599 100644
--- a/tools/kvm/8250-serial.c
+++ b/tools/kvm/8250-serial.c
@@ -7,6 +7,7 @@
 #include "kvm/term.h"
 #include "kvm/kvm.h"
 
+#include <linux/types.h>
 #include <linux/serial_reg.h>
 
 #include <pthread.h>
@@ -14,20 +15,20 @@
 struct serial8250_device {
 	pthread_mutex_t		mutex;
 
-	uint16_t		iobase;
-	uint8_t			irq;
-
-	uint8_t			rbr;		/* receive buffer */
-	uint8_t			dll;
-	uint8_t			dlm;
-	uint8_t			iir;
-	uint8_t			ier;
-	uint8_t			fcr;
-	uint8_t			lcr;
-	uint8_t			mcr;
-	uint8_t			lsr;
-	uint8_t			msr;
-	uint8_t			scr;
+	u16			iobase;
+	u8			irq;
+
+	u8			rbr;		/* receive buffer */
+	u8			dll;
+	u8			dlm;
+	u8			iir;
+	u8			ier;
+	u8			fcr;
+	u8			lcr;
+	u8			mcr;
+	u8			lsr;
+	u8			msr;
+	u8			scr;
 };
 
 static struct serial8250_device devices[] = {
@@ -141,7 +142,7 @@ void serial8250__inject_sysrq(struct kvm *self)
 	sysrq_pending	= SYSRQ_PENDING_BREAK;
 }
 
-static struct serial8250_device *find_device(uint16_t port)
+static struct serial8250_device *find_device(u16 port)
 {
 	unsigned int i;
 
@@ -154,10 +155,10 @@ static struct serial8250_device *find_device(uint16_t port)
 	return NULL;
 }
 
-static bool serial8250_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool serial8250_out(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	struct serial8250_device *dev;
-	uint16_t offset;
+	u16 offset;
 	bool ret = true;
 
 	dev		= find_device(port);
@@ -242,10 +243,10 @@ out_unlock:
 	return ret;
 }
 
-static bool serial8250_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool serial8250_in(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	struct serial8250_device *dev;
-	uint16_t offset;
+	u16 offset;
 	bool ret = true;
 
 	dev		= find_device(port);
@@ -288,7 +289,7 @@ static bool serial8250_in(struct kvm *self, uint16_t port, void *data, int size,
 
 	switch (offset) {
 	case UART_IIR: {
-		uint8_t iir = dev->iir;
+		u8 iir = dev->iir;
 
 		if (dev->fcr & UART_FCR_ENABLE_FIFO)
 			iir		|= 0xc0;
diff --git a/tools/kvm/bios/e820.c b/tools/kvm/bios/e820.c
index baa2c5b..e4d8354 100644
--- a/tools/kvm/bios/e820.c
+++ b/tools/kvm/bios/e820.c
@@ -4,25 +4,25 @@
 #include "kvm/bios.h"
 #include "kvm/util.h"
 
-static inline void set_fs(uint16_t seg)
+static inline void set_fs(u16 seg)
 {
 	asm volatile("movw %0,%%fs" : : "rm" (seg));
 }
 
-static inline uint8_t rdfs8(unsigned long addr)
+static inline u8 rdfs8(unsigned long addr)
 {
-	uint8_t v;
+	u8 v;
 
-	asm volatile("addr32 movb %%fs:%1,%0" : "=q" (v) : "m" (*(uint8_t *)addr));
+	asm volatile("addr32 movb %%fs:%1,%0" : "=q" (v) : "m" (*(u8 *)addr));
 
 	return v;
 }
 
 bioscall void e820_query_map(struct e820_query *query)
 {
-	uint8_t map_size;
-	uint16_t fs_seg;
-	uint32_t ndx;
+	u8 map_size;
+	u16 fs_seg;
+	u32 ndx;
 
 	fs_seg		= flat_to_seg16(E820_MAP_SIZE);
 	set_fs(fs_seg);
@@ -34,7 +34,7 @@ bioscall void e820_query_map(struct e820_query *query)
 	if (ndx < map_size) {
 		unsigned long start;
 		unsigned int i;
-		uint8_t *p;
+		u8 *p;
 
 		fs_seg		= flat_to_seg16(E820_MAP_START);
 		set_fs(fs_seg);
diff --git a/tools/kvm/disk-image.c b/tools/kvm/disk-image.c
index 0fb2083..e44ee02 100644
--- a/tools/kvm/disk-image.c
+++ b/tools/kvm/disk-image.c
@@ -8,7 +8,7 @@
 
 #include <sys/ioctl.h>
 #include <sys/types.h>
-#include <inttypes.h>
+#include <linux/types.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <stdbool.h>
@@ -17,7 +17,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 
-struct disk_image *disk_image__new(int fd, uint64_t size, struct disk_image_operations *ops)
+struct disk_image *disk_image__new(int fd, u64 size, struct disk_image_operations *ops)
 {
 	struct disk_image *self;
 
@@ -31,7 +31,7 @@ struct disk_image *disk_image__new(int fd, uint64_t size, struct disk_image_oper
 	return self;
 }
 
-struct disk_image *disk_image__new_readonly(int fd, uint64_t size, struct disk_image_operations *ops)
+struct disk_image *disk_image__new_readonly(int fd, u64 size, struct disk_image_operations *ops)
 {
 	struct disk_image *self;
 
@@ -45,23 +45,23 @@ struct disk_image *disk_image__new_readonly(int fd, uint64_t size, struct disk_i
 	return self;
 }
 
-static ssize_t raw_image__read_sector_iov(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount)
+static ssize_t raw_image__read_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
 {
-	uint64_t offset = sector << SECTOR_SHIFT;
+	u64 offset = sector << SECTOR_SHIFT;
 
 	return preadv_in_full(self->fd, iov, iovcount, offset);
 }
 
-static ssize_t raw_image__write_sector_iov(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount)
+static ssize_t raw_image__write_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
 {
-	uint64_t offset = sector << SECTOR_SHIFT;
+	u64 offset = sector << SECTOR_SHIFT;
 
 	return pwritev_in_full(self->fd, iov, iovcount, offset);
 }
 
-static int raw_image__read_sector_ro_mmap(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len)
+static int raw_image__read_sector_ro_mmap(struct disk_image *self, u64 sector, void *dst, u32 dst_len)
 {
-	uint64_t offset = sector << SECTOR_SHIFT;
+	u64 offset = sector << SECTOR_SHIFT;
 
 	if (offset + dst_len > self->size)
 		return -1;
@@ -71,9 +71,9 @@ static int raw_image__read_sector_ro_mmap(struct disk_image *self, uint64_t sect
 	return 0;
 }
 
-static int raw_image__write_sector_ro_mmap(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len)
+static int raw_image__write_sector_ro_mmap(struct disk_image *self, u64 sector, void *src, u32 src_len)
 {
-	uint64_t offset = sector << SECTOR_SHIFT;
+	u64 offset = sector << SECTOR_SHIFT;
 
 	if (offset + src_len > self->size)
 		return -1;
@@ -110,7 +110,7 @@ static struct disk_image *raw_image__probe(int fd, struct stat *st, bool readonl
 
 static struct disk_image *blkdev__probe(const char *filename, struct stat *st)
 {
-	uint64_t size;
+	u64 size;
 	int fd;
 
 	if (!S_ISBLK(st->st_mode))
diff --git a/tools/kvm/include/kvm/cpufeature.h b/tools/kvm/include/kvm/cpufeature.h
index 92abb87..bc4abbb 100644
--- a/tools/kvm/include/kvm/cpufeature.h
+++ b/tools/kvm/include/kvm/cpufeature.h
@@ -22,10 +22,10 @@
 	((reg) |  (1 << (feature)))
 
 struct cpuid_regs {
-	uint32_t	eax;
-	uint32_t	ebx;
-	uint32_t	ecx;
-	uint32_t	edx;
+	u32	eax;
+	u32	ebx;
+	u32	ecx;
+	u32	edx;
 };
 
 static inline void host_cpuid(struct cpuid_regs *regs)
diff --git a/tools/kvm/include/kvm/disk-image.h b/tools/kvm/include/kvm/disk-image.h
index 11823c6..660a539 100644
--- a/tools/kvm/include/kvm/disk-image.h
+++ b/tools/kvm/include/kvm/disk-image.h
@@ -1,7 +1,7 @@
 #ifndef KVM__DISK_IMAGE_H
 #define KVM__DISK_IMAGE_H
 
-#include <stdint.h>
+#include <linux/types.h>
 #include <stdbool.h>
 #include <sys/uio.h>
 
@@ -11,36 +11,36 @@
 struct disk_image;
 
 struct disk_image_operations {
-	int (*read_sector)(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len);
-	int (*write_sector)(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len);
-	ssize_t (*read_sector_iov)(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount);
-	ssize_t (*write_sector_iov)(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount);
+	int (*read_sector)(struct disk_image *self, u64 sector, void *dst, u32 dst_len);
+	int (*write_sector)(struct disk_image *self, u64 sector, void *src, u32 src_len);
+	ssize_t (*read_sector_iov)(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount);
+	ssize_t (*write_sector_iov)(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount);
 	void (*close)(struct disk_image *self);
 };
 
 struct disk_image {
 	int				fd;
-	uint64_t			size;
+	u64				size;
 	struct disk_image_operations	*ops;
 	void				*priv;
 };
 
 struct disk_image *disk_image__open(const char *filename, bool readonly);
-struct disk_image *disk_image__new(int fd, uint64_t size, struct disk_image_operations *ops);
-struct disk_image *disk_image__new_readonly(int fd, uint64_t size, struct disk_image_operations *ops);
+struct disk_image *disk_image__new(int fd, u64 size, struct disk_image_operations *ops);
+struct disk_image *disk_image__new_readonly(int fd, u64 size, struct disk_image_operations *ops);
 void disk_image__close(struct disk_image *self);
 
-static inline int disk_image__read_sector(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len)
+static inline int disk_image__read_sector(struct disk_image *self, u64 sector, void *dst, u32 dst_len)
 {
 	return self->ops->read_sector(self, sector, dst, dst_len);
 }
 
-static inline int disk_image__write_sector(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len)
+static inline int disk_image__write_sector(struct disk_image *self, u64 sector, void *src, u32 src_len)
 {
 	return self->ops->write_sector(self, sector, src, src_len);
 }
 
-static inline ssize_t disk_image__read_sector_iov(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount)
+static inline ssize_t disk_image__read_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
 {
 	if (self->ops->read_sector_iov)
 		return self->ops->read_sector_iov(self, sector, iov, iovcount);
@@ -54,7 +54,7 @@ static inline ssize_t disk_image__read_sector_iov(struct disk_image *self, uint6
 	return sector << SECTOR_SHIFT;
 }
 
-static inline ssize_t disk_image__write_sector_iov(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount)
+static inline ssize_t disk_image__write_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
 {
 	if (self->ops->write_sector_iov)
 		return self->ops->write_sector_iov(self, sector, iov, iovcount);
diff --git a/tools/kvm/include/kvm/e820.h b/tools/kvm/include/kvm/e820.h
index 7482eb5..252ae1f 100644
--- a/tools/kvm/include/kvm/e820.h
+++ b/tools/kvm/include/kvm/e820.h
@@ -1,7 +1,7 @@
 #ifndef KVM_E820_H
 #define KVM_E820_H
 
-#include <stdint.h>
+#include <linux/types.h>
 
 #define SMAP    0x534d4150      /* ASCII "SMAP" */
 
@@ -11,17 +11,17 @@
 #define E820_MEM_AREAS		4
 
 struct e820_entry {
-	uint64_t addr;	/* start of memory segment */
-	uint64_t size;	/* size of memory segment */
-	uint32_t type;	/* type of memory segment */
+	u64	addr;	/* start of memory segment */
+	u64	size;	/* size of memory segment */
+	u32	type;	/* type of memory segment */
 } __attribute__((packed));
 
 struct e820_query {
-	uint32_t	eax;
-	uint32_t	ebx;
-	uint32_t	edi;
-	uint32_t	ecx;
-	uint32_t	edx;
+	u32	eax;
+	u32	ebx;
+	u32	edi;
+	u32	ecx;
+	u32	edx;
 };
 
 void e820_query_map(struct e820_query *query);
diff --git a/tools/kvm/include/kvm/interrupt.h b/tools/kvm/include/kvm/interrupt.h
index 0169bba..b9610ea 100644
--- a/tools/kvm/include/kvm/interrupt.h
+++ b/tools/kvm/include/kvm/interrupt.h
@@ -1,13 +1,13 @@
 #ifndef KVM__INTERRUPT_H
 #define KVM__INTERRUPT_H
 
-#include <inttypes.h>
+#include <linux/types.h>
 #include "kvm/bios.h"
 #include "kvm/bios-export.h"
 
 struct real_intr_desc {
-	uint16_t offset;
-	uint16_t segment;
+	u16 offset;
+	u16 segment;
 } __attribute__((packed));
 
 #define REAL_SEGMENT_SHIFT	4
diff --git a/tools/kvm/include/kvm/ioport.h b/tools/kvm/include/kvm/ioport.h
index 98a880f..aa5d73f 100644
--- a/tools/kvm/include/kvm/ioport.h
+++ b/tools/kvm/include/kvm/ioport.h
@@ -2,7 +2,8 @@
 #define KVM__IOPORT_H
 
 #include <stdbool.h>
-#include <stdint.h>
+#include <asm/types.h>
+#include <linux/types.h>
 
 /* some ports we reserve for own use */
 #define IOPORT_DBG			0xe0
@@ -18,40 +19,40 @@
 struct kvm;
 
 struct ioport_operations {
-	bool (*io_in)(struct kvm *self, uint16_t port, void *data, int size, uint32_t count);
-	bool (*io_out)(struct kvm *self, uint16_t port, void *data, int size, uint32_t count);
+	bool (*io_in)(struct kvm *self, u16 port, void *data, int size, u32 count);
+	bool (*io_out)(struct kvm *self, u16 port, void *data, int size, u32 count);
 };
 
 void ioport__setup_legacy(void);
 
-void ioport__register(uint16_t port, struct ioport_operations *ops, int count);
+void ioport__register(u16 port, struct ioport_operations *ops, int count);
 
-static inline uint8_t ioport__read8(uint8_t *data)
+static inline u8 ioport__read8(u8 *data)
 {
 	return *data;
 }
 
-static inline uint16_t ioport__read16(uint16_t *data)
+static inline u16 ioport__read16(u16 *data)
 {
 	return *data;
 }
 
-static inline uint32_t ioport__read32(uint32_t *data)
+static inline u32 ioport__read32(u32 *data)
 {
 	return *data;
 }
 
-static inline void ioport__write8(uint8_t *data, uint8_t value)
+static inline void ioport__write8(u8 *data, u8 value)
 {
 	*data		 = value;
 }
 
-static inline void ioport__write16(uint16_t *data, uint16_t value)
+static inline void ioport__write16(u16 *data, u16 value)
 {
 	*data		 = value;
 }
 
-static inline void ioport__write32(uint32_t *data, uint32_t value)
+static inline void ioport__write32(u32 *data, u32 value)
 {
 	*data		 = value;
 }
diff --git a/tools/kvm/include/kvm/kvm-cpu.h b/tools/kvm/include/kvm/kvm-cpu.h
index 0d0881e..18d787f 100644
--- a/tools/kvm/include/kvm/kvm-cpu.h
+++ b/tools/kvm/include/kvm/kvm-cpu.h
@@ -4,7 +4,6 @@
 #include <linux/kvm.h>	/* for struct kvm_regs */
 
 #include <pthread.h>
-#include <stdint.h>
 
 struct kvm;
 
diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h
index d239f49..f697579 100644
--- a/tools/kvm/include/kvm/kvm.h
+++ b/tools/kvm/include/kvm/kvm.h
@@ -4,7 +4,7 @@
 #include "kvm/interrupt.h"
 
 #include <stdbool.h>
-#include <stdint.h>
+#include <linux/types.h>
 #include <time.h>
 
 #define KVM_NR_CPUS		(255)
@@ -16,14 +16,14 @@ struct kvm {
 
 	int			nrcpus;		/* Number of cpus to run */
 
-	uint64_t		ram_size;
+	u64			ram_size;
 	void			*ram_start;
 
 	bool			nmi_disabled;
 
-	uint16_t		boot_selector;
-	uint16_t		boot_ip;
-	uint16_t		boot_sp;
+	u16			boot_selector;
+	u16			boot_ip;
+	u16			boot_sp;
 
 	struct interrupt_table	interrupt_table;
 };
@@ -37,8 +37,8 @@ void kvm__setup_bios(struct kvm *self);
 void kvm__start_timer(struct kvm *self);
 void kvm__stop_timer(struct kvm *self);
 void kvm__irq_line(struct kvm *self, int irq, int level);
-bool kvm__emulate_io(struct kvm *self, uint16_t port, void *data, int direction, int size, uint32_t count);
-bool kvm__emulate_mmio(struct kvm *self, uint64_t phys_addr, uint8_t *data, uint32_t len, uint8_t is_write);
+bool kvm__emulate_io(struct kvm *self, u16 port, void *data, int direction, int size, u32 count);
+bool kvm__emulate_mmio(struct kvm *self, u64 phys_addr, u8 *data, u32 len, u8 is_write);
 
 /*
  * Debugging
@@ -52,9 +52,9 @@ static inline bool host_ptr_in_ram(struct kvm *self, void *p)
 	return self->ram_start <= p && p < (self->ram_start + self->ram_size);
 }
 
-static inline uint32_t segment_to_flat(uint16_t selector, uint16_t offset)
+static inline u32 segment_to_flat(u16 selector, u16 offset)
 {
-	return ((uint32_t)selector << 4) + (uint32_t) offset;
+	return ((u32)selector << 4) + (u32) offset;
 }
 
 static inline void *guest_flat_to_host(struct kvm *self, unsigned long offset)
@@ -62,7 +62,7 @@ static inline void *guest_flat_to_host(struct kvm *self, unsigned long offset)
 	return self->ram_start + offset;
 }
 
-static inline void *guest_real_to_host(struct kvm *self, uint16_t selector, uint16_t offset)
+static inline void *guest_real_to_host(struct kvm *self, u16 selector, u16 offset)
 {
 	unsigned long flat = segment_to_flat(selector, offset);
 
diff --git a/tools/kvm/include/kvm/pci.h b/tools/kvm/include/kvm/pci.h
index c352803..6ad4426 100644
--- a/tools/kvm/include/kvm/pci.h
+++ b/tools/kvm/include/kvm/pci.h
@@ -1,7 +1,7 @@
 #ifndef KVM__PCI_H
 #define KVM__PCI_H
 
-#include <inttypes.h>
+#include <linux/types.h>
 
 #include <linux/pci_regs.h>
 
@@ -15,41 +15,41 @@
 #define PCI_CONFIG_BUS_FORWARD	0xcfa
 
 struct pci_config_address {
-	unsigned		zeros		: 2;		/* 1  .. 0  */
-	unsigned		register_number	: 6;		/* 7  .. 2  */
-	unsigned		function_number	: 3;		/* 10 .. 8  */
-	unsigned		device_number	: 5;		/* 15 .. 11 */
-	unsigned		bus_number	: 8;		/* 23 .. 16 */
-	unsigned		reserved	: 7;		/* 30 .. 24 */
-	unsigned		enable_bit	: 1;		/* 31       */
+	unsigned	zeros		: 2;		/* 1  .. 0  */
+	unsigned	register_number	: 6;		/* 7  .. 2  */
+	unsigned	function_number	: 3;		/* 10 .. 8  */
+	unsigned	device_number	: 5;		/* 15 .. 11 */
+	unsigned	bus_number	: 8;		/* 23 .. 16 */
+	unsigned	reserved	: 7;		/* 30 .. 24 */
+	unsigned	enable_bit	: 1;		/* 31       */
 };
 
 struct pci_device_header {
-	uint16_t	vendor_id;
-	uint16_t	device_id;
-	uint16_t	command;
-	uint16_t	status;
-	uint16_t	revision_id		:  8;
-	uint32_t	class			: 24;
-	uint8_t		cacheline_size;
-	uint8_t		latency_timer;
-	uint8_t		header_type;
-	uint8_t		bist;
-	uint32_t	bar[6];
-	uint32_t	card_bus;
-	uint16_t	subsys_vendor_id;
-	uint16_t	subsys_id;
-	uint32_t	exp_rom_bar;
-	uint32_t	capabilities		:  8;
-	uint32_t	reserved1		: 24;
-	uint32_t	reserved2;
-	uint8_t		irq_line;
-	uint8_t		irq_pin;
-	uint8_t		min_gnt;
-	uint8_t		max_lat;
+	u16		vendor_id;
+	u16		device_id;
+	u16		command;
+	u16		status;
+	u16		revision_id		:  8;
+	u32		class			: 24;
+	u8		cacheline_size;
+	u8		latency_timer;
+	u8		header_type;
+	u8		bist;
+	u32		bar[6];
+	u32		card_bus;
+	u16		subsys_vendor_id;
+	u16		subsys_id;
+	u32		exp_rom_bar;
+	u32		capabilities		:  8;
+	u32		reserved1		: 24;
+	u32		reserved2;
+	u8		irq_line;
+	u8		irq_pin;
+	u8		min_gnt;
+	u8		max_lat;
 };
 
 void pci__init(void);
-void pci__register(struct pci_device_header *dev, uint8_t dev_num);
+void pci__register(struct pci_device_header *dev, u8 dev_num);
 
 #endif /* KVM__PCI_H */
diff --git a/tools/kvm/include/kvm/qcow.h b/tools/kvm/include/kvm/qcow.h
index afd776d8..3d84aad 100644
--- a/tools/kvm/include/kvm/qcow.h
+++ b/tools/kvm/include/kvm/qcow.h
@@ -33,7 +33,7 @@ struct qcow_header {
 	u32			l1_size;
 	u8			cluster_bits;
 	u8			l2_bits;
-	uint64_t		oflag_mask;
+	u64			oflag_mask;
 };
 
 struct qcow1_header_disk {
diff --git a/tools/kvm/include/kvm/segment.h b/tools/kvm/include/kvm/segment.h
index 0701cd7..362e46d 100644
--- a/tools/kvm/include/kvm/segment.h
+++ b/tools/kvm/include/kvm/segment.h
@@ -1,14 +1,14 @@
 #ifndef KVM_SEGMENT_H
 #define KVM_SEGMENT_H
 
-#include <stdint.h>
+#include <linux/types.h>
 
-static inline uint16_t flat_to_seg16(uint32_t address)
+static inline u16 flat_to_seg16(u32 address)
 {
 	return address >> 4;
 }
 
-static inline uint16_t flat_to_off16(uint32_t address, uint32_t segment)
+static inline u16 flat_to_off16(u32 address, u32 segment)
 {
 	return address - (segment << 4);
 }
diff --git a/tools/kvm/include/kvm/threadpool.h b/tools/kvm/include/kvm/threadpool.h
index 4716411..62826a6 100644
--- a/tools/kvm/include/kvm/threadpool.h
+++ b/tools/kvm/include/kvm/threadpool.h
@@ -1,8 +1,6 @@
 #ifndef KVM__THREADPOOL_H
 #define KVM__THREADPOOL_H
 
-#include <stdint.h>
-
 struct kvm;
 
 typedef void (*kvm_thread_callback_fn_t)(struct kvm *kvm, void *data);
diff --git a/tools/kvm/include/kvm/virtio.h b/tools/kvm/include/kvm/virtio.h
index 7903a74..e8df8eb 100644
--- a/tools/kvm/include/kvm/virtio.h
+++ b/tools/kvm/include/kvm/virtio.h
@@ -3,25 +3,25 @@
 
 #include <linux/virtio_ring.h>
 
-#include <stdint.h>
+#include <linux/types.h>
 #include <sys/uio.h>
 
 #include "kvm/kvm.h"
 
 struct virt_queue {
-	struct vring			vring;
-	uint32_t			pfn;
+	struct vring	vring;
+	u32		pfn;
 	/* The last_avail_idx field is an index to ->ring of struct vring_avail.
 	   It's where we assume the next request index is at.  */
-	uint16_t			last_avail_idx;
+	u16		last_avail_idx;
 };
 
-static inline uint16_t virt_queue__pop(struct virt_queue *queue)
+static inline u16 virt_queue__pop(struct virt_queue *queue)
 {
 	return queue->vring.avail->ring[queue->last_avail_idx++ % queue->vring.num];
 }
 
-static inline struct vring_desc *virt_queue__get_desc(struct virt_queue *queue, uint16_t desc_ndx)
+static inline struct vring_desc *virt_queue__get_desc(struct virt_queue *queue, u16 desc_ndx)
 {
 	return &queue->vring.desc[desc_ndx];
 }
@@ -33,8 +33,8 @@ static inline bool virt_queue__available(struct virt_queue *vq)
 	return vq->vring.avail->idx !=  vq->last_avail_idx;
 }
 
-struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, uint32_t head, uint32_t len);
+struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, u32 head, u32 len);
 
-uint16_t virt_queue__get_iov(struct virt_queue *queue, struct iovec iov[], uint16_t *out, uint16_t *in, struct kvm *kvm);
+u16 virt_queue__get_iov(struct virt_queue *queue, struct iovec iov[], u16 *out, u16 *in, struct kvm *kvm);
 
 #endif /* KVM__VIRTIO_H */
diff --git a/tools/kvm/include/linux/types.h b/tools/kvm/include/linux/types.h
index c7c444e..6feb6da 100644
--- a/tools/kvm/include/linux/types.h
+++ b/tools/kvm/include/linux/types.h
@@ -1,19 +1,7 @@
 #ifndef LINUX_TYPES_H
 #define LINUX_TYPES_H
 
-#include <stdint.h>
-
-#define __s8		int8_t
-#define __u8		uint8_t
-
-#define __s16		int16_t
-#define __u16		uint16_t
-
-#define __s32		int32_t
-#define __u32		uint32_t
-
-#define __s64		long long
-#define __u64		unsigned long long
+#include <asm/types.h>
 
 typedef __u64 u64;
 typedef __s64 s64;
diff --git a/tools/kvm/ioport.c b/tools/kvm/ioport.c
index a38d2d1..8b96518 100644
--- a/tools/kvm/ioport.c
+++ b/tools/kvm/ioport.c
@@ -3,6 +3,7 @@
 #include "kvm/kvm.h"
 
 #include <linux/kvm.h>	/* for KVM_EXIT_* */
+#include <linux/types.h>
 
 #include <stdbool.h>
 #include <assert.h>
@@ -12,7 +13,7 @@
 
 bool ioport_debug;
 
-static bool debug_io_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool debug_io_out(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	exit(EXIT_SUCCESS);
 }
@@ -21,12 +22,12 @@ static struct ioport_operations debug_ops = {
 	.io_out		= debug_io_out,
 };
 
-static bool dummy_io_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool dummy_io_in(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	return true;
 }
 
-static bool dummy_io_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool dummy_io_out(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	return true;
 }
@@ -42,7 +43,7 @@ static struct ioport_operations dummy_write_only_ioport_ops = {
 
 static struct ioport_operations *ioport_ops[USHRT_MAX];
 
-void ioport__register(uint16_t port, struct ioport_operations *ops, int count)
+void ioport__register(u16 port, struct ioport_operations *ops, int count)
 {
 	int i;
 
@@ -58,12 +59,12 @@ static const char *to_direction(int direction)
 		return "OUT";
 }
 
-static void ioport_error(uint16_t port, void *data, int direction, int size, uint32_t count)
+static void ioport_error(u16 port, void *data, int direction, int size, u32 count)
 {
-	fprintf(stderr, "IO error: %s port=%x, size=%d, count=%" PRIu32 "\n", to_direction(direction), port, size, count);
+	fprintf(stderr, "IO error: %s port=%x, size=%d, count=%u\n", to_direction(direction), port, size, count);
 }
 
-bool kvm__emulate_io(struct kvm *self, uint16_t port, void *data, int direction, int size, uint32_t count)
+bool kvm__emulate_io(struct kvm *self, u16 port, void *data, int direction, int size, u32 count)
 {
 	struct ioport_operations *ops = ioport_ops[port];
 	bool ret;
diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c
index 3f4007c..e66f03e 100644
--- a/tools/kvm/kvm-cpu.c
+++ b/tools/kvm/kvm-cpu.c
@@ -17,9 +17,9 @@ static inline bool is_in_protected_mode(struct kvm_cpu *self)
 	return self->sregs.cr0 & 0x01;
 }
 
-static inline uint64_t ip_to_flat(struct kvm_cpu *self, uint64_t ip)
+static inline u64 ip_to_flat(struct kvm_cpu *self, u64 ip)
 {
-	uint64_t cs;
+	u64 cs;
 
 	/*
 	 * NOTE! We should take code segment base address into account here.
@@ -33,12 +33,12 @@ static inline uint64_t ip_to_flat(struct kvm_cpu *self, uint64_t ip)
 	return ip + (cs << 4);
 }
 
-static inline uint32_t selector_to_base(uint16_t selector)
+static inline u32 selector_to_base(u16 selector)
 {
 	/*
 	 * KVM on Intel requires 'base' to be 'selector * 16' in real mode.
 	 */
-	return (uint32_t)selector * 16;
+	return (u32)selector * 16;
 }
 
 static struct kvm_cpu *kvm_cpu__new(struct kvm *kvm)
@@ -158,7 +158,7 @@ static void kvm_cpu__setup_regs(struct kvm_cpu *self)
 	};
 
 	if (self->regs.rip > USHRT_MAX)
-		die("ip 0x%" PRIx64 " is too high for real mode", (uint64_t) self->regs.rip);
+		die("ip 0x%llx is too high for real mode", (u64) self->regs.rip);
 
 	if (ioctl(self->vcpu_fd, KVM_SET_REGS, &self->regs) < 0)
 		die_perror("KVM_SET_REGS failed");
@@ -200,15 +200,15 @@ void kvm_cpu__reset_vcpu(struct kvm_cpu *self)
 
 static void print_dtable(const char *name, struct kvm_dtable *dtable)
 {
-	printf(" %s                 %016" PRIx64 "  %08" PRIx16 "\n",
-		name, (uint64_t) dtable->base, (uint16_t) dtable->limit);
+	printf(" %s                 %016llx %08hx\n",
+		name, (u64) dtable->base, (u16) dtable->limit);
 }
 
 static void print_segment(const char *name, struct kvm_segment *seg)
 {
-	printf(" %s       %04" PRIx16 "      %016" PRIx64 "  %08" PRIx32 "  %02" PRIx8 "    %x %x   %x  %x %x %x %x\n",
-		name, (uint16_t) seg->selector, (uint64_t) seg->base, (uint32_t) seg->limit,
-		(uint8_t) seg->type, seg->present, seg->dpl, seg->db, seg->s, seg->l, seg->g, seg->avl);
+	printf(" %s       %04hx      %016llx  %08x  %02hhx    %x %x   %x  %x %x %x %x\n",
+		name, (u16) seg->selector, (u64) seg->base, (u32) seg->limit,
+		(u8) seg->type, seg->present, seg->dpl, seg->db, seg->s, seg->l, seg->g, seg->avl);
 }
 
 void kvm_cpu__show_registers(struct kvm_cpu *self)
@@ -266,13 +266,13 @@ void kvm_cpu__show_registers(struct kvm_cpu *self)
 	print_segment("ldt", &sregs.ldt);
 	print_dtable("gdt", &sregs.gdt);
 	print_dtable("idt", &sregs.idt);
-	printf(" [ efer: %016" PRIx64 "  apic base: %016" PRIx64 "  nmi: %s ]\n",
-		(uint64_t) sregs.efer, (uint64_t) sregs.apic_base,
+	printf(" [ efer: %016llx  apic base: %016llx  nmi: %s ]\n",
+		(u64) sregs.efer, (u64) sregs.apic_base,
 		(self->kvm->nmi_disabled ? "disabled" : "enabled"));
 	printf("Interrupt bitmap:\n");
 	printf(" ");
 	for (i = 0; i < (KVM_NR_INTERRUPTS + 63) / 64; i++)
-		printf("%016" PRIx64 " ", (uint64_t) sregs.interrupt_bitmap[i]);
+		printf("%016llx ", (u64) sregs.interrupt_bitmap[i]);
 	printf("\n");
 }
 
@@ -283,7 +283,7 @@ void kvm_cpu__show_code(struct kvm_cpu *self)
 	unsigned int code_len = code_bytes;
 	unsigned char c;
 	unsigned int i;
-	uint8_t *ip;
+	u8 *ip;
 
 	if (ioctl(self->vcpu_fd, KVM_GET_REGS, &self->regs) < 0)
 		die("KVM_GET_REGS failed");
@@ -315,10 +315,10 @@ void kvm_cpu__show_code(struct kvm_cpu *self)
 
 void kvm_cpu__show_page_tables(struct kvm_cpu *self)
 {
-	uint64_t *pte1;
-	uint64_t *pte2;
-	uint64_t *pte3;
-	uint64_t *pte4;
+	u64 *pte1;
+	u64 *pte2;
+	u64 *pte3;
+	u64 *pte4;
 
 	if (!is_in_protected_mode(self))
 		return;
@@ -344,12 +344,12 @@ void kvm_cpu__show_page_tables(struct kvm_cpu *self)
 
 	printf("Page Tables:\n");
 	if (*pte2 & (1 << 7))
-		printf(" pte4: %016" PRIx64 "   pte3: %016" PRIx64
-			"   pte2: %016" PRIx64 "\n",
+		printf(" pte4: %016llx   pte3: %016llx"
+			"   pte2: %016llx\n",
 			*pte4, *pte3, *pte2);
 	else
-		printf(" pte4: %016" PRIx64 "   pte3: %016" PRIx64 "   pte2: %016"
-			PRIx64 "   pte1: %016" PRIx64 "\n",
+		printf(" pte4: %016llx  pte3: %016llx   pte2: %016"
+			"llx   pte1: %016llx\n",
 			*pte4, *pte3, *pte2, *pte1);
 }
 
@@ -387,7 +387,7 @@ int kvm_cpu__start(struct kvm_cpu *cpu)
 
 			ret = kvm__emulate_io(cpu->kvm,
 					cpu->kvm_run->io.port,
-					(uint8_t *)cpu->kvm_run +
+					(u8 *)cpu->kvm_run +
 					cpu->kvm_run->io.data_offset,
 					cpu->kvm_run->io.direction,
 					cpu->kvm_run->io.size,
diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
index 2182dc5..2ff13d3 100644
--- a/tools/kvm/kvm-run.c
+++ b/tools/kvm/kvm-run.c
@@ -1,9 +1,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <signal.h>
-#include <stdint.h>
 #include <unistd.h>
-#include <inttypes.h>
 #include <stdlib.h>
 #include <termios.h>
 #include <sys/utsname.h>
@@ -162,7 +160,7 @@ static void *kvm_cpu_thread(void *arg)
 	return (void *) (intptr_t) 0;
 
 panic_kvm:
-	fprintf(stderr, "KVM exit reason: %" PRIu32 " (\"%s\")\n",
+	fprintf(stderr, "KVM exit reason: %u (\"%s\")\n",
 		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)
diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
index df88d37..b3adb6b 100644
--- a/tools/kvm/kvm.c
+++ b/tools/kvm/kvm.c
@@ -11,7 +11,6 @@
 #include <asm/bootparam.h>
 
 #include <sys/ioctl.h>
-#include <inttypes.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <stdbool.h>
@@ -115,7 +114,7 @@ void kvm__delete(struct kvm *self)
 static bool kvm__cpu_supports_vm(void)
 {
 	struct cpuid_regs regs;
-	uint32_t eax_base;
+	u32 eax_base;
 	int feature;
 
 	regs	= (struct cpuid_regs) {
diff --git a/tools/kvm/mmio.c b/tools/kvm/mmio.c
index 095d2c9..6dd0645 100644
--- a/tools/kvm/mmio.c
+++ b/tools/kvm/mmio.c
@@ -1,8 +1,9 @@
 #include "kvm/kvm.h"
 
 #include <stdio.h>
+#include <linux/types.h>
 
-static const char *to_direction(uint8_t is_write)
+static const char *to_direction(u8 is_write)
 {
 	if (is_write)
 		return "write";
@@ -10,9 +11,9 @@ static const char *to_direction(uint8_t is_write)
 	return "read";
 }
 
-bool kvm__emulate_mmio(struct kvm *self, uint64_t phys_addr, uint8_t *data, uint32_t len, uint8_t is_write)
+bool kvm__emulate_mmio(struct kvm *self, u64 phys_addr, u8 *data, u32 len, u8 is_write)
 {
-	fprintf(stderr, "Warning: Ignoring MMIO %s at %016" PRIx64 " (length %" PRIu32 ")\n",
+	fprintf(stderr, "Warning: Ignoring MMIO %s at %016llx (length %u)\n",
 		to_direction(is_write), phys_addr, len);
 
 	return true;
diff --git a/tools/kvm/pci.c b/tools/kvm/pci.c
index 0b96990..11457ef 100644
--- a/tools/kvm/pci.c
+++ b/tools/kvm/pci.c
@@ -3,7 +3,6 @@
 #include "kvm/util.h"
 
 #include <assert.h>
-#include <stdint.h>
 
 #define PCI_MAX_DEVICES			256
 
@@ -11,7 +10,7 @@ static struct pci_device_header		*pci_devices[PCI_MAX_DEVICES];
 
 static struct pci_config_address	pci_config_address;
 
-static void *pci_config_address_ptr(uint16_t port)
+static void *pci_config_address_ptr(u16 port)
 {
 	unsigned long offset;
 	void *base;
@@ -22,7 +21,7 @@ static void *pci_config_address_ptr(uint16_t port)
 	return base + offset;
 }
 
-static bool pci_config_address_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool pci_config_address_out(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	void *p = pci_config_address_ptr(port);
 
@@ -31,7 +30,7 @@ static bool pci_config_address_out(struct kvm *self, uint16_t port, void *data,
 	return true;
 }
 
-static bool pci_config_address_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool pci_config_address_in(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	void *p = pci_config_address_ptr(port);
 
@@ -45,12 +44,12 @@ static struct ioport_operations pci_config_address_ops = {
 	.io_out		= pci_config_address_out,
 };
 
-static bool pci_config_data_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool pci_config_data_out(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	return true;
 }
 
-static bool pci_device_exists(uint8_t bus_number, uint8_t device_number, uint8_t function_number)
+static bool pci_device_exists(u8 bus_number, u8 device_number, u8 function_number)
 {
 	struct pci_device_header *dev;
 
@@ -68,10 +67,10 @@ static bool pci_device_exists(uint8_t bus_number, uint8_t device_number, uint8_t
 	return dev != NULL;
 }
 
-static bool pci_config_data_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool pci_config_data_in(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	unsigned long start;
-	uint8_t dev_num;
+	u8 dev_num;
 
 	/*
 	 * If someone accesses PCI configuration space offsets that are not
@@ -102,7 +101,7 @@ static struct ioport_operations pci_config_data_ops = {
 	.io_out		= pci_config_data_out,
 };
 
-void pci__register(struct pci_device_header *dev, uint8_t dev_num)
+void pci__register(struct pci_device_header *dev, u8 dev_num)
 {
 	assert(dev_num < PCI_MAX_DEVICES);
 
diff --git a/tools/kvm/qcow.c b/tools/kvm/qcow.c
index f628736..fd29dee 100644
--- a/tools/kvm/qcow.c
+++ b/tools/kvm/qcow.c
@@ -101,8 +101,8 @@ out_error:
 	goto out;
 }
 
-static int qcow1_read_sector(struct disk_image *self, uint64_t sector,
-		void *dst, uint32_t dst_len)
+static int qcow1_read_sector(struct disk_image *self, u64 sector,
+		void *dst, u32 dst_len)
 {
 	struct qcow *q = self->priv;
 	struct qcow_header *header = q->header;
@@ -130,7 +130,7 @@ out_error:
 	return -1;
 }
 
-static int qcow1_write_sector(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len)
+static int qcow1_write_sector(struct disk_image *self, u64 sector, void *src, u32 src_len)
 {
 	return -1;
 }
diff --git a/tools/kvm/rtc.c b/tools/kvm/rtc.c
index b9c09b9..719198f 100644
--- a/tools/kvm/rtc.c
+++ b/tools/kvm/rtc.c
@@ -5,7 +5,7 @@
 
 #include <time.h>
 
-static uint8_t cmos_index;
+static u8 cmos_index;
 
 #define CMOS_RTC_SECONDS		0x00
 #define CMOS_RTC_MINUTES		0x02
@@ -19,7 +19,7 @@ static inline unsigned char bin2bcd(unsigned val)
 	return ((val / 10) << 4) + val % 10;
 }
 
-static bool cmos_ram_data_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool cmos_ram_data_in(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	struct tm *tm;
 	time_t ti;
@@ -52,7 +52,7 @@ static bool cmos_ram_data_in(struct kvm *self, uint16_t port, void *data, int si
 	return true;
 }
 
-static bool cmos_ram_data_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool cmos_ram_data_out(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	return true;
 }
@@ -62,9 +62,9 @@ static struct ioport_operations cmos_ram_data_ioport_ops = {
 	.io_in		= cmos_ram_data_in,
 };
 
-static bool cmos_ram_index_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool cmos_ram_index_out(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
-	uint8_t value;
+	u8 value;
 
 	value	= ioport__read8(data);
 
diff --git a/tools/kvm/util/parse-options.c b/tools/kvm/util/parse-options.c
index 94edf7b..19d2048 100644
--- a/tools/kvm/util/parse-options.c
+++ b/tools/kvm/util/parse-options.c
@@ -1,7 +1,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
-#include <stdint.h>
 
 #include <stdbool.h>
 
diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c
index 16c9658..4e5ac9e 100644
--- a/tools/kvm/virtio/blk.c
+++ b/tools/kvm/virtio/blk.c
@@ -14,7 +14,7 @@
 #include <linux/virtio_ring.h>
 #include <linux/virtio_blk.h>
 
-#include <inttypes.h>
+#include <linux/types.h>
 #include <pthread.h>
 
 #define VIRTIO_BLK_IRQ		9
@@ -35,14 +35,14 @@ struct blk_device {
 
 	struct virtio_blk_config	blk_config;
 	struct disk_image		*disk;
-	uint32_t			host_features;
-	uint32_t			guest_features;
-	uint16_t			config_vector;
-	uint8_t				status;
+	u32				host_features;
+	u32				guest_features;
+	u16				config_vector;
+	u8				status;
 	u8				idx;
 
 	/* virtio queue */
-	uint16_t			queue_selector;
+	u16				queue_selector;
 
 	struct virt_queue		vqs[NUM_VIRT_QUEUES];
 	struct blk_device_job		jobs[NUM_VIRT_QUEUES];
@@ -55,9 +55,9 @@ static bool virtio_blk_pci_io_device_specific_in(struct blk_device *blk_device,
 						void *data,
 						unsigned long offset,
 						int size,
-						uint32_t count)
+						u32 count)
 {
-	uint8_t *config_space = (uint8_t *) &blk_device->blk_config;
+	u8 *config_space = (u8 *) &blk_device->blk_config;
 
 	if (size != 1 || count != 1)
 		return false;
@@ -77,7 +77,7 @@ static void virtio_blk_port2dev(u16 port,
 	*dev_idx	= (port - base) / size;
 	*offset		= port - (base + *dev_idx * size);
 }
-static bool virtio_blk_pci_io_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool virtio_blk_pci_io_in(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	u16 offset, dev_idx;
 	bool ret = true;
@@ -133,8 +133,8 @@ static bool virtio_blk_do_io_request(struct kvm *self,
 	struct iovec iov[VIRTIO_BLK_QUEUE_SIZE];
 	struct virtio_blk_outhdr *req;
 	ssize_t block_cnt = -1;
-	uint16_t out, in, head;
-	uint8_t *status;
+	u16 out, in, head;
+	u8 *status;
 
 	head		= virt_queue__get_iov(queue, iov, &out, &in, self);
 
@@ -177,7 +177,7 @@ static void virtio_blk_do_io(struct kvm *kvm, void *param)
 	kvm__irq_line(kvm, VIRTIO_BLK_IRQ + blk_device->idx, 1);
 }
 
-static bool virtio_blk_pci_io_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool virtio_blk_pci_io_out(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	u16 offset, dev_idx;
 	bool ret = true;
@@ -220,7 +220,7 @@ static bool virtio_blk_pci_io_out(struct kvm *self, uint16_t port, void *data, i
 		blk_device->queue_selector	= ioport__read16(data);
 		break;
 	case VIRTIO_PCI_QUEUE_NOTIFY: {
-		uint16_t queue_index;
+		u16 queue_index;
 		queue_index		= ioport__read16(data);
 		thread_pool__do_job(blk_device->jobs[queue_index].job_id);
 		break;
diff --git a/tools/kvm/virtio/console.c b/tools/kvm/virtio/console.c
index f440ded..3be65d3 100644
--- a/tools/kvm/virtio/console.c
+++ b/tools/kvm/virtio/console.c
@@ -17,7 +17,6 @@
 #include <sys/uio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <inttypes.h>
 #include <termios.h>
 #include <assert.h>
 #include <unistd.h>
@@ -37,25 +36,25 @@ struct console_device {
 
 	struct virt_queue		vqs[VIRTIO_CONSOLE_NUM_QUEUES];
 	struct virtio_console_config	console_config;
-	uint32_t			host_features;
-	uint32_t			guest_features;
-	uint16_t			config_vector;
-	uint8_t				status;
-	uint16_t			queue_selector;
+	u32				host_features;
+	u32				guest_features;
+	u16				config_vector;
+	u8				status;
+	u16				queue_selector;
 
-	void			*jobs[VIRTIO_CONSOLE_NUM_QUEUES];
+	void				*jobs[VIRTIO_CONSOLE_NUM_QUEUES];
 };
 
 static struct console_device console_device = {
-	.mutex			= PTHREAD_MUTEX_INITIALIZER,
+	.mutex				= PTHREAD_MUTEX_INITIALIZER,
 
 	.console_config = {
-		.cols		= 80,
-		.rows		= 24,
-		.max_nr_ports	= 1,
+		.cols			= 80,
+		.rows			= 24,
+		.max_nr_ports		= 1,
 	},
 
-	.host_features		= 0,
+	.host_features			= 0,
 };
 
 /*
@@ -65,8 +64,8 @@ static void virtio_console__inject_interrupt_callback(struct kvm *self, void *pa
 {
 	struct iovec iov[VIRTIO_CONSOLE_QUEUE_SIZE];
 	struct virt_queue *vq;
-	uint16_t out, in;
-	uint16_t head;
+	u16 out, in;
+	u16 head;
 	int len;
 
 	mutex_lock(&console_device.mutex);
@@ -88,9 +87,9 @@ void virtio_console__inject_interrupt(struct kvm *self)
 	thread_pool__do_job(console_device.jobs[VIRTIO_CONSOLE_RX_QUEUE]);
 }
 
-static bool virtio_console_pci_io_device_specific_in(void *data, unsigned long offset, int size, uint32_t count)
+static bool virtio_console_pci_io_device_specific_in(void *data, unsigned long offset, int size, u32 count)
 {
-	uint8_t *config_space = (uint8_t *) &console_device.console_config;
+	u8 *config_space = (u8 *) &console_device.console_config;
 
 	if (size != 1 || count != 1)
 		return false;
@@ -103,7 +102,7 @@ static bool virtio_console_pci_io_device_specific_in(void *data, unsigned long o
 	return true;
 }
 
-static bool virtio_console_pci_io_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool virtio_console_pci_io_in(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	unsigned long offset = port - IOPORT_VIRTIO_CONSOLE;
 	bool ret = true;
@@ -150,9 +149,9 @@ static void virtio_console_handle_callback(struct kvm *self, void *param)
 {
 	struct iovec iov[VIRTIO_CONSOLE_QUEUE_SIZE];
 	struct virt_queue *vq;
-	uint16_t out, in;
-	uint16_t head;
-	uint32_t len;
+	u16 out, in;
+	u16 head;
+	u32 len;
 
 	vq = param;
 
@@ -165,7 +164,7 @@ static void virtio_console_handle_callback(struct kvm *self, void *param)
 	kvm__irq_line(self, VIRTIO_CONSOLE_IRQ, 1);
 }
 
-static bool virtio_console_pci_io_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool virtio_console_pci_io_out(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	unsigned long offset = port - IOPORT_VIRTIO_CONSOLE;
 	bool ret = true;
@@ -201,7 +200,7 @@ static bool virtio_console_pci_io_out(struct kvm *self, uint16_t port, void *dat
 		console_device.queue_selector	= ioport__read16(data);
 		break;
 	case VIRTIO_PCI_QUEUE_NOTIFY: {
-		uint16_t queue_index;
+		u16 queue_index;
 		queue_index	= ioport__read16(data);
 		thread_pool__do_job(console_device.jobs[queue_index]);
 		break;
diff --git a/tools/kvm/virtio/core.c b/tools/kvm/virtio/core.c
index 4dcd092..dd7a3cf 100644
--- a/tools/kvm/virtio/core.c
+++ b/tools/kvm/virtio/core.c
@@ -1,5 +1,5 @@
 #include <linux/virtio_ring.h>
-#include <stdint.h>
+#include <linux/types.h>
 #include <sys/uio.h>
 
 #include "kvm/barrier.h"
@@ -7,7 +7,7 @@
 #include "kvm/kvm.h"
 #include "kvm/virtio.h"
 
-struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, uint32_t head, uint32_t len)
+struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, u32 head, u32 len)
 {
 	struct vring_used_elem *used_elem;
 	used_elem	= &queue->vring.used->ring[queue->vring.used->idx % queue->vring.num];
@@ -32,10 +32,10 @@ struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, uint
 	return used_elem;
 }
 
-uint16_t virt_queue__get_iov(struct virt_queue *queue, struct iovec iov[], uint16_t *out, uint16_t *in, struct kvm *kvm)
+u16 virt_queue__get_iov(struct virt_queue *queue, struct iovec iov[], u16 *out, u16 *in, struct kvm *kvm)
 {
 	struct vring_desc *desc;
-	uint16_t head, idx;
+	u16 head, idx;
 
 	idx = head = virt_queue__pop(queue);
 	*out = *in = 0;
diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c
index 3e13429..f0d24fa 100644
--- a/tools/kvm/virtio/net.c
+++ b/tools/kvm/virtio/net.c
@@ -34,11 +34,11 @@ struct net_device {
 
 	struct virt_queue		vqs[VIRTIO_NET_NUM_QUEUES];
 	struct virtio_net_config	net_config;
-	uint32_t			host_features;
-	uint32_t			guest_features;
-	uint16_t			config_vector;
-	uint8_t				status;
-	uint16_t			queue_selector;
+	u32				host_features;
+	u32				guest_features;
+	u16				config_vector;
+	u8				status;
+	u16				queue_selector;
 
 	pthread_t			io_rx_thread;
 	pthread_mutex_t			io_rx_mutex;
@@ -74,8 +74,8 @@ static void *virtio_net_rx_thread(void *p)
 	struct iovec iov[VIRTIO_NET_QUEUE_SIZE];
 	struct virt_queue *vq;
 	struct kvm *self;
-	uint16_t out, in;
-	uint16_t head;
+	u16 out, in;
+	u16 head;
 	int len;
 
 	self = p;
@@ -107,8 +107,8 @@ static void *virtio_net_tx_thread(void *p)
 	struct iovec iov[VIRTIO_NET_QUEUE_SIZE];
 	struct virt_queue *vq;
 	struct kvm *self;
-	uint16_t out, in;
-	uint16_t head;
+	u16 out, in;
+	u16 head;
 	int len;
 
 	self = p;
@@ -133,9 +133,9 @@ static void *virtio_net_tx_thread(void *p)
 	return NULL;
 
 }
-static bool virtio_net_pci_io_device_specific_in(void *data, unsigned long offset, int size, uint32_t count)
+static bool virtio_net_pci_io_device_specific_in(void *data, unsigned long offset, int size, u32 count)
 {
-	uint8_t *config_space = (uint8_t *) &net_device.net_config;
+	u8 *config_space = (u8 *) &net_device.net_config;
 
 	if (size != 1 || count != 1)
 		return false;
@@ -148,7 +148,7 @@ static bool virtio_net_pci_io_device_specific_in(void *data, unsigned long offse
 	return true;
 }
 
-static bool virtio_net_pci_io_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool virtio_net_pci_io_in(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	unsigned long offset = port - IOPORT_VIRTIO_NET;
 	bool ret = true;
@@ -191,7 +191,7 @@ static bool virtio_net_pci_io_in(struct kvm *self, uint16_t port, void *data, in
 	return ret;
 }
 
-static void virtio_net_handle_callback(struct kvm *self, uint16_t queue_index)
+static void virtio_net_handle_callback(struct kvm *self, u16 queue_index)
 {
 	if (queue_index == VIRTIO_NET_TX_QUEUE) {
 
@@ -208,7 +208,7 @@ static void virtio_net_handle_callback(struct kvm *self, uint16_t queue_index)
 	}
 }
 
-static bool virtio_net_pci_io_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+static bool virtio_net_pci_io_out(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
 	unsigned long offset = port - IOPORT_VIRTIO_NET;
 	bool ret = true;
@@ -237,7 +237,7 @@ static bool virtio_net_pci_io_out(struct kvm *self, uint16_t port, void *data, i
 		net_device.queue_selector	= ioport__read16(data);
 		break;
 	case VIRTIO_PCI_QUEUE_NOTIFY: {
-		uint16_t queue_index;
+		u16 queue_index;
 		queue_index	= ioport__read16(data);
 		virtio_net_handle_callback(self, queue_index);
 		break;
diff --git a/tools/kvm/virtio/rng.c b/tools/kvm/virtio/rng.c
index 6dab92e..65fa48d 100644
--- a/tools/kvm/virtio/rng.c
+++ b/tools/kvm/virtio/rng.c
@@ -17,7 +17,6 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <inttypes.h>
 #include <pthread.h>
 
 #define PCI_VENDOR_ID_REDHAT_QUMRANET			0x1af4
@@ -34,19 +33,19 @@
 #define VIRTIO_RNG_QUEUE_SIZE	128
 
 struct rng_device {
-	uint8_t				status;
-	uint16_t			config_vector;
+	u8				status;
+	u16			config_vector;
 	int					fd_rng;
 
 	/* virtio queue */
-	uint16_t			queue_selector;
+	u16			queue_selector;
 	struct virt_queue	vqs[NUM_VIRT_QUEUES];
 	void				*jobs[NUM_VIRT_QUEUES];
 };
 
 static struct rng_device rng_device;
 
-static bool virtio_rng_pci_io_in(struct kvm *kvm, uint16_t port, void *data, int size, uint32_t count)
+static bool virtio_rng_pci_io_in(struct kvm *kvm, u16 port, void *data, int size, u32 count)
 {
 	unsigned long offset;
 	bool ret = true;
@@ -86,7 +85,7 @@ static bool virtio_rng_pci_io_in(struct kvm *kvm, uint16_t port, void *data, int
 static bool virtio_rng_do_io_request(struct kvm *self, struct virt_queue *queue)
 {
 	struct iovec iov[VIRTIO_RNG_QUEUE_SIZE];
-	uint16_t out, in, head;
+	u16 out, in, head;
 	unsigned int len = 0;
 
 	head = virt_queue__get_iov(queue, iov, &out, &in, self);
@@ -106,7 +105,7 @@ static void virtio_rng_do_io(struct kvm *kvm, void *param)
 	}
 }
 
-static bool virtio_rng_pci_io_out(struct kvm *kvm, uint16_t port, void *data, int size, uint32_t count)
+static bool virtio_rng_pci_io_out(struct kvm *kvm, u16 port, void *data, int size, u32 count)
 {
 	unsigned long offset;
 	bool ret = true;
@@ -136,7 +135,7 @@ static bool virtio_rng_pci_io_out(struct kvm *kvm, uint16_t port, void *data, in
 		rng_device.queue_selector	= ioport__read16(data);
 		break;
 	case VIRTIO_PCI_QUEUE_NOTIFY: {
-		uint16_t queue_index;
+		u16 queue_index;
 		queue_index		= ioport__read16(data);
 		thread_pool__do_job(rng_device.jobs[queue_index]);
 		break;
-- 
1.7.5.rc3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux