[PATCH 02 of 19] Make static slot & kvm_memory region funcions public

Jerone Young
2007-11-02T18:24:51Z

# Date 1194027872 18000
# Node ID 17bf778405bb2aea7eab2e4625f913941efeab1c
# Parent 72c2d9f9786aea122419208189291808d56b8053
Make static slot & kvm_memory region funcions public

This patch changes static functions for manipulation of memory slots
and regions public in kvmctl.c. This also makes a decleration for these
functions in kvmctl.h.

This allow for breaking out code into other files and still keep this
functionality. These functions can later be broken up some to
move there x86 specific stuff (ex. TSS).

Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

diff --git a/libkvm/kvm-x86.h b/libkvm/kvm-x86.h
--- a/libkvm/kvm-x86.h
+++ b/libkvm/kvm-x86.h
@@ -11,4 +11,14 @@
#define PAGE_SIZE 4096ul
#define PAGE_MASK (~(PAGE_SIZE - 1))

+void init_slots();
+int get_free_slot(kvm_context_t kvm);
+void register_slot(int slot, unsigned long phys_addr);
+int get_slot(unsigned long phys_addr);
+void kvm_memory_region_save_params(kvm_context_t kvm,
+ struct kvm_memory_region *mem);
+void kvm_userspace_memory_region_save_params(kvm_context_t kvm,
+ struct kvm_userspace_memory_region *mem);
+void kvm_memory_region_clear_params(kvm_context_t kvm, int regnum);
+
#endif
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -46,7 +46,7 @@ int free_slots[KVM_MAX_NUM_MEM_REGIONS];
int free_slots[KVM_MAX_NUM_MEM_REGIONS];
unsigned long phys_addr_slots[KVM_MAX_NUM_MEM_REGIONS];

-static void init_slots()
+void init_slots()
{
int i;

@@ -54,7 +54,7 @@ static void init_slots()
free_slots[i] = 0;
}

-static int get_free_slot(kvm_context_t kvm)
+int get_free_slot(kvm_context_t kvm)
{
int i;
int tss_ext;
@@ -81,13 +81,13 @@ static int get_free_slot(kvm_context_t k
return -1;
}

-static void register_slot(int slot, unsigned long phys_addr)
+void register_slot(int slot, unsigned long phys_addr)
{
free_slots[slot] = 1;
phys_addr_slots[slot] = phys_addr;
}

-static int get_slot(unsigned long phys_addr)
+int get_slot(unsigned long phys_addr)
{
int i;

@@ -100,7 +100,7 @@ static int get_slot(unsigned long phys_a
/*
* memory regions parameters
*/
-static void kvm_memory_region_save_params(kvm_context_t kvm,
+void kvm_memory_region_save_params(kvm_context_t kvm,
struct kvm_memory_region *mem)
{
if (!mem || (mem->slot >= KVM_MAX_NUM_MEM_REGIONS)) {
@@ -112,7 +112,7 @@ static void kvm_memory_region_save_param

#ifdef KVM_CAP_USER_MEMORY

-static void kvm_userspace_memory_region_save_params(kvm_context_t kvm,
+void kvm_userspace_memory_region_save_params(kvm_context_t kvm,
struct kvm_userspace_memory_region *mem)
{
struct kvm_memory_region kvm_mem;
@@ -126,7 +126,7 @@ static void kvm_userspace_memory_region_

#endif

-static void kvm_memory_region_clear_params(kvm_context_t kvm, int regnum)
+void kvm_memory_region_clear_params(kvm_context_t kvm, int regnum)
{
if (regnum >= KVM_MAX_NUM_MEM_REGIONS) {
fprintf(stderr, "BUG: %s: invalid parameters\n", __FUNCTION__);