X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fmain.c;h=df1c98c9dadb609c325ee3305f7c76861bcf9da5;hb=8f7141b61d0c58befc5433a22d9af728fe3bb6f9;hp=57fe2ef219d8c3758c3d2a67e100d6416b734343;hpb=791ea2f3e21cfbc9c47341efbb98995c33d86fcb;p=palacios.git diff --git a/linux_module/main.c b/linux_module/main.c index 57fe2ef..df1c98c 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 = 0; struct class * v3_class = NULL; static struct cdev ctrl_dev; @@ -171,6 +174,42 @@ static struct file_operations v3_ctrl_fops = { +struct proc_dir_entry *palacios_get_procdir(void) +{ + return dir; +} + +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 +258,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 +328,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); }