From: Ferrol Aderholdt Date: Fri, 22 Jun 2012 18:45:15 +0000 (-0500) Subject: /proc info showing vm device and vm name mapping, and memory use X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=a3534432fa8e7a9fe4730c151ca52350ca0a2faf;p=palacios.releases.git /proc info showing vm device and vm name mapping, and memory use --- diff --git a/linux_module/main.c b/linux_module/main.c index 57fe2ef..b7fecea 100644 --- a/linux_module/main.c +++ b/linux_module/main.c @@ -19,6 +19,8 @@ #include #include +#include + #include "palacios.h" #include "mm.h" #include "vm.h" @@ -42,6 +44,7 @@ int mod_frees = 0; static int v3_major_num = 0; static struct v3_guest * guest_map[MAX_VMS] = {[0 ... MAX_VMS - 1] = 0}; +static struct proc_dir_entry *dir; struct class * v3_class = NULL; static struct cdev ctrl_dev; @@ -171,6 +174,37 @@ static struct file_operations v3_ctrl_fops = { +static int read_guests(char * buf, char ** start, off_t off, int count, + int * eof, void * data) +{ + int len = 0; + unsigned int i = 0; + + for(i = 0; i < MAX_VMS; i++) { + if (guest_map[i] != NULL) { + if (lenname, i); + } + } + } + + return len; +} + +static int show_mem(char * buf, char ** start, off_t off, int count, + int * eof, void * data) +{ + int len = 0; + + len = snprintf(buf,count, "%p\n", (void *)get_palacios_base_addr()); + len += snprintf(buf+len,count-len, "%lld\n", get_palacios_num_pages()); + + return len; +} + + static int __init v3_init(void) { dev_t dev = MKDEV(0, 0); // We dynamicallly assign the major number int ret = 0; @@ -219,8 +253,32 @@ static int __init v3_init(void) { goto failure1; } - - + dir = proc_mkdir("v3vee", NULL); + if(dir) { + struct proc_dir_entry *entry; + + entry = create_proc_read_entry("v3-guests", 0444, dir, + read_guests, NULL); + if (entry) { + INFO("/proc/v3vee/v3-guests successfully created\n"); + } else { + ERROR("Could not create proc entry\n"); + goto failure1; + } + + entry = create_proc_read_entry("v3-mem", 0444, dir, + show_mem, NULL); + if (entry) { + INFO("/proc/v3vee/v3-mem successfully added\n"); + } else { + ERROR("Could not create proc entry\n"); + goto failure1; + } + } else { + ERROR("Could not create proc entry\n"); + goto failure1; + } + return 0; failure1: @@ -265,6 +323,10 @@ static void __exit v3_exit(void) { palacios_deinit_mm(); + remove_proc_entry("v3-guests", dir); + remove_proc_entry("v3-mem", dir); + remove_proc_entry("v3vee", NULL); + DEBUG("Palacios Module Mallocs = %d, Frees = %d\n", mod_allocs, mod_frees); } diff --git a/linux_module/mm.c b/linux_module/mm.c index ef6e1bd..bb8919a 100644 --- a/linux_module/mm.c +++ b/linux_module/mm.c @@ -43,6 +43,14 @@ static inline void clear_page_bit(int index) { } +uintptr_t get_palacios_base_addr(void) { + return pool.base_addr; +} + +u64 get_palacios_num_pages(void) { + return pool.num_pages; +} + static uintptr_t alloc_contig_pgs(u64 num_pages, u32 alignment) { int step = 1; diff --git a/linux_module/mm.h b/linux_module/mm.h index abc8857..dfe5d55 100644 --- a/linux_module/mm.h +++ b/linux_module/mm.h @@ -11,6 +11,9 @@ uintptr_t alloc_palacios_pgs(u64 num_pages, u32 alignment); void free_palacios_pg(uintptr_t base_addr); void free_palacios_pgs(uintptr_t base_addr, u64 num_pages); +uintptr_t get_palacios_base_addr(void); +u64 get_palacios_num_pages(void); + int add_palacios_memory(uintptr_t base_addr, u64 num_pages); int remove_palacios_memory(uintptr_t base_addr, u64 num_pages);