Hacks to build kvmtool on Android
diff --git a/kvmtool/include/kvm/virtio.h b/kvmtool/include/kvm/virtio.h
index 3a311f5..a3f87f7 100644
--- a/kvmtool/include/kvm/virtio.h
+++ b/kvmtool/include/kvm/virtio.h
@@ -114,6 +114,17 @@
 
 #endif
 
+static inline void vring_init(struct vring * vr, unsigned int num, void * p, unsigned long align) {
+  vr->num = num;
+  vr->desc = p;
+  vr->avail = p + num * sizeof(struct vring_desc);
+  vr->used = (void *) (((uintptr_t) & vr->avail->ring[num] + sizeof(__virtio16) + align - 1) & ~(align - 1));
+}
+
+static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old) {
+  return(__u16) (new_idx - event_idx - 1) < (__u16) (new_idx - old);
+}
+
 static inline u16 virt_queue__pop(struct virt_queue *queue)
 {
 	__u16 guest_idx;
diff --git a/kvmtool/include/linux/9p.h b/kvmtool/include/linux/9p.h
index c7cfd8e..1c70fac 100644
--- a/kvmtool/include/linux/9p.h
+++ b/kvmtool/include/linux/9p.h
@@ -447,11 +447,11 @@
 	u64 st_blksize;
 	u64 st_blocks;
 	u64 st_atime_sec;
-	u64 st_atime_nsec;
+	u64 st_atime_nsec_;
 	u64 st_mtime_sec;
-	u64 st_mtime_nsec;
+	u64 st_mtime_nsec_;
 	u64 st_ctime_sec;
-	u64 st_ctime_nsec;
+	u64 st_ctime_nsec_;
 	u64 st_btime_sec;
 	u64 st_btime_nsec;
 	u64 st_gen;
diff --git a/kvmtool/include/linux/compiler.h b/kvmtool/include/linux/compiler.h
index a662ba0..27e8d1f 100644
--- a/kvmtool/include/linux/compiler.h
+++ b/kvmtool/include/linux/compiler.h
@@ -10,8 +10,14 @@
 #define __attribute_const__
 #endif
 
+#ifndef __used
 #define __used		__attribute__((__unused__))
+#endif
+
+#ifndef __packed
 #define __packed	__attribute__((packed))
+#endif
+
 #define __iomem
 #define __force
 #define __must_check	__attribute__((warn_unused_result))
diff --git a/kvmtool/include/linux/types.h b/kvmtool/include/linux/types.h
index 5e20f10..56b3fff 100644
--- a/kvmtool/include/linux/types.h
+++ b/kvmtool/include/linux/types.h
@@ -28,7 +28,6 @@
 #define __bitwise
 #endif
 
-
 typedef __u16 __bitwise __le16;
 typedef __u16 __bitwise __be16;
 typedef __u32 __bitwise __le32;
@@ -36,6 +35,12 @@
 typedef __u64 __bitwise __le64;
 typedef __u64 __bitwise __be64;
 
+#define __aligned_u64 __u64 __attribute__((aligned(8)))
+#define __aligned_be64 __be64 __attribute__((aligned(8)))
+#define __aligned_le64 __le64 __attribute__((aligned(8)))
+
+typedef unsigned __bitwise __poll_t;
+
 struct list_head {
 	struct list_head *next, *prev;
 };
@@ -48,4 +53,8 @@
 	struct hlist_node *next, **pprev;
 };
 
+
+
+#define pthread_cancel(X) pthread_kill((X), 0)
+
 #endif /* LINUX_TYPES_H */
diff --git a/kvmtool/virtio/9p-pdu.c b/kvmtool/virtio/9p-pdu.c
index c0b95e0..c7012bb 100644
--- a/kvmtool/virtio/9p-pdu.c
+++ b/kvmtool/virtio/9p-pdu.c
@@ -245,11 +245,11 @@
 						       stbuf->st_blksize,
 						       stbuf->st_blocks,
 						       stbuf->st_atime_sec,
-						       stbuf->st_atime_nsec,
+						       stbuf->st_atime_nsec_,
 						       stbuf->st_mtime_sec,
-						       stbuf->st_mtime_nsec,
+						       stbuf->st_mtime_nsec_,
 						       stbuf->st_ctime_sec,
-						       stbuf->st_ctime_nsec,
+						       stbuf->st_ctime_nsec_,
 						       stbuf->st_btime_sec,
 						       stbuf->st_btime_nsec,
 						       stbuf->st_gen,
diff --git a/kvmtool/virtio/9p.c b/kvmtool/virtio/9p.c
index b78f2b3..afd6571 100644
--- a/kvmtool/virtio/9p.c
+++ b/kvmtool/virtio/9p.c
@@ -553,11 +553,11 @@
 	statl->st_blksize	= st->st_blksize;
 	statl->st_blocks	= st->st_blocks;
 	statl->st_atime_sec	= st->st_atime;
-	statl->st_atime_nsec	= st->st_atim.tv_nsec;
+	statl->st_atime_nsec_	= st->st_atim.tv_nsec;
 	statl->st_mtime_sec	= st->st_mtime;
-	statl->st_mtime_nsec	= st->st_mtim.tv_nsec;
+	statl->st_mtime_nsec_	= st->st_mtim.tv_nsec;
 	statl->st_ctime_sec	= st->st_ctime;
-	statl->st_ctime_nsec	= st->st_ctim.tv_nsec;
+	statl->st_ctime_nsec_	= st->st_ctim.tv_nsec;
 	/* Currently we only support BASIC fields in stat */
 	statl->st_result_mask	= P9_STATS_BASIC;
 	stat2qid(st, &statl->qid);