From: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [PATCH 01 of 20] Move kvm_context to kvmctl.h
Date: Fri, 02 Nov 2007 05:36:37 -0500 [thread overview]
Message-ID: <5900e2b0ebdee721ae65.1193999797@thinkpad> (raw)
In-Reply-To: <patchbomb.1193999796@thinkpad>
# HG changeset patch
# User Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1193996153 18000
# Node ID 5900e2b0ebdee721ae651070fcd325363691e25a
# Parent 6ce27ddeb45df182e923060ae3abe699ce704ca3
Move kvm_context to kvmctl.h
This patch moves kvm_context from libkvm.c to kvm-context.h. This is so
other files are able to see members of kvm_context. Also you should
allways declare stuff like this in a header anyway. Also moved are
delcrations MAX_VCPU, KVM_MAX_NUM_MEM_REGIONS, PAGE_SIZE & PAGE_MASK
to kvm-x86.h.
The idea here is kvm-$(ARCH).h will be headers for interal use by
libkvm. Headers name libkvm-$(ARCH) will be functions that are
arch specific that will be exposed to a user.
Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
diff --git a/libkvm/config-i386.mak b/libkvm/config-i386.mak
--- 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
--- a/libkvm/config-x86_64.mak
+++ b/libkvm/config-x86_64.mak
@@ -1,2 +1,5 @@
LIBDIR := /lib64
+CFLAGS += -m64
+CFLAGS += -D__x86_64__
+
diff --git a/libkvm/kvm-context.h b/libkvm/kvm-context.h
new file mode 100644
--- /dev/null
+++ b/libkvm/kvm-context.h
@@ -0,0 +1,31 @@
+#ifndef KVM_CONTEXT_H
+#define KVM_CONTEXT_H
+
+/**
+ * \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
--- /dev/null
+++ b/libkvm/kvm-x86.h
@@ -0,0 +1,17 @@
+/* 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.
+ */
+#ifndef KVM_X86_H
+#define KVM_X86_H
+
+/* FIXME: share this number with kvm */
+/* FIXME: or dynamically alloc/realloc regions */
+#define KVM_MAX_NUM_MEM_REGIONS 8u
+#define MAX_VCPUS 4
+
+#define PAGE_SIZE 4096ul
+#define PAGE_MASK (~(PAGE_SIZE - 1))
+
+#endif
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -37,43 +37,16 @@
#include "libkvm.h"
#include "kvm-abi-10.h"
+#if defined(__x86_64__) || defined(__i386__)
+#include "kvm-x86.h"
+#endif
+
+#include "kvm-context.h"
+
static int kvm_abi = EXPECTED_KVM_API_VERSION;
-#define PAGE_SIZE 4096ul
-#define PAGE_MASK (~(PAGE_SIZE - 1))
-
-/* 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
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -1,4 +1,4 @@
-/** \file kvmctl.h
+/** \file libkvm.h
* libkvm API
*/
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
next prev parent reply other threads:[~2007-11-02 10:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-02 10:36 [PATCH 00 of 20] [RESEND] Refactor libkvm code Phase 1 Jerone Young
2007-11-02 10:36 ` Jerone Young [this message]
2007-11-02 17:28 ` [kvm-ppc-devel] [PATCH 01 of 20] Move kvm_context to kvmctl.h Hollis Blanchard
2007-11-02 17:42 ` Jerone Young
2007-11-02 10:36 ` [PATCH 02 of 20] Make static slot & kvm_memory region funcions public Jerone Young
2007-11-02 10:36 ` [PATCH 03 of 20] Move fuction kvm_alloc_kernel_memory to libkvm-x86.c Jerone Young
2007-11-02 10:36 ` [PATCH 04 of 20] Move kvm_alloc_userspace_memory " Jerone Young
2007-11-02 10:36 ` [PATCH 05 of 20] Modify out arch specific code from kvm_create function Jerone Young
2007-11-02 10:36 ` [PATCH 06 of 20] Move kvm_create_kernel_phys_mem to libkvm-x86.c Jerone Young
2007-11-02 10:36 ` [PATCH 07 of 20] Move kvm_create_phys_mem " Jerone Young
2007-11-02 10:36 ` [PATCH 08 of 20] Move kvm_destroy_phys_mem " Jerone Young
2007-11-02 10:36 ` [PATCH 09 of 20] Move kvm_create_memory_alias & kvm_destroy_memory_alias " Jerone Young
2007-11-02 10:36 ` [PATCH 10 of 20] Move kvm_get & kmv_set_lapci functions " Jerone Young
2007-11-02 10:36 ` [PATCH 11 of 20] Make functions in libkvm.c nonstatic Jerone Young
2007-11-02 10:36 ` [PATCH 12 of 20] Move abi 10 functions to libkvm-x86.c Jerone Young
2007-11-02 10:36 ` [PATCH 13 of 20] Move msrs " Jerone Young
2007-11-02 10:36 ` [PATCH 14 of 20] Move print_seg & Move kvm_show_regs to kvmctl-x86.c Jerone Young
2007-11-02 10:36 ` [PATCH 15 of 20] Declare kvm_abi as a global variable in libkvm.h Jerone Young
2007-11-02 10:36 ` [PATCH 16 of 20] Move kvm_get_apic to libkvm-x86.c Jerone Young
2007-11-02 10:36 ` [PATCH 17 of 20] Move cr8 functions " Jerone Young
2007-11-02 10:36 ` [PATCH 18 of 20] Move kvm_setup_cpuid " Jerone Young
2007-11-02 10:36 ` [PATCH 19 of 20] Move kvm_show_code " Jerone Young
2007-11-02 10:36 ` [PATCH 20 of 20] Remove unsued inclusion of linux/kvm_parah.h in userspace libkvm.h Jerone Young
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=5900e2b0ebdee721ae65.1193999797@thinkpad \
--to=jyoung5-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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