summaryrefslogtreecommitdiff
path: root/libkvm
diff options
context:
space:
mode:
Diffstat (limited to 'libkvm')
-rw-r--r--libkvm/config-i386.mak2
-rw-r--r--libkvm/config-x86_64.mak2
-rw-r--r--libkvm/kvm-common.h52
-rw-r--r--libkvm/kvm-x86.h26
-rw-r--r--libkvm/libkvm.c37
-rw-r--r--libkvm/libkvm.h2
6 files changed, 87 insertions, 34 deletions
diff --git a/libkvm/config-i386.mak b/libkvm/config-i386.mak
index 02e00185..0ce10347 100644
--- a/libkvm/config-i386.mak
+++ b/libkvm/config-i386.mak
@@ -1,2 +1,4 @@
LIBDIR := /lib
+CFLAGS += -m32
+CFLAGS += -D__i386__
diff --git a/libkvm/config-x86_64.mak b/libkvm/config-x86_64.mak
index 485cda0e..0de73ca2 100644
--- a/libkvm/config-x86_64.mak
+++ b/libkvm/config-x86_64.mak
@@ -1,2 +1,4 @@
LIBDIR := /lib64
+CFLAGS += -m64
+CFLAGS += -D__x86_64__
diff --git a/libkvm/kvm-common.h b/libkvm/kvm-common.h
new file mode 100644
index 00000000..35e311a5
--- /dev/null
+++ b/libkvm/kvm-common.h
@@ -0,0 +1,52 @@
+/*
+ * This header is for functions & variables that will ONLY be
+ * used inside libkvm.
+ *
+ * derived from libkvm.c
+ *
+ * Copyright (C) 2006 Qumranet, Inc.
+ *
+ * Authors:
+ * Avi Kivity <avi@qumranet.com>
+ * Yaniv Kamay <yaniv@qumranet.com>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ */
+
+#ifndef KVM_COMMON_H
+#define KVM_COMMON_H
+
+/* FIXME: share this number with kvm */
+/* FIXME: or dynamically alloc/realloc regions */
+#define KVM_MAX_NUM_MEM_REGIONS 8u
+#define MAX_VCPUS 4
+
+
+/**
+ * \brief The KVM context
+ *
+ * The verbose KVM context
+ */
+
+struct kvm_context {
+ /// Filedescriptor to /dev/kvm
+ int fd;
+ int vm_fd;
+ int vcpu_fd[MAX_VCPUS];
+ struct kvm_run *run[MAX_VCPUS];
+ /// Callbacks that KVM uses to emulate various unvirtualizable functionality
+ struct kvm_callbacks *callbacks;
+ void *opaque;
+ /// A pointer to the memory used as the physical memory for the guest
+ void *physical_memory;
+ /// is dirty pages logging enabled for all regions or not
+ int dirty_pages_log_all;
+ /// memory regions parameters
+ struct kvm_memory_region mem_regions[KVM_MAX_NUM_MEM_REGIONS];
+ /// do not create in-kernel irqchip if set
+ int no_irqchip_creation;
+ /// in-kernel irqchip status
+ int irqchip_in_kernel;
+};
+
+#endif
diff --git a/libkvm/kvm-x86.h b/libkvm/kvm-x86.h
new file mode 100644
index 00000000..9e74cbd7
--- /dev/null
+++ b/libkvm/kvm-x86.h
@@ -0,0 +1,26 @@
+/*
+ * This header is for functions & variables that will ONLY be
+ * used inside libkvm for x86.
+ * THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE
+ * WITHIN LIBKVM.
+ *
+ * derived from libkvm.c
+ *
+ * Copyright (C) 2006 Qumranet, Inc.
+ *
+ * Authors:
+ * Avi Kivity <avi@qumranet.com>
+ * Yaniv Kamay <yaniv@qumranet.com>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ */
+
+#ifndef KVM_X86_H
+#define KVM_X86_H
+
+#include "kvm-common.h"
+
+#define PAGE_SIZE 4096ul
+#define PAGE_MASK (~(PAGE_SIZE - 1))
+
+#endif
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index 17aaf506..96659dda 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -37,43 +37,14 @@
#include "libkvm.h"
#include "kvm-abi-10.h"
-static int kvm_abi = EXPECTED_KVM_API_VERSION;
+#if defined(__x86_64__) || defined(__i386__)
+#include "kvm-x86.h"
+#endif
-#define PAGE_SIZE 4096ul
-#define PAGE_MASK (~(PAGE_SIZE - 1))
+static int kvm_abi = EXPECTED_KVM_API_VERSION;
-/* FIXME: share this number with kvm */
-/* FIXME: or dynamically alloc/realloc regions */
-#define KVM_MAX_NUM_MEM_REGIONS 8u
int free_slots[KVM_MAX_NUM_MEM_REGIONS];
unsigned long phys_addr_slots[KVM_MAX_NUM_MEM_REGIONS];
-#define MAX_VCPUS 4
-
-/**
- * \brief The KVM context
- *
- * The verbose KVM context
- */
-struct kvm_context {
- /// Filedescriptor to /dev/kvm
- int fd;
- int vm_fd;
- int vcpu_fd[MAX_VCPUS];
- struct kvm_run *run[MAX_VCPUS];
- /// Callbacks that KVM uses to emulate various unvirtualizable functionality
- struct kvm_callbacks *callbacks;
- void *opaque;
- /// A pointer to the memory used as the physical memory for the guest
- void *physical_memory;
- /// is dirty pages logging enabled for all regions or not
- int dirty_pages_log_all;
- /// memory regions parameters
- struct kvm_memory_region mem_regions[KVM_MAX_NUM_MEM_REGIONS];
- /// do not create in-kernel irqchip if set
- int no_irqchip_creation;
- /// in-kernel irqchip status
- int irqchip_in_kernel;
-};
static void init_slots()
{
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index 6b3499e2..18728266 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -1,4 +1,4 @@
-/** \file kvmctl.h
+/** \file libkvm.h
* libkvm API
*/