Re: [kvm-ppc-devel] [PATCH 01 of 19] Move kvm_context to kvmctl.h

Jerone Young
2007-11-02T19:48:06Z

I'll wait awhile before sending another super patch bomb to the list.
Perhaps I can add these changes afterward if need be.

Actually do need the conf-*.mak changes. Otherwise if you compile libkvm
on it's own you don't get the CFLAGS. Now the way it really should be is
that those config-*.mak files shouldn't be there and the ones used
should be those in the "user" directory. I was planning to send a patch
for this after these patches got in.

On Fri, 2007-11-02 at 14:34 -0500, Hollis Blanchard wrote:
> * Remove the config-*.mak changes
> * Update the patch description
> * Supply a copyright notice in all new files
>
> --
> Hollis Blanchard
> IBM Linux Technology Center
>
> On Fri, 2007-11-02 at 13:24 -0500, Jerone Young wrote:
> > # HG changeset patch
> > # User Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> > # Date 1194027872 18000
> > # Node ID 72c2d9f9786aea122419208189291808d56b8053
> > # 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,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
> > --- /dev/null
> > +++ b/libkvm/kvm-common.h
> > @@ -0,0 +1,37 @@
> > +#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
> > --- /dev/null
> > +++ b/libkvm/kvm-x86.h
> > @@ -0,0 +1,14 @@
> > +/* 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
> > +
> > +#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
> > --- a/libkvm/libkvm.c
> > +++ b/libkvm/libkvm.c
> > @@ -37,43 +37,14 @@
> > #include "libkvm.h"
> > #include "kvm-abi-10.h"
> >
> > +#if defined(__x86_64__) || defined(__i386__)
> > +#include "kvm-x86.h"
> > +#endif
> > +
> > 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/
> > _______________________________________________
> > kvm-ppc-devel mailing list
> > kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> > https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel
>
>
> -------------------------------------------------------------------------
> 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-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/kvm-devel