# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1193849563 18000 # Node ID 19a7c6d2ddfd1383aeb8a9bc09d9fe0673e7f9cc # Parent c3d6e1e2b8a0368485badcde0e55a82d9b1897d1 Move kvm_context to kvmctl.h
This patch moves kvm_context from kvmctl.c to kvmctl.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 to kvmctl-x86.h. As these are closely associated with the architecture. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/libkvm/Makefile b/libkvm/Makefile --- a/libkvm/Makefile +++ b/libkvm/Makefile @@ -21,7 +21,7 @@ autodepend-flags = -MMD -MF $(dir $*).$( all: libkvm.a -libkvm.a: libkvm.o +libkvm.a: libkvm.o $(libkvm-$(ARCH)-objs) $(AR) rcs $@ $^ install: 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,3 @@ +libkvm-$(ARCH)-objs := libkvm-x86.o LIBDIR := /lib diff --git a/libkvm/libkvm-x86.h b/libkvm/libkvm-x86.h new file mode 100644 --- /dev/null +++ b/libkvm/libkvm-x86.h @@ -0,0 +1,7 @@ +#ifndef KVMCTL_X86_H +#define KVMCTL_X86_H + +#define KVM_MAX_NUM_MEM_REGIONS 8u +#define MAX_VCPUS 4 + +#endif diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c --- a/libkvm/libkvm.c +++ b/libkvm/libkvm.c @@ -44,36 +44,8 @@ static int kvm_abi = EXPECTED_KVM_API_VE /* 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 */ @@ -26,6 +26,40 @@ struct kvm_context; struct kvm_context; typedef struct kvm_context *kvm_context_t; + +/* Add info from arch specific header */ +#if defined(__x86_64__) || defined(__i386__) +#include "libkvm-x86.h" +#endif + + +/** + * \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; +}; + /*! * \brief KVM callbacks structure ------------------------------------------------------------------------- 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/ _______________________________________________ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel