Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Updates to linux module to use linux print macros
Ben Scholbrock [Tue, 19 Jun 2012 20:46:39 +0000 (15:46 -0500)]
21 files changed:
linux_module/iface-code-inject.c
linux_module/iface-console.c
linux_module/iface-env-inject.c
linux_module/iface-file.c
linux_module/iface-graphics-console.c
linux_module/iface-host-dev.c
linux_module/iface-host-hypercall.c
linux_module/iface-keyed-stream.c
linux_module/iface-packet.c
linux_module/iface-socket.c
linux_module/iface-stream.c
linux_module/iface-syscall.c
linux_module/inspector.c
linux_module/linux-exts.c
linux_module/main.c
linux_module/mm.c
linux_module/palacios-stubs.c
linux_module/palacios-vnet-brg.c
linux_module/palacios-vnet-ctrl.c
linux_module/palacios-vnet.c
linux_module/vm.c

index ff63326..d0b5495 100644 (file)
@@ -57,14 +57,14 @@ static int vm_tophalf_inject (struct v3_guest * guest, unsigned int cmd, unsigne
 
     top = kmalloc(sizeof(struct top_half_data), GFP_KERNEL);
     if (IS_ERR(top)) {
-        printk("Palacios Error: could not allocate space for top half data\n");
+        ERROR("Palacios Error: could not allocate space for top half data\n");
         return -EFAULT;
     }
     memset(top, 0, sizeof(struct top_half_data));
     
-    printk("Palacios: Loading ELF data...\n");
+    INFO("Palacios: Loading ELF data...\n");
     if (copy_from_user(&top_arg, (void __user *)arg, sizeof(struct top_half_data))) {
-        printk("palacios: error copying ELF from userspace\n");
+        ERROR("palacios: error copying ELF from userspace\n");
         return -EFAULT;
     }
 
@@ -76,34 +76,34 @@ static int vm_tophalf_inject (struct v3_guest * guest, unsigned int cmd, unsigne
     if (top_arg.is_exec_hooked) {
         strcpy(top->bin_file, top_arg.bin_file);
         top->is_exec_hooked = 1;
-        printk("top->bin_file is %s\n", top->bin_file);
+        DEBUG("top->bin_file is %s\n", top->bin_file);
     } 
 
-    printk("Palacios: Allocating %lu B of kernel memory for ELF binary data...\n", top->elf_size);
+    DEBUG("Palacios: Allocating %lu B of kernel memory for ELF binary data...\n", top->elf_size);
     top->elf_data = kmalloc(top->elf_size, GFP_KERNEL);
     if (IS_ERR(top->elf_data)) {
-        printk("Palacios Error: could not allocate space for binary image\n");
+        ERROR("Palacios Error: could not allocate space for binary image\n");
         return -EFAULT;
     }
     memset(top->elf_data, 0, top->elf_size);
 
-    printk("Palacios: Copying ELF image into kernel module...\n");
+    INFO("Palacios: Copying ELF image into kernel module...\n");
     if (copy_from_user(top->elf_data, (void __user *)top_arg.elf_data, top->elf_size)) {
-        printk("Palacios: Error loading elf data\n");
+        ERROR("Palacios: Error loading elf data\n");
         return -EFAULT;
     }
 
     if (register_top(top) < 0) 
         return -1;
     
-    printk("Palacios: setting up inject code...\n");
+    INFO("Palacios: setting up inject code...\n");
     if (v3_insert_code_inject(guest->v3_ctx, top->elf_data, top->elf_size, 
                          top->bin_file, top->is_dyn, top->is_exec_hooked, top->func_offset) < 0) {
-        printk("Palacios Error: error setting up inject code\n");
+        ERROR("Palacios Error: error setting up inject code\n");
         return -1;
     }
 
-    printk("Palacios: injection registration complete\n");
+    INFO("Palacios: injection registration complete\n");
     return 0;
 }
 
index ab66d5a..c28fd4c 100644 (file)
@@ -96,19 +96,19 @@ console_read(struct file * filp, char __user * buf, size_t size, loff_t * offset
 
 
     if (size < sizeof(struct cons_msg)) {
-       printk("Invalid Read operation size: %lu\n", size);
+       ERROR("Invalid Read operation size: %lu\n", size);
        return -EFAULT;
     }
     
     msg = dequeue(cons->queue);
     
     if (msg == NULL) {
-       printk("ERROR: Null console message\n");
+       ERROR("ERROR: Null console message\n");
        return -EFAULT;
     }
     
     if (copy_to_user(buf, msg, size)) {
-       printk("Read Fault\n");
+       ERROR("Read Fault\n");
        return -EFAULT;
     }
 
@@ -123,7 +123,7 @@ console_read(struct file * filp, char __user * buf, size_t size, loff_t * offset
        wake_up_interruptible(&(cons->intr_queue));
     }
 
-    //    printk("Read from console\n");
+    //    DEBUG("Read from console\n");
     return size;
 }
 
@@ -141,7 +141,7 @@ console_write(struct file * filp, const char __user * buf, size_t size, loff_t *
 
     for (i = 0; i < size; i++) {
        if (copy_from_user(&(event.scan_code), buf + i, 1)) {
-           printk("Console Write fault\n");
+           ERROR("Console Write fault\n");
            return -EFAULT;
        }
 
@@ -158,7 +158,7 @@ console_poll(struct file * filp, struct poll_table_struct * poll_tb) {
     unsigned long flags;
     int entries = 0;
 
-    //    printk("Console=%p (guest=%s)\n", cons, cons->guest->name);
+    //    DEBUG("Console=%p (guest=%s)\n", cons, cons->guest->name);
 
 
     poll_wait(filp, &(cons->intr_queue), poll_tb);
@@ -168,7 +168,7 @@ console_poll(struct file * filp, struct poll_table_struct * poll_tb) {
     spin_unlock_irqrestore(&(cons->queue->lock), flags);
 
     if (entries > 0) {
-       //      printk("Returning from POLL\n");
+       //      DEBUG("Returning from POLL\n");
        return mask;
     }
     
@@ -181,7 +181,7 @@ static int console_release(struct inode * i, struct file * filp) {
     struct cons_msg * msg = NULL;
     unsigned long flags;
 
-    printk("Releasing the Console File desc\n");
+    DEBUG("Releasing the Console File desc\n");
     
     spin_lock_irqsave(&(cons->queue->lock), flags);
     cons->connected = 0;
@@ -212,7 +212,7 @@ static int console_connect(struct v3_guest * guest, unsigned int cmd,
     int acquired = 0;
 
     if (cons->open == 0) {
-       printk("Attempted to connect to unopened console\n");
+       ERROR("Attempted to connect to unopened console\n");
        return -1;
     }
 
@@ -224,21 +224,21 @@ static int console_connect(struct v3_guest * guest, unsigned int cmd,
     spin_unlock_irqrestore(&(cons->lock), flags);
 
     if (acquired == 0) {
-       printk("Console already connected\n");
+       ERROR("Console already connected\n");
        return -1;
     }
 
     cons_fd = anon_inode_getfd("v3-cons", &cons_fops, cons, O_RDWR);
 
     if (cons_fd < 0) {
-       printk("Error creating console inode\n");
+       ERROR("Error creating console inode\n");
        return cons_fd;
     }
 
     v3_deliver_console_event(guest->v3_ctx, NULL);
 
 
-    printk("Console connected\n");
+    INFO("Console connected\n");
 
     return cons_fd;
 }
@@ -249,15 +249,15 @@ static void * palacios_tty_open(void * private_data, unsigned int width, unsigne
     struct v3_guest * guest = (struct v3_guest *)private_data;
     struct palacios_console * cons = kmalloc(sizeof(struct palacios_console), GFP_KERNEL);
 
-    printk("Guest initialized virtual console (Guest=%s)\n", guest->name);
+    INFO("Guest initialized virtual console (Guest=%s)\n", guest->name);
 
     if (guest == NULL) {
-       printk("ERROR: Cannot open a console on a NULL guest\n");
+       ERROR("ERROR: Cannot open a console on a NULL guest\n");
        return NULL;
     }
 
     if (cons->open == 1) {
-       printk("Console already open\n");
+       ERROR("Console already open\n");
        return NULL;
     }
 
@@ -280,7 +280,7 @@ static void * palacios_tty_open(void * private_data, unsigned int width, unsigne
 }
 
 static int post_msg(struct palacios_console * cons, struct cons_msg * msg) {
-    //    printk("Posting Console message\n");
+    //    DEBUG("Posting Console message\n");
 
     while (enqueue(cons->queue, msg) == -1) {  
        wake_up_interruptible(&(cons->intr_queue));
index 1719abb..7fcc652 100644 (file)
@@ -53,15 +53,15 @@ static int vm_env_inject (struct v3_guest * guest, unsigned int cmd, unsigned lo
     struct env_data * env;
     int i;
 
-    printk("Palacios: Loading environment data...\n");
+    INFO("Palacios: Loading environment data...\n");
     if (copy_from_user(&env_arg, (void __user *)arg, sizeof(struct env_data))) {
-        printk("palacios: error copying environment data from userspace\n");
+        ERROR("palacios: error copying environment data from userspace\n");
         return -EFAULT;
     }
 
     env = kmalloc(sizeof(struct env_data), GFP_KERNEL);
     if (IS_ERR(env)) {
-        printk("Palacios Error: could not allocate space for environment data\n");
+        ERROR("Palacios Error: could not allocate space for environment data\n");
         return -EFAULT;
     }
 
@@ -70,47 +70,47 @@ static int vm_env_inject (struct v3_guest * guest, unsigned int cmd, unsigned lo
     env->num_strings = env_arg.num_strings;
     
     strcpy(env->bin_name, env_arg.bin_name);
-    printk("Binary hooked on: %s\n", env->bin_name);
+    DEBUG("Binary hooked on: %s\n", env->bin_name);
 
-    //printk("Palacios: Allocating space for %u env var string ptrs...\n", env->num_strings);
+    //DEBUG("Palacios: Allocating space for %u env var string ptrs...\n", env->num_strings);
     env->strings = kmalloc(env->num_strings*sizeof(char*), GFP_KERNEL);
     if (IS_ERR(env->strings)) {
-        printk("Palacios Error: could not allocate space for env var strings\n");
+        ERROR("Palacios Error: could not allocate space for env var strings\n");
         return -EFAULT;
     }
     memset(env->strings, 0, env->num_strings*sizeof(char*));
 
-    //printk("Palacios: copying env var string pointers\n");
+    //INFO("Palacios: copying env var string pointers\n");
     if (copy_from_user(env->strings, (void __user *)env_arg.strings, env->num_strings*sizeof(char*))) {
-        printk("Palacios: Error copying string pointers\n");
+        ERROR("Palacios: Error copying string pointers\n");
         return -EFAULT;
     }
 
     for (i = 0; i < env->num_strings; i++) {
         char * tmp  = kmalloc(MAX_STRING_LEN, GFP_KERNEL);
         if (IS_ERR(tmp)) {
-            printk("Palacios Error: could not allocate space for env var string #%d\n", i);
+            ERROR("Palacios Error: could not allocate space for env var string #%d\n", i);
             return -EFAULT;
         }
 
         if (copy_from_user(tmp, (void __user *)env->strings[i], MAX_STRING_LEN)) {
-            printk("Palacios: Error copying string #%d\n", i);
+            ERROR("Palacios: Error copying string #%d\n", i);
             return -EFAULT;
         }
         env->strings[i] = tmp;
     }
 
-    printk("Palacios: registering environment data...\n");
+    INFO("Palacios: registering environment data...\n");
     if (register_env(env) < 0) 
         return -1;
     
-    printk("Palacios: passing data off to palacios...\n");
+    DEBUG("Palacios: passing data off to palacios...\n");
     if (v3_insert_env_inject(guest->v3_ctx, env->strings, env->num_strings, env->bin_name) < 0) {
-        printk("Palacios: Error passing off environment data\n");
+        ERROR("Palacios: Error passing off environment data\n");
         return -1;
     }
 
-    printk("Palacios: environment injection registration complete\n");
+    INFO("Palacios: environment injection registration complete\n");
     return 0;
 }
 
index 091c773..b770256 100644 (file)
@@ -66,7 +66,7 @@ static int mkdir_recursive(const char * path, unsigned short perms) {
               (*tmp_iter != '\0')) {
 
            if ( (!isprint(*tmp_iter))) {
-               printk("Invalid character in path name (%d)\n", *tmp_iter);
+               ERROR("Invalid character in path name (%d)\n", *tmp_iter);
                return -1;
            } else {
                tmp_iter++;
@@ -82,7 +82,7 @@ static int mkdir_recursive(const char * path, unsigned short perms) {
        // Ignore empty directories
        if ((tmp_iter - dirname_ptr) > 1) {
            if (palacios_file_mkdir(tmp_str, perms, 0) != 0) {
-               printk("Could not create directory (%s)\n", tmp_str);
+               ERROR("Could not create directory (%s)\n", tmp_str);
                return -1;
            }
        }
@@ -142,7 +142,7 @@ static int palacios_file_mkdir(const char * pathname, unsigned short perms, int
 #endif
 
        if (ret != 0) {
-           printk("%s:%d - Error: kern_path_parent() returned error for (%s)\n", __FILE__, __LINE__, 
+           ERROR("%s:%d - Error: kern_path_parent() returned error for (%s)\n", __FILE__, __LINE__, 
                   pathname);
            return -1;
        }
@@ -183,7 +183,7 @@ static void * palacios_file_open(const char * path, int mode, void * private_dat
        vm_state = get_vm_ext_data(guest, "FILE_INTERFACE");
        
        if (vm_state == NULL) {
-           printk("ERROR: Could not locate vm file state for extension FILE_INTERFACE\n");
+           ERROR("ERROR: Could not locate vm file state for extension FILE_INTERFACE\n");
            return NULL;
        }
     }
@@ -210,7 +210,7 @@ static void * palacios_file_open(const char * path, int mode, void * private_dat
     pfile->filp = filp_open(path, pfile->mode, 0);
     
     if (IS_ERR(pfile->filp)) {
-       printk("Cannot open file: %s\n", path);
+       ERROR("Cannot open file: %s\n", path);
        return NULL;
     }
 
@@ -252,7 +252,7 @@ static unsigned long long palacios_file_size(void * file_ptr) {
     ret = vfs_getattr(filp->f_path.mnt, filp->f_path.dentry, &s);
 
     if (ret != 0) {
-       printk("Failed to fstat file\n");
+       ERROR("Failed to fstat file\n");
        return -1;
     }
 
@@ -273,7 +273,7 @@ static unsigned long long palacios_file_read(void * file_ptr, void * buffer, uns
     set_fs(old_fs);
        
     if (ret <= 0) {
-       printk("sys_read of %p for %lld bytes at offset %llu failed (ret=%ld)\n", filp, length, offset, ret);
+       ERROR("sys_read of %p for %lld bytes at offset %llu failed (ret=%ld)\n", filp, length, offset, ret);
     }
        
     return ret;
@@ -295,7 +295,7 @@ static unsigned long long palacios_file_write(void * file_ptr, void * buffer, un
 
  
     if (ret <= 0) {
-       printk("sys_write for %llu bytes at offset %llu failed (ret=%ld)\n", length, offset, ret);              
+       ERROR("sys_write for %llu bytes at offset %llu failed (ret=%ld)\n", length, offset, ret);
     }
        
     return ret;
@@ -324,7 +324,7 @@ static int file_init( void ) {
 
 static int file_deinit( void ) {
     if (!list_empty(&(global_files))) {
-       printk("Error removing module with open files\n");
+       ERROR("Error removing module with open files\n");
     }
 
     return 0;
index 70dede5..07d979b 100644 (file)
@@ -85,12 +85,12 @@ static v3_graphics_console_t g_open(void * priv_data,
     gc = get_vm_ext_data(guest, "GRAPHICS_CONSOLE_INTERFACE");
     
     if (gc == NULL) {
-       printk("palacios: Could not locate graphics console data for extension GRAPHICS_CONSOLE_INTERFACE\n");
+       ERROR("palacios: Could not locate graphics console data for extension GRAPHICS_CONSOLE_INTERFACE\n");
        return 0;
     }
 
     if (gc->data != NULL) { 
-       printk("palacios: framebuffer already allocated - returning it\n");
+       DEBUG("palacios: framebuffer already allocated - returning it\n");
 
        *actual_spec = gc->spec;
        gc->cons_refcount++;
@@ -101,13 +101,13 @@ static v3_graphics_console_t g_open(void * priv_data,
 
     mem = desired_spec->width * desired_spec->height * desired_spec->bytes_per_pixel;
 
-    printk("palacios: allocating %u bytes for %u by %u by %u buffer\n",
+    DEBUG("palacios: allocating %u bytes for %u by %u by %u buffer\n",
           mem, desired_spec->width, desired_spec->height, desired_spec->bytes_per_pixel);
 
     gc->data = vmalloc(mem);
 
     if (!(gc->data)) { 
-       printk("palacios: unable to allocate memory for frame buffer\n");
+       ERROR("palacios: unable to allocate memory for frame buffer\n");
        return 0;
     }
 
@@ -119,7 +119,7 @@ static v3_graphics_console_t g_open(void * priv_data,
     gc->cons_refcount++;
     gc->data_refcount++;
 
-    printk("palacios: allocated frame buffer\n");
+    INFO("palacios: allocated frame buffer\n");
 
     return gc;
 }
@@ -132,17 +132,17 @@ static  void g_close(v3_graphics_console_t cons)
     gc->data_refcount--;
 
     if (gc->data_refcount < gc->cons_refcount) { 
-       printk("palacios: error!   data refcount is less than console refcount for graphics console\n");
+       ERROR("palacios: error!   data refcount is less than console refcount for graphics console\n");
     }
 
     if (gc->cons_refcount > 0) { 
        return;
     } else {
        if (gc->cons_refcount < 0) { 
-           printk("palacios: error!  refcount for graphics console is negative on close!\n");
+           ERROR("palacios: error!  refcount for graphics console is negative on close!\n");
        }
        if (gc->data_refcount > 0) { 
-           printk("palacios: error!  refcount for graphics console data is positive on close - LEAKING MEMORY\n");
+           ERROR("palacios: error!  refcount for graphics console data is positive on close - LEAKING MEMORY\n");
            return;
        }
        if (gc->data) { 
@@ -158,7 +158,7 @@ static void * g_get_data_read(v3_graphics_console_t cons,
     struct palacios_graphics_console *gc = (struct palacios_graphics_console *) cons;
     
     if (gc->data_refcount<=0) { 
-       printk("palacios: error!  data refcount is <= 0 in get_data_read\n");
+       ERROR("palacios: error!  data refcount is <= 0 in get_data_read\n");
     }
 
     gc->data_refcount++;
@@ -175,7 +175,7 @@ static void g_release_data_read(v3_graphics_console_t cons)
     gc->data_refcount--;
 
     if (gc->data_refcount<=0) { 
-       printk("palacios: error!  data refcount is <= zero in release_data_read\n");
+       ERROR("palacios: error!  data refcount is <= zero in release_data_read\n");
     }
     
 }
@@ -223,7 +223,7 @@ static int g_register_render_request(
    gc->render_data = priv_data;
    gc->render_request = render_request;
 
-   printk("palacios: installed rendering callback function for graphics console\n");
+   INFO("palacios: installed rendering callback function for graphics console\n");
    
    return 0;
 
@@ -241,7 +241,7 @@ static int g_register_update_inquire(
    gc->update_data = priv_data;
    gc->update_inquire = update_inquire;
 
-   printk("palacios: installed update inquiry callback function for graphics console\n");
+   INFO("palacios: installed update inquiry callback function for graphics console\n");
    
    return 0;
 
@@ -255,11 +255,11 @@ static int palacios_graphics_console_key(struct v3_guest * guest,
     e.status = 0;
     e.scan_code = scancode;
 
-    //printk("palacios: start key delivery\n");
+    //DEBUG("palacios: start key delivery\n");
 
     v3_deliver_keyboard_event(guest->v3_ctx, &e);
 
-    //printk("palacios: end key delivery\n");
+    //DEBUG("palacios: end key delivery\n");
     
     return 0;
 }
@@ -311,27 +311,27 @@ static int fb_query(struct v3_guest * guest, unsigned int cmd, unsigned long arg
     
     
     if (copy_from_user(&q, (void __user *) arg, sizeof(struct v3_fb_query_response))) { 
-       printk("palacios: copy from user in getting query in fb\n");
+       ERROR("palacios: copy from user in getting query in fb\n");
        return -EFAULT;
     }
     
     switch (q.request_type) { 
        case V3_FB_SPEC:
-           //printk("palacios: request for db spec from Userland\n");
+           //INFO("palacios: request for db spec from Userland\n");
            // returns only the spec for the FB
            q.spec = cons->spec;
 
            break;
 
        case V3_FB_UPDATE: 
-           //printk("palacios: test for fb updatei from Userland\n");
+           //DEBUG("palacios: test for fb updatei from Userland\n");
            // returns whether an update is available for the region
            if (cons->update_inquire) {
              q.updated = cons->update_inquire(cons,cons->update_data);
            } else {
              q.updated = 1;
            }
-            //printk("palacios: update=%d\n",q.updated);
+            //DEBUG("palacios: update=%d\n",q.updated);
 
             // request a render, since a FB_DATA will probably soon come
             cons->change_request = 1;
@@ -340,7 +340,7 @@ static int fb_query(struct v3_guest * guest, unsigned int cmd, unsigned long arg
 
        case V3_FB_DATA_BOX: {
            // Not curently implemented
-           printk("palacios: request for data in bounding box unsupported currently\n");
+           ERROR("palacios: request for data in bounding box unsupported currently\n");
            return -EFAULT;
 
        }
@@ -348,25 +348,25 @@ static int fb_query(struct v3_guest * guest, unsigned int cmd, unsigned long arg
            break;
            
        case V3_FB_DATA_ALL: {
-            //printk("palacios: got FrameBuffer Request from Userland\n");
+            //DEBUG("palacios: got FrameBuffer Request from Userland\n");
            // First let's sanity check to see if they are requesting the same
            // spec that we have
            if (memcmp(&(q.spec),&(cons->spec),sizeof(struct v3_frame_buffer_spec))) { 
-               printk("palacios: request for data with non-matching fb spec \n");
+               ERROR("palacios: request for data with non-matching fb spec \n");
                return -EFAULT;
            }
             // Now we will force a render if we can
             if (cons->render_request) {
-                //printk("palacios: making rendering request\n");
+                //DEBUG("palacios: making rendering request\n");
                  cons->render_request(cons,cons->render_data);
             }
 
            // Now let's indicate an update is in the pointer and copy across the data
            if (copy_to_user(q.data,cons->data,cons->spec.width*cons->spec.height*cons->spec.bytes_per_pixel)) { 
-               printk("palacios: unable to copy fb content to user\n");
+               ERROR("palacios: unable to copy fb content to user\n");
                return -EFAULT;
            }
-            //printk("palacios: FrameBuffer copy out done\n");
+            //DEBUG("palacios: FrameBuffer copy out done\n");
            q.updated = 1;
             // Now we don't need to request a render
             cons->change_request = 0;
@@ -379,7 +379,7 @@ static int fb_query(struct v3_guest * guest, unsigned int cmd, unsigned long arg
 
     // now we'll copy back any changes we made to the query/response structure
     if (copy_to_user((void __user *) arg, (void*)&q, sizeof(struct v3_fb_query_response))) { 
-       printk("palacios: unable to copy fb response to user\n");
+       ERROR("palacios: unable to copy fb response to user\n");
        return -EFAULT;
     }
 
@@ -398,21 +398,21 @@ static int fb_input(struct v3_guest * guest,
 
 
     if (copy_from_user(&inp, (void __user *) arg, sizeof(struct v3_fb_input))) { 
-       printk("palacios: copy from user in getting input in fb\n");
+       ERROR("palacios: copy from user in getting input in fb\n");
        return -EFAULT;
     }
 
-    //printk("palacios: input from Userland\n");   
+    //DEBUG("palacios: input from Userland\n");   
        
     if ((inp.data_type == V3_FB_KEY) || (inp.data_type == V3_FB_BOTH)) { 
        rc = palacios_graphics_console_key(guest, cons, inp.scan_code);
-        //printk("palacios: key delivered to palacios\n");
+        //DEBUG("palacios: key delivered to palacios\n");
     }
 
     if ((inp.data_type == V3_FB_MOUSE) || (inp.data_type == V3_FB_BOTH)) { 
        rc |= palacios_graphics_console_mouse(guest, cons, inp.mouse_data[0],
                                              inp.mouse_data[1], inp.mouse_data[2]);
-       //printk("palacios: mouse delivered to palacios\n");
+       //DEBUG("palacios: mouse delivered to palacios\n");
     }
 
     if (rc) { 
@@ -428,7 +428,7 @@ static int graphics_console_guest_init(struct v3_guest * guest, void ** vm_data)
     struct palacios_graphics_console * graphics_cons = kmalloc(sizeof(struct palacios_graphics_console), GFP_KERNEL);
 
     if (!graphics_cons) { 
-       printk("palacios: filed to do guest_init for graphics console\n");
+       ERROR("palacios: filed to do guest_init for graphics console\n");
        return -1;
     }
 
index cfcf4c0..5ef4d16 100644 (file)
@@ -127,20 +127,20 @@ struct palacios_host_dev {
 #define SHALLOW_DEBUG 0
 
 #if DEEP_DEBUG
-#define DEEP_DEBUG_PRINT(fmt, args...) printk((fmt), ##args)
+#define DEEP_DEBUG_PRINT(fmt, args...) DEBUG((fmt), ##args)
 #else
 #define DEEP_DEBUG_PRINT(fmt, args...) 
 #endif
 
 #if SHALLOW_DEBUG
-#define SHALLOW_DEBUG_PRINT(fmt, args...) printk((fmt), ##args)
+#define SHALLOW_DEBUG_PRINT(fmt, args...) INFO((fmt), ##args)
 #else
 #define SHALLOW_DEBUG_PRINT(fmt, args...) 
 #endif
 
-
-#define ERROR(fmt, args...) printk((fmt), ##args)
-#define INFO(fmt, args...) printk((fmt), ##args)
+// Moved to palacios.h
+//define ERROR(fmt, args...)
+//define INFO(fmt, args...)
 
 struct palacios_host_device_user {
     spinlock_t lock;
@@ -616,7 +616,7 @@ static int host_dev_connect(struct v3_guest * guest, unsigned int cmd, unsigned
 
 
     if (copy_from_user(url, argp, MAX_URL)) {
-       printk("copy from user error getting url for host device connect...\n");
+       ERROR("copy from user error getting url for host device connect...\n");
        return -EFAULT;
     }
 
@@ -750,7 +750,7 @@ static v3_host_dev_t palacios_host_dev_open_deferred(char *url,
     host_dev = get_vm_ext_data(guest, "HOST_DEVICE_INTERFACE");
 
     if (host_dev == NULL) {
-       printk("Error locating vm host data for HOST_DEVICE_INTERFACE\n");
+       ERROR("Error locating vm host data for HOST_DEVICE_INTERFACE\n");
        return 0;
     }
 
index f5682db..76f2f2d 100644 (file)
@@ -22,21 +22,21 @@ static int host_hypercall_nop(palacios_core_t core,
                              unsigned int hcall_id, 
                              struct guest_accessors *acc,
                              void *priv_data) {
-  printk("palacios: host_hypercall_nop dummy handler invoked\n");
-  printk(" rip=%p\n rsp=%p\n rbp=%p\n rflags=%p\n",
+  DEBUG("palacios: host_hypercall_nop dummy handler invoked\n");
+  DEBUG(" rip=%p\n rsp=%p\n rbp=%p\n rflags=%p\n",
         (void*)(acc->get_rip(core)),
         (void*)(acc->get_rsp(core)),
         (void*)(acc->get_rbp(core)),
         (void*)(acc->get_rflags(core)));
 
-  printk(" rax=%p\n rbx=%p\n rcx=%p\n rdx=%p\n rsi=%p\n rdi=%p\n",
+  DEBUG(" rax=%p\n rbx=%p\n rcx=%p\n rdx=%p\n rsi=%p\n rdi=%p\n",
         (void*)(acc->get_rax(core)),
         (void*)(acc->get_rbx(core)),
         (void*)(acc->get_rcx(core)),
         (void*)(acc->get_rdx(core)),
         (void*)(acc->get_rsi(core)),
         (void*)(acc->get_rdi(core)));
-  printk(" r8=%p\n r9=%p\n r10=%p\n r11=%p\n r12=%p\n r13=%p\n r14=%p\n r15=%p\n",
+  DEBUG(" r8=%p\n r9=%p\n r10=%p\n r11=%p\n r12=%p\n r13=%p\n r14=%p\n r15=%p\n",
         (void*)(acc->get_r8(core)),
         (void*)(acc->get_r9(core)),
         (void*)(acc->get_r10(core)),
@@ -45,7 +45,7 @@ static int host_hypercall_nop(palacios_core_t core,
         (void*)(acc->get_r13(core)),
         (void*)(acc->get_r14(core)),
         (void*)(acc->get_r15(core)));
-  printk(" cr0=%p\n cr2=%p\n cr3=%p\n cr4=%p\n cr8=%p\n efer=%p\n",
+  DEBUG(" cr0=%p\n cr2=%p\n cr3=%p\n cr4=%p\n cr8=%p\n efer=%p\n",
         (void*)(acc->get_cr0(core)),
         (void*)(acc->get_cr2(core)),
         (void*)(acc->get_cr3(core)),
@@ -65,19 +65,19 @@ static int vm_hypercall_add (struct v3_guest *guest,
   void *func;
 
   if (copy_from_user(&hdata,(void __user *) arg, sizeof(struct hcall_data))) { 
-    printk("palacios: copy from user in getting input for hypercall add\n");
+    ERROR("palacios: copy from user in getting input for hypercall add\n");
     return -EFAULT;
   }
 
   if (0==strcmp(hdata.fn,"")) { 
-    printk("palacios: no hypercall function supplied, using default\n");
+    WARNING("palacios: no hypercall function supplied, using default\n");
     func = (void*) host_hypercall_nop;
   } else {
     func = __symbol_get(hdata.fn);
   }
 
   if (func == NULL) { 
-    printk("palacios: cannot find function '%s' for hypercall addition - perhaps your module hasn't been loaded yet?\n",hdata.fn);
+    ERROR("palacios: cannot find function '%s' for hypercall addition - perhaps your module hasn't been loaded yet?\n",hdata.fn);
     return -EFAULT;
   }
 
@@ -85,12 +85,12 @@ static int vm_hypercall_add (struct v3_guest *guest,
                                 hdata.hcall_nr,
                                 func,
                                 NULL)) { 
-    printk("palacios: cannot register hypercall 0x%x for function %s (%p)\n",
+    ERROR("palacios: cannot register hypercall 0x%x for function %s (%p)\n",
           hdata.hcall_nr, hdata.fn, func);
     return -EFAULT;
   } 
 
-  printk("palacios: hypercall %d (0x%x) registered for function %s (%p)\n", 
+  INFO("palacios: hypercall %d (0x%x) registered for function %s (%p)\n", 
         hdata.hcall_nr,hdata.hcall_nr,hdata.fn,func);
   return 0;
 }
@@ -103,16 +103,16 @@ static int vm_hypercall_remove (struct v3_guest *guest,
   struct hcall_data hdata;
 
   if (copy_from_user(&hdata,(void __user *) arg, sizeof(struct hcall_data))) { 
-    printk("palacios: copy from user in getting input for hypercall remove\n");
+    ERROR("palacios: copy from user in getting input for hypercall remove\n");
     return -EFAULT;
   }
   if (v3_unregister_host_hypercall(guest->v3_ctx, 
                                   hdata.hcall_nr)) {
-    printk("palacios: cannot unregister hypercall 0x%x\n", hdata.hcall_nr);
+    ERROR("palacios: cannot unregister hypercall 0x%x\n", hdata.hcall_nr);
     return -EFAULT;
   } 
 
-  printk("palacios: hypercall %d (0x%x) unregistered\n", 
+  INFO("palacios: hypercall %d (0x%x) unregistered\n", 
         hdata.hcall_nr,hdata.hcall_nr);
 
   return 0;
index a622eb0..9a51cf3 100644 (file)
@@ -211,7 +211,7 @@ static v3_keyed_stream_t open_stream_mem(char *url,
 {
 
     if (strncasecmp(url,"mem:",4)) { 
-       printk("palacios: illegitimate attempt to open memory stream \"%s\"\n",url);
+       WARNING("palacios: illegitimate attempt to open memory stream \"%s\"\n",url);
        return 0;
     }
 
@@ -234,7 +234,7 @@ static v3_keyed_stream_t open_stream_mem(char *url,
                mykey = kmalloc(strlen(url+4)+1,GFP_KERNEL);
 
                if (!mykey) { 
-                   printk("palacios: cannot allocate space for new in-memory keyed stream %s\n",url);
+                   ERROR("palacios: cannot allocate space for new in-memory keyed stream %s\n",url);
                    return 0;
                }
 
@@ -244,7 +244,7 @@ static v3_keyed_stream_t open_stream_mem(char *url,
 
                if (!mks) { 
                    kfree(mykey);
-                   printk("palacios: cannot allocate in-memory keyed stream %s\n",url);
+                   ERROR("palacios: cannot allocate in-memory keyed stream %s\n",url);
                    return 0;
                }
            
@@ -252,7 +252,7 @@ static v3_keyed_stream_t open_stream_mem(char *url,
                if (!mks->ht) { 
                    kfree(mks);
                    kfree(mykey);
-                   printk("palacios: cannot allocate in-memory keyed stream %s\n",url);
+                   ERROR("palacios: cannot allocate in-memory keyed stream %s\n",url);
                    return 0;
                }
 
@@ -261,7 +261,7 @@ static v3_keyed_stream_t open_stream_mem(char *url,
                    palacios_free_htable(mks->ht,1,1);
                    kfree(mks);
                    kfree(mykey);
-                   printk("palacios: cannot insert in-memory keyed stream %s\n",url);
+                   ERROR("palacios: cannot insert in-memory keyed stream %s\n",url);
                    return 0;
                }
                mks->stype=STREAM_MEM;
@@ -275,7 +275,7 @@ static v3_keyed_stream_t open_stream_mem(char *url,
            break;
 
        default:
-           printk("palacios: unsupported open type in open_stream_mem\n");
+           ERROR("palacios: unsupported open type in open_stream_mem\n");
            break;
     }
     
@@ -306,7 +306,7 @@ static v3_keyed_stream_key_t open_key_mem(v3_keyed_stream_t stream,
        char *mykey = kmalloc(strlen(key)+1,GFP_KERNEL);
 
        if (!mykey) { 
-           printk("palacios: cannot allocate copy of key for key %s\n",key);
+           ERROR("palacios: cannot allocate copy of key for key %s\n",key);
            return 0;
        }
 
@@ -316,14 +316,14 @@ static v3_keyed_stream_key_t open_key_mem(v3_keyed_stream_t stream,
        
        if (!m) { 
            kfree(mykey);
-           printk("palacios: cannot allocate mem keyed stream for key %s\n",key);
+           ERROR("palacios: cannot allocate mem keyed stream for key %s\n",key);
            return 0;
        }
 
        if (!palacios_htable_insert(s,(addr_t)mykey,(addr_t)m)) {
            destroy_mem_stream(m);
            kfree(mykey);
-           printk("palacios: cannot insert mem keyed stream for key %s\n",key);
+           ERROR("palacios: cannot insert mem keyed stream for key %s\n",key);
            return 0;
        }
     }
@@ -355,7 +355,7 @@ static void preallocate_hint_key_mem(v3_keyed_stream_t stream,
        mykey=kmalloc(strlen(key)+1,GFP_KERNEL);
        
        if (!mykey) { 
-           printk("palacios: cannot allocate key spce for preallocte for key %s\n",key);
+           ERROR("palacios: cannot allocate key space for preallocte for key %s\n",key);
            return;
        }
        
@@ -364,19 +364,19 @@ static void preallocate_hint_key_mem(v3_keyed_stream_t stream,
        m = create_mem_stream_internal(size);
        
        if (!m) { 
-           printk("palacios: cannot preallocate mem keyed stream for key %s\n",key);
+           ERROR("palacios: cannot preallocate mem keyed stream for key %s\n",key);
            return;
        }
 
        if (!palacios_htable_insert(s,(addr_t)mykey,(addr_t)m)) {
-           printk("palacios: cannot insert preallocated mem keyed stream for key %s\n",key);
+           ERROR("palacios: cannot insert preallocated mem keyed stream for key %s\n",key);
            destroy_mem_stream(m);
            return;
        }
     } else {
        if (m->data_max < size) { 
            if (expand_mem_stream(m,size)) { 
-               printk("palacios: cannot expand key for preallocation for key %s\n",key);
+               ERROR("palacios: cannot expand key for preallocation for key %s\n",key);
                return;
            }
        }
@@ -416,7 +416,7 @@ static sint64_t write_key_mem(v3_keyed_stream_t stream,
     writelen=write_mem_stream(m,buf,mylen);
 
     if (writelen!=mylen) { 
-       printk("palacios: failed to write all data for key\n");
+       ERROR("palacios: failed to write all data for key\n");
        return -1;
     } else {
        return (sint64_t)writelen;
@@ -446,7 +446,7 @@ static sint64_t read_key_mem(v3_keyed_stream_t stream,
     readlen=read_mem_stream(m,buf,mylen);
     
     if (readlen!=mylen) { 
-       printk("palacios: failed to read all data for key\n");
+       ERROR("palacios: failed to read all data for key\n");
        return -1;
     } else {
        return (sint64_t)readlen;
@@ -482,21 +482,21 @@ static v3_keyed_stream_t open_stream_file(char *url,
     struct nameidata nd;
 
     if (strncasecmp(url,"file:",5)) { 
-       printk("palacios: illegitimate attempt to open file stream \"%s\"\n",url);
+       WARNING("palacios: illegitimate attempt to open file stream \"%s\"\n",url);
        return 0;
     }
 
     fks = kmalloc(sizeof(struct file_keyed_stream),GFP_KERNEL);
     
     if (!fks) { 
-       printk("palacios: cannot allocate space for file stream\n");
+       ERROR("palacios: cannot allocate space for file stream\n");
        return 0;
     }
 
     fks->path = (char*)kmalloc(strlen(url+5)+1,GFP_KERNEL);
     
     if (!(fks->path)) { 
-       printk("palacios: cannot allocate space for file stream\n");
+       ERROR("palacios: cannot allocate space for file stream\n");
        kfree(fks);
        return 0;
     }
@@ -516,7 +516,7 @@ static v3_keyed_stream_t open_stream_file(char *url,
        if (ot==V3_KS_RD_ONLY || ot==V3_KS_WR_ONLY) { 
 
            // we are not being asked to create it
-           printk("palacios: attempt to open %s, which does not exist\n",fks->path);
+           ERROR("palacios: attempt to open %s, which does not exist\n",fks->path);
            goto fail_out;
 
        } else {
@@ -528,14 +528,14 @@ static v3_keyed_stream_t open_stream_file(char *url,
 
            // Find its parent
            if (path_lookup(fks->path,LOOKUP_PARENT|LOOKUP_FOLLOW,&nd)) { 
-               printk("palacios: attempt to create %s failed because its parent cannot be looked up\n",fks->path);
+               ERROR("palacios: attempt to create %s failed because its parent cannot be looked up\n",fks->path);
                goto fail_out;
            }
 
            // Can we write to the parent?
 
            if (inode_permission(nd.path.dentry->d_inode, MAY_WRITE | MAY_EXEC)) { 
-               printk("palacios: attempt to open %s, which has the wrong permissions for directory creation\n",fks->path);
+               ERROR("palacios: attempt to open %s, which has the wrong permissions for directory creation\n",fks->path);
                goto fail_out;
            }
 
@@ -544,7 +544,7 @@ static v3_keyed_stream_t open_stream_file(char *url,
            de = lookup_create(&nd,1);
 
            if (IS_ERR(de)) { 
-               printk("palacios: cannot allocate dentry\n");
+               ERROR("palacios: cannot allocate dentry\n");
                goto fail_out;
            }
 
@@ -555,7 +555,7 @@ static v3_keyed_stream_t open_stream_file(char *url,
            mutex_unlock(&(nd.path.dentry->d_inode->i_mutex));
 
            if (err) {
-               printk("palacios: attempt to create %s failed because mkdir failed\n",fks->path);
+               ERROR("palacios: attempt to create %s failed because mkdir failed\n",fks->path);
                goto fail_out;
            }
 
@@ -569,7 +569,7 @@ static v3_keyed_stream_t open_stream_file(char *url,
     // and the directory exists, so we must check the permissions
 
     if (inode_permission(nd.path.dentry->d_inode, MAY_EXEC | (ot==V3_KS_RD_ONLY ? MAY_READ : MAY_WRITE))) {
-       printk("palacios: attempt to open %s, which has the wrong permissions\n",fks->path);
+       ERROR("palacios: attempt to open %s, which has the wrong permissions\n",fks->path);
        goto fail_out;
     } else {
        return (v3_keyed_stream_t) fks;
@@ -610,7 +610,7 @@ static v3_keyed_stream_key_t open_key_file(v3_keyed_stream_t stream,
     // file:/home/foo + "regext" => "/home/foo/regext"
     path = (char *) kmalloc(strlen(fks->path)+strlen(key)+2,GFP_KERNEL);
     if (!path) {                               
-       printk("palacios: cannot allocate file keyed stream for key %s\n",key);
+       ERROR("palacios: cannot allocate file keyed stream for key %s\n",key);
        return 0;
     }
     strcpy(path,fks->path);
@@ -620,7 +620,7 @@ static v3_keyed_stream_key_t open_key_file(v3_keyed_stream_t stream,
     fs = (struct file_stream *) kmalloc(sizeof(struct file_stream *),GFP_KERNEL);
     
     if (!fs) { 
-       printk("palacios: cannot allocate file keyed stream for key %s\n",key);
+       ERROR("palacios: cannot allocate file keyed stream for key %s\n",key);
        kfree(path);
        return 0;
     }
@@ -630,7 +630,7 @@ static v3_keyed_stream_key_t open_key_file(v3_keyed_stream_t stream,
     fs->f = filp_open(path,O_RDWR|O_CREAT,0600);
     
     if (IS_ERR(fs->f)) {
-       printk("palacios: cannot open relevent file \"%s\" for stream \"file:%s\" and key \"%s\"\n",path,fks->path,key);
+       ERROR("palacios: cannot open relevent file \"%s\" for stream \"file:%s\" and key \"%s\"\n",path,fks->path,key);
        kfree(fs);
        kfree(path);
        return 0;
@@ -805,7 +805,7 @@ static int do_request_to_response(struct user_keyed_stream *s, unsigned long *fl
 {
 
     if (s->waiting) {
-       printk("palacios: user keyed stream request attempted while one is already in progress on %s\n",s->url);
+       ERROR("palacios: user keyed stream request attempted while one is already in progress on %s\n",s->url);
         return -1;
     }
 
@@ -835,7 +835,7 @@ static int do_response_to_request(struct user_keyed_stream *s, unsigned long *fl
 {
 
     if (!(s->waiting)) {
-       printk("palacios: user keyed stream response while no request is in progress on %s\n",s->url);
+       ERROR("palacios: user keyed stream response while no request is in progress on %s\n",s->url);
         return -1;
     }
 
@@ -901,7 +901,7 @@ static long keyed_stream_ioctl_user(struct file * filp, unsigned int ioctl, unsi
            
            if (copy_to_user((void * __user) argp, &size, sizeof(uint64_t))) {
                spin_unlock_irqrestore(&(s->lock), flags);
-               printk("palacios: palacios user key size request failed to copy data\n");
+               ERROR("palacios: palacios user key size request failed to copy data\n");
                return -EFAULT;
            }
            
@@ -919,7 +919,7 @@ static long keyed_stream_ioctl_user(struct file * filp, unsigned int ioctl, unsi
 
            if (!(s->waiting)) {
                spin_unlock_irqrestore(&(s->lock), flags);
-               printk("palacios: palacios user key pull request when not waiting\n");
+               ERROR("palacios: palacios user key pull request when not waiting\n");
                return 0;
            }
 
@@ -928,7 +928,7 @@ static long keyed_stream_ioctl_user(struct file * filp, unsigned int ioctl, unsi
 
            if (copy_to_user((void __user *) argp, s->op, size)) {
                spin_unlock_irqrestore(&(s->lock), flags);
-               printk("palacios: palacios user key pull request failed to copy data\n");
+               ERROR("palacios: palacios user key pull request failed to copy data\n");
                return -EFAULT;
            }
 
@@ -947,18 +947,18 @@ static long keyed_stream_ioctl_user(struct file * filp, unsigned int ioctl, unsi
 
         if (!(s->waiting)) {
             spin_unlock_irqrestore(&(s->lock), flags);
-           printk("palacios: palacios user key push response when not waiting\n");
+           ERROR("palacios: palacios user key push response when not waiting\n");
             return 0;
         }
        
         if (copy_from_user(&size, (void __user *) argp, sizeof(uint64_t))) {
-           printk("palacios: palacios user key push response failed to copy size\n");
+           ERROR("palacios: palacios user key push response failed to copy size\n");
             spin_unlock_irqrestore(&(s->lock), flags);
             return -EFAULT;
         }
 
        if (resize_op(&(s->op),size-sizeof(struct palacios_user_keyed_stream_op))) {
-           printk("palacios: unable to resize op in user key push response\n");
+           ERROR("palacios: unable to resize op in user key push response\n");
             spin_unlock_irqrestore(&(s->lock), flags);
            return -EFAULT;
        }
@@ -976,7 +976,7 @@ static long keyed_stream_ioctl_user(struct file * filp, unsigned int ioctl, unsi
         break;
        
     default:
-       printk("palacios: unknown ioctl in user keyed stream\n");
+       ERROR("palacios: unknown ioctl in user keyed stream\n");
 
         return -EFAULT;
 
@@ -1028,25 +1028,25 @@ int keyed_stream_connect_user(struct v3_guest *guest, unsigned int cmd, unsigned
     struct user_keyed_stream *s;
     
     if (!user_streams) { 
-       printk("palacios: no user space keyed streams!\n");
+       ERROR("palacios: no user space keyed streams!\n");
        return -1;
     }
 
     // get the url
     if (copy_from_user(&len,(void __user *)arg,sizeof(len))) { 
-       printk("palacios: cannot copy url len from user\n");
+       ERROR("palacios: cannot copy url len from user\n");
        return -1;
     }
 
     url = kmalloc(len,GFP_KERNEL);
     
     if (!url) { 
-       printk("palacios: cannot allocate url for user keyed stream\n");
+       ERROR("palacios: cannot allocate url for user keyed stream\n");
        return -1;
     }
 
     if (copy_from_user(url,((void __user *)arg)+sizeof(len),len)) {
-       printk("palacios: cannot copy url from user\n");
+       ERROR("palacios: cannot copy url from user\n");
        return -1;
     }
     url[len-1]=0;
@@ -1056,7 +1056,7 @@ int keyed_stream_connect_user(struct v3_guest *guest, unsigned int cmd, unsigned
     spin_lock_irqsave(&(user_streams->lock), flags);
     list_for_each_entry(s, &(user_streams->streams), node) {
         if (!strncasecmp(url, s->url, len)) {
-            printk("palacios: user keyed stream connection with url \"%s\" already exists\n", url);
+            ERROR("palacios: user keyed stream connection with url \"%s\" already exists\n", url);
            kfree(url);
             return -1;
         }
@@ -1067,7 +1067,7 @@ int keyed_stream_connect_user(struct v3_guest *guest, unsigned int cmd, unsigned
     s = kmalloc(sizeof(struct user_keyed_stream), GFP_KERNEL);
     
     if (!s) {
-       printk("palacios: cannot allocate new user keyed stream for %s\n",url);
+       ERROR("palacios: cannot allocate new user keyed stream for %s\n",url);
        kfree(url);
         return -1;
     }
@@ -1077,7 +1077,7 @@ int keyed_stream_connect_user(struct v3_guest *guest, unsigned int cmd, unsigned
     fd = anon_inode_getfd("v3-kstream", &user_keyed_stream_fops, s, 0);
 
     if (fd < 0) {
-       printk("palacios: cannot allocate file descriptor for new user keyed stream for %s\n",url);
+       ERROR("palacios: cannot allocate file descriptor for new user keyed stream for %s\n",url);
         kfree(s);
        kfree(url);
         return -1;
@@ -1105,7 +1105,7 @@ static struct user_keyed_stream *keyed_stream_user_find(char *url)
     struct user_keyed_stream *s;
     
     if (!user_streams) { 
-       printk("palacios: no user space keyed streams available\n");
+       ERROR("palacios: no user space keyed streams available\n");
        return NULL;
     }
     
@@ -1131,7 +1131,7 @@ static v3_keyed_stream_t open_stream_user(char *url, v3_keyed_stream_open_t ot)
     s = keyed_stream_user_find(url);
     
     if (!s) {
-       printk("palacios: cannot open user stream %s as it does not exist yet\n",url);
+       ERROR("palacios: cannot open user stream %s as it does not exist yet\n",url);
         return NULL;
     }
 
@@ -1139,7 +1139,7 @@ static v3_keyed_stream_t open_stream_user(char *url, v3_keyed_stream_open_t ot)
 
     if (s->waiting) {
         spin_unlock_irqrestore(&(s->lock), flags);
-       printk("palacios: cannot open user stream %s as it is already in waiting state\n",url);
+       ERROR("palacios: cannot open user stream %s as it is already in waiting state\n",url);
         return NULL;
     }
     
@@ -1181,7 +1181,7 @@ static v3_keyed_stream_key_t open_key_user(v3_keyed_stream_t stream, char *key)
 
     if (resize_op(&(s->op),len)) {
        spin_unlock_irqrestore(&(s->lock),flags);
-       printk("palacios: cannot resize op in opening key %s on user keyed stream %s\n",key,s->url);
+       ERROR("palacios: cannot resize op in opening key %s on user keyed stream %s\n",key,s->url);
        return NULL;
     }
 
@@ -1192,7 +1192,7 @@ static v3_keyed_stream_key_t open_key_user(v3_keyed_stream_t stream, char *key)
     // enter with it locked
     if (do_request_to_response(s,&flags)) { 
        spin_unlock_irqrestore(&(s->lock),flags);
-       printk("palacios: request/response handling failed\n");
+       ERROR("palacios: request/response handling failed\n");
        return NULL;
     }
     // return with it locked
@@ -1214,7 +1214,7 @@ static void close_key_user(v3_keyed_stream_t stream, v3_keyed_stream_key_t key)
 
     if (resize_op(&(s->op),len)) {
        spin_unlock_irqrestore(&(s->lock),flags);
-       printk("palacios: cannot resize op in closing key 0x%p on user keyed stream %s\n",key,s->url);
+       ERROR("palacios: cannot resize op in closing key 0x%p on user keyed stream %s\n",key,s->url);
        return;
     }
 
@@ -1225,7 +1225,7 @@ static void close_key_user(v3_keyed_stream_t stream, v3_keyed_stream_key_t key)
     // enter with it locked
     if (do_request_to_response(s,&flags)) { 
        spin_unlock_irqrestore(&(s->lock),flags);
-       printk("palacios: request/response handling failed\n");
+       ERROR("palacios: request/response handling failed\n");
        return;
     }
     // return with it locked
@@ -1250,12 +1250,12 @@ static sint64_t read_key_user(v3_keyed_stream_t stream, v3_keyed_stream_key_t ke
 
     if (s->otype != V3_KS_RD_ONLY) { 
        spin_unlock_irqrestore(&(s->lock),flags);
-       printk("palacios: attempt to read key from stream that is not in read state on %s\n",s->url);
+       ERROR("palacios: attempt to read key from stream that is not in read state on %s\n",s->url);
     }  
 
     if (resize_op(&(s->op),len)) {
        spin_unlock_irqrestore(&(s->lock),flags);
-       printk("palacios: cannot resize op in reading key 0x%p on user keyed stream %s\n",key,s->url);
+       ERROR("palacios: cannot resize op in reading key 0x%p on user keyed stream %s\n",key,s->url);
        return -1;
     }
 
@@ -1267,7 +1267,7 @@ static sint64_t read_key_user(v3_keyed_stream_t stream, v3_keyed_stream_key_t ke
     // enter with it locked
     if (do_request_to_response(s,&flags)) { 
        spin_unlock_irqrestore(&(s->lock),flags);
-       printk("palacios: request/response handling failed\n");
+       ERROR("palacios: request/response handling failed\n");
        return -1;
     }
     // return with it locked
@@ -1299,12 +1299,12 @@ static sint64_t write_key_user(v3_keyed_stream_t stream, v3_keyed_stream_key_t k
 
     if (s->otype != V3_KS_WR_ONLY) { 
        spin_unlock_irqrestore(&(s->lock),flags);
-       printk("palacios: attempt to write key on stream that is not in write state on %s\n",s->url);
+       ERROR("palacios: attempt to write key on stream that is not in write state on %s\n",s->url);
     }  
 
     if (resize_op(&(s->op),len)) {
        spin_unlock_irqrestore(&(s->lock),flags);
-       printk("palacios: cannot resize op in reading key 0x%p on user keyed stream %s\n",key,s->url);
+       ERROR("palacios: cannot resize op in reading key 0x%p on user keyed stream %s\n",key,s->url);
        return -1;
     }
 
@@ -1320,7 +1320,7 @@ static sint64_t write_key_user(v3_keyed_stream_t stream, v3_keyed_stream_key_t k
     // enter with it locked
     if (do_request_to_response(s,&flags)) { 
        spin_unlock_irqrestore(&(s->lock),flags);
-       printk("palacios: request/response handling failed\n");
+       ERROR("palacios: request/response handling failed\n");
        return -1;
     }
     // return with it locked
@@ -1349,7 +1349,7 @@ static v3_keyed_stream_t open_stream(char *url,
     } else if (!strncasecmp(url,"user:",5)) { 
        return open_stream_user(url,ot);
     } else {
-       printk("palacios: unsupported type in attempt to open keyed stream \"%s\"\n",url);
+       ERROR("palacios: unsupported type in attempt to open keyed stream \"%s\"\n",url);
        return 0;
     }
 }
@@ -1368,7 +1368,7 @@ static void close_stream(v3_keyed_stream_t stream)
            return close_stream_user(stream);
            break;
        default:
-           printk("palacios: unknown stream type %d in close\n",gks->stype);
+           ERROR("palacios: unknown stream type %d in close\n",gks->stype);
            break;
     }
 }
@@ -1389,7 +1389,7 @@ static void preallocate_hint_key(v3_keyed_stream_t stream,
            return preallocate_hint_key_user(stream,key,size);
            break;
        default:
-           printk("palacios: unknown stream type %d in preallocate_hint_key\n",gks->stype);
+           ERROR("palacios: unknown stream type %d in preallocate_hint_key\n",gks->stype);
            break;
     }
     return;
@@ -1411,7 +1411,7 @@ static v3_keyed_stream_key_t open_key(v3_keyed_stream_t stream,
            return open_key_user(stream,key);
            break;
        default:
-           printk("palacios: unknown stream type %d in open_key\n",gks->stype);
+           ERROR("palacios: unknown stream type %d in open_key\n",gks->stype);
            break;
     }
     return 0;
@@ -1433,7 +1433,7 @@ static void close_key(v3_keyed_stream_t stream,
            return close_key_user(stream,key);
            break;
        default:
-           printk("palacios: unknown stream type %d in close_key\n",gks->stype);
+           ERROR("palacios: unknown stream type %d in close_key\n",gks->stype);
            break;
     }
     // nothing to do
@@ -1457,7 +1457,7 @@ static sint64_t write_key(v3_keyed_stream_t stream,
            return write_key_user(stream,key,buf,len);
            break;
        default:
-           printk("palacios: unknown stream type %d in write_key\n",gks->stype);
+           ERROR("palacios: unknown stream type %d in write_key\n",gks->stype);
            return -1;
            break;
     }
@@ -1482,7 +1482,7 @@ static sint64_t read_key(v3_keyed_stream_t stream,
            return read_key_user(stream,key,buf,len);
            break;
        default:
-           printk("palacios: unknown stream type %d in read_key\n",gks->stype);
+           ERROR("palacios: unknown stream type %d in read_key\n",gks->stype);
            return -1;
            break;
     }
@@ -1513,14 +1513,14 @@ static int init_keyed_streams( void )
     mem_streams = palacios_create_htable(DEF_NUM_STREAMS,hash_func,hash_comp);
 
     if (!mem_streams) { 
-       printk("palacios: failed to allocated stream pool for in-memory streams\n");
+       ERROR("palacios: failed to allocated stream pool for in-memory streams\n");
        return -1;
     }
 
     user_streams = kmalloc(sizeof(struct user_keyed_streams),GFP_KERNEL);
 
     if (!user_streams) { 
-       printk("palacios: failed to allocated list for user streams\n");
+       ERROR("palacios: failed to allocated list for user streams\n");
        return -1;
     }
 
@@ -1540,7 +1540,7 @@ static int deinit_keyed_streams( void )
 
     kfree(user_streams);
 
-    printk("Deinit of Palacios Keyed Streams likely leaked memory\n");
+    WARNING("Deinit of Palacios Keyed Streams likely leaked memory\n");
 
     return 0;
 }
index d55b854..4cdec65 100644 (file)
@@ -99,13 +99,13 @@ init_socket(struct raw_interface * iface, const char * eth_dev){
 
     err = sock_create(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL), &(iface->raw_sock)); 
     if (err < 0) {
-       printk(KERN_WARNING "Could not create a PF_PACKET Socket, err %d\n", err);
+       WARNING("Could not create a PF_PACKET Socket, err %d\n", err);
        return -1;
     }
 
     net_dev = dev_get_by_name(&init_net, eth_dev);
     if(net_dev == NULL) {
-       printk(KERN_WARNING "Palacios Packet: Unable to get index for device %s\n", eth_dev);
+       WARNING("Palacios Packet: Unable to get index for device %s\n", eth_dev);
        sock_release(iface->raw_sock);
        return -1;
     }
@@ -120,13 +120,13 @@ init_socket(struct raw_interface * iface, const char * eth_dev){
                                     sizeof(sock_addr));
 
     if (err < 0){
-       printk(KERN_WARNING "Error binding raw packet to device %s, %d\n", eth_dev, err);
+       WARNING("Error binding raw packet to device %s, %d\n", eth_dev, err);
        sock_release(iface->raw_sock);
        
        return -1;
     }
 
-    printk(KERN_INFO "Bind a palacios raw packet interface to device %s, device index %d\n",
+    INFO("Bind a palacios raw packet interface to device %s, device index %d\n",
           eth_dev, net_dev->ifindex);
 
     return 0;
@@ -160,14 +160,14 @@ static int packet_recv_thread( void * arg ) {
 
     pkt = (unsigned char *)kmalloc(ETHERNET_PACKET_LEN, GFP_KERNEL);
 
-    printk("Palacios Raw Packet Bridge: Staring receiving on ethernet device %s\n", 
+    INFO("Palacios Raw Packet Bridge: Staring receiving on ethernet device %s\n", 
           iface->eth_dev);
 
     while (!kthread_should_stop()) {
        size = recv_pkt(iface->raw_sock, pkt, ETHERNET_PACKET_LEN);
        
        if (size < 0) {
-           printk(KERN_WARNING "Palacios raw packet receive error, Server terminated\n");
+           WARNING("Palacios raw packet receive error, Server terminated\n");
            break;
        }
 
@@ -199,7 +199,7 @@ init_raw_interface(struct raw_interface * iface, const char * eth_dev){
 
     memcpy(iface->eth_dev, eth_dev, V3_ETHINT_NAMELEN);        
     if(init_socket(iface, eth_dev) !=0) {
-       printk("packet: fails to initiate raw socket\n");
+       WARNING("packet: fails to initiate raw socket\n");
        return -1;
     }
     
@@ -255,11 +255,11 @@ palacios_packet_connect(struct v3_packet * packet,
     if(iface == NULL){
        iface = (struct raw_interface *)kmalloc(sizeof(struct raw_interface), GFP_KERNEL);
        if (!iface) { 
-           printk("Palacios Packet Interface: Fails to allocate interface\n");
+           WARNING("Palacios Packet Interface: Fails to allocate interface\n");
            return -1;
        }
        if(init_raw_interface(iface, host_nic) != 0) {
-           printk("Palacios Packet Interface: Fails to initiate an raw interface on device %s\n", host_nic);
+           WARNING("Palacios Packet Interface: Fails to initiate an raw interface on device %s\n", host_nic);
            kfree(iface);
            return -1;
        }
@@ -275,7 +275,7 @@ palacios_packet_connect(struct v3_packet * packet,
                           (addr_t)packet->dev_mac, 
                           (addr_t)packet);
 
-    printk(KERN_INFO "Packet: Add Receiver MAC to ethernet device %s: %2x:%2x:%2x:%2x:%2x:%2x\n", 
+    INFO("Packet: Add Receiver MAC to ethernet device %s: %2x:%2x:%2x:%2x:%2x:%2x\n", 
           iface->eth_dev, 
           packet->dev_mac[0], packet->dev_mac[1], 
           packet->dev_mac[2], packet->dev_mac[3], 
@@ -296,7 +296,7 @@ palacios_packet_send(struct v3_packet * packet,
        
     if(iface->inited == 0 || 
        iface->raw_sock == NULL){
-       printk("Palacios Packet Interface: Send fails due to inapproriate interface\n");
+       WARNING("Palacios Packet Interface: Send fails due to inapproriate interface\n");
        
        return -1;
     }
index 979558c..39d18f0 100644 (file)
@@ -51,7 +51,7 @@ palacios_tcp_socket(const int bufsize, const int nodelay,
         vm_state = get_vm_ext_data(guest, "SOCKET_INTERFACE");
         
         if (vm_state == NULL) {
-            printk("ERROR: Could not locate vm socket state for extension SOCKET_INTERFACE\n");
+            ERROR("ERROR: Could not locate vm socket state for extension SOCKET_INTERFACE\n");
             return NULL;
         }
     }
@@ -95,7 +95,7 @@ palacios_udp_socket(
         vm_state = get_vm_ext_data(guest, "SOCKET_INTERFACE");
         
         if (vm_state == NULL) {
-            printk("ERROR: Could not locate vm socket state for extension SOCKET_INTERFACE\n");
+            ERROR("ERROR: Could not locate vm socket state for extension SOCKET_INTERFACE\n");
             return NULL;
         }
     }
@@ -187,7 +187,7 @@ static void * palacios_accept(const void * sock_ptr, unsigned int * remote_ip, u
         vm_state = get_vm_ext_data(sock->guest, "SOCKET_INTERFACE");
         
         if (vm_state == NULL) {
-            printk("ERROR: Could not locate vm socket state for extension SOCKET_INTERFACE\n");
+            ERROR("Could not locate vm socket state for extension SOCKET_INTERFACE\n");
             return NULL;
         }
     }
@@ -457,7 +457,7 @@ static int socket_init( void ) {
 
 static int socket_deinit( void ) {
     if (!list_empty(&(global_sockets))) {
-       printk("Error removing module with open sockets\n");
+       ERROR("Error removing module with open sockets\n");
     }
 
     return 0;
index 9cb89e5..e064b94 100644 (file)
@@ -68,7 +68,7 @@ static struct stream_state * find_stream_by_name(struct v3_guest * guest, const
        vm_state = get_vm_ext_data(guest, "STREAM_INTERFACE");
 
        if (vm_state == NULL) {
-           printk("ERROR: Could not locate vm stream state for extension STREAM_INTERFACE\n");
+           ERROR("ERROR: Could not locate vm stream state for extension STREAM_INTERFACE\n");
            return NULL;
        }
 
@@ -112,7 +112,7 @@ static ssize_t stream_read(struct file * filp, char __user * buf, size_t size, l
        }
 
        if (copy_to_user(buf + bytes_read, tmp_buf, tmp_read)) {
-           printk("Read Fault\n");
+           ERROR("Read Fault\n");
            return -EFAULT;
        }
        
@@ -161,7 +161,7 @@ static ssize_t stream_write(struct file * filp, const char __user * buf, size_t
     kern_buf = kmalloc(size, GFP_KERNEL);
 
     if (copy_from_user(kern_buf, buf, size)) {
-       printk("Stream Write Failed\n");
+       ERROR("Stream Write Failed\n");
        return -EFAULT;
     };
     
@@ -204,13 +204,13 @@ static void * palacios_stream_open(struct v3_stream * v3_stream, const char * na
        vm_state = get_vm_ext_data(guest, "STREAM_INTERFACE");
 
        if (vm_state == NULL) {
-           printk("ERROR: Could not locate vm stream state for extension STREAM_INTERFACE\n");
+           ERROR("ERROR: Could not locate vm stream state for extension STREAM_INTERFACE\n");
            return NULL;
        }
     }
 
     if (find_stream_by_name(guest, name) != NULL) {
-       printk("Stream already exists\n");
+       ERROR("Stream already exists\n");
        return NULL;
     }
 
@@ -291,8 +291,8 @@ static int stream_init( void ) {
 
 static int stream_deinit( void ) {
     if (!list_empty(&(global_streams))) {
-       printk("Error removing module with open streams\n");
-       printk("TODO: free old streams... \n");
+       ERROR("Error removing module with open streams\n");
+       DEBUG("TODO: free old streams... \n");
     }
 
     return 0;
@@ -312,14 +312,14 @@ static int stream_connect(struct v3_guest * guest, unsigned int cmd, unsigned lo
     
     
     if (copy_from_user(name, argp, STREAM_NAME_LEN)) {
-       printk("%s(%d): copy from user error...\n", __FILE__, __LINE__);
+       ERROR("%s(%d): copy from user error...\n", __FILE__, __LINE__);
        return -EFAULT;
     }
 
     stream = find_stream_by_name(guest, name);
 
     if (stream == NULL) {
-       printk("Could not find stream (%s)\n", name);
+       ERROR("Could not find stream (%s)\n", name);
        return -EFAULT;
     }
 
@@ -332,7 +332,7 @@ static int stream_connect(struct v3_guest * guest, unsigned int cmd, unsigned lo
 
 
     if (ret == -1) {
-       printk("Stream (%s) already connected\n", name);
+       ERROR("Stream (%s) already connected\n", name);
        return -EFAULT;
     }
 
@@ -340,11 +340,11 @@ static int stream_connect(struct v3_guest * guest, unsigned int cmd, unsigned lo
     stream_fd = anon_inode_getfd("v3-stream", &stream_fops, stream, O_RDWR);
 
     if (stream_fd < 0) {
-       printk("Error creating stream inode for (%s)\n", name);
+       ERROR("Error creating stream inode for (%s)\n", name);
        return stream_fd;
     }
 
-    printk("Stream (%s) connected\n", name);
+    INFO("Stream (%s) connected\n", name);
 
     return stream_fd;
 }
@@ -365,7 +365,7 @@ static int guest_stream_init(struct v3_guest * guest, void ** vm_data) {
 static int guest_stream_deinit(struct v3_guest * guest, void * vm_data) {
     struct vm_global_streams * state = vm_data;
     if (!list_empty(&(state->open_streams))) {
-       printk("Error shutting down VM with open streams\n");
+       ERROR("Error shutting down VM with open streams\n");
     }
 
     return 0;
index 0ed6231..1ed9972 100644 (file)
@@ -23,7 +23,7 @@ static int vm_syscall_ctrl (struct v3_guest * guest, unsigned int cmd, unsigned
     int ret;
 
     if (copy_from_user(&syscall_cmd, (void __user *)arg, sizeof(struct v3_syscall_cmd))) {
-        printk("Palacios: error copying syscall command from userspace\n");
+        ERROR("palacios: error copying syscall command from userspace\n");
         return -EFAULT;
     }
     
@@ -32,29 +32,29 @@ static int vm_syscall_ctrl (struct v3_guest * guest, unsigned int cmd, unsigned
         case SYSCALL_OFF: {
             ret = v3_syscall_off(guest->v3_ctx, syscall_cmd.syscall_nr);
             if (ret < 0) {
-                printk("Palacios: error deactivating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
+                ERROR("palacios: error deactivating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
             }
             break;
         }
         case SYSCALL_ON: {
             ret = v3_syscall_on(guest->v3_ctx, syscall_cmd.syscall_nr);
             if (ret < 0) {
-                printk("Palacios: error activating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
+                ERROR("palacios: error activating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
             }
             break;
         }
         case SYSCALL_STAT: {
             ret = v3_syscall_stat(guest->v3_ctx, syscall_cmd.syscall_nr);  
             if (ret == SYSCALL_OFF)
-                printk("Palacios: exiting for syscall #%d is OFF\n", syscall_cmd.syscall_nr);
+                INFO("palacios: exiting for syscall #%d is OFF\n", syscall_cmd.syscall_nr);
             else if (ret == SYSCALL_ON) 
-                printk("Palacios: exiting for syscall #%d is ON\n", syscall_cmd.syscall_nr);
+                INFO("palacios: exiting for syscall #%d is ON\n", syscall_cmd.syscall_nr);
             else 
-                printk("Palacios: error stating syscall nr: %d\n", syscall_cmd.syscall_nr);
+                INFO("palacios: error stating syscall nr: %d\n", syscall_cmd.syscall_nr);
             break;
         }
         default:
-            printk("Palacios: error - invalid syscall command\n");
+            ERROR("palacios: error - invalid syscall command\n");
             return -1;
     }
       
index b6cfc1a..7d3ccf2 100644 (file)
@@ -58,14 +58,14 @@ static int inspect_vm(struct v3_guest * guest, unsigned int cmd, unsigned long a
 
 
     if (root == NULL) {
-       printk("No inspection root found\n");
+       ERROR("No inspection root found\n");
        return -1;
     }
 
     guest_dir = debugfs_create_dir(guest->name, v3_dir);
 
     if (IS_ERR(guest_dir)) {
-       printk("Error Creating inspector tree for VM \"%s\"\n", guest->name);
+       ERROR("Error Creating inspector tree for VM \"%s\"\n", guest->name);
        return -1;
     }
 
@@ -80,7 +80,7 @@ static int init_inspector( void ) {
     v3_dir = debugfs_create_dir("v3vee", NULL);
 
     if (IS_ERR(v3_dir)) {
-       printk("Error creating v3vee debugfs directory\n");
+       ERROR("Error creating v3vee debugfs directory\n");
        return -1;
     }
 
index d07cef0..e227107 100644 (file)
@@ -45,12 +45,12 @@ int init_vm_extensions(struct v3_guest * guest) {
            continue;
        }
        
-       printk("Registering Linux Extension (%s)\n", ext_impl->name);
+       INFO("Registering Linux Extension (%s)\n", ext_impl->name);
 
        ext = kmalloc(sizeof(struct vm_ext), GFP_KERNEL);
        
        if (!ext) {
-           printk("Error allocating VM extension (%s)\n", ext_impl->name);
+           WARNING("Error allocating VM extension (%s)\n", ext_impl->name);
            return -1;
        }
 
@@ -76,7 +76,7 @@ int deinit_vm_extensions(struct v3_guest * guest) {
        if (ext->impl->guest_deinit) {
            ext->impl->guest_deinit(guest, ext->vm_data);
        } else {
-           printk("WARNING: Extension %s, does not have a guest deinit function\n", ext->impl->name);
+           WARNING("WARNING: Extension %s, does not have a guest deinit function\n", ext->impl->name);
        }
 
        list_del(&(ext->node));
@@ -94,10 +94,10 @@ int init_lnx_extensions( void ) {
 
     while (tmp_ext != __stop__lnx_exts[0]) {
 
-       printk("tmp_ext=%p\n", tmp_ext);
+       DEBUG("tmp_ext=%p\n", tmp_ext);
 
        if (tmp_ext->init != NULL) {
-           printk("Registering Linux Extension (%s)\n", tmp_ext->name);
+           INFO("Registering Linux Extension (%s)\n", tmp_ext->name);
            tmp_ext->init();
        }
 
@@ -115,11 +115,11 @@ int deinit_lnx_extensions( void ) {
     int i = 0;
 
     while (tmp_ext != __stop__lnx_exts[0]) {
-       printk("Cleaning up Linux Extension (%s)\n", tmp_ext->name);
+       INFO("Cleaning up Linux Extension (%s)\n", tmp_ext->name);
        if (tmp_ext->deinit != NULL) {
            tmp_ext->deinit();
        } else {
-           printk("WARNING: Extension %s does not have a global deinit function\n", tmp_ext->name);
+           WARNING("WARNING: Extension %s does not have a global deinit function\n", tmp_ext->name);
        }
 
        tmp_ext = __start__lnx_exts[++i];
index b24df34..57fe2ef 100644 (file)
@@ -64,7 +64,7 @@ static int register_vm(struct v3_guest * guest) {
 static long v3_dev_ioctl(struct file * filp,
                         unsigned int ioctl, unsigned long arg) {
     void __user * argp = (void __user *)arg;
-    printk("V3 IOCTL %d\n", ioctl);
+    DEBUG("V3 IOCTL %d\n", ioctl);
 
 
     switch (ioctl) {
@@ -74,40 +74,40 @@ static long v3_dev_ioctl(struct file * filp,
            struct v3_guest * guest = kmalloc(sizeof(struct v3_guest), GFP_KERNEL);
 
            if (IS_ERR(guest)) {
-               printk("Palacios: Error allocating Kernel guest_image\n");
+               ERROR("Palacios: Error allocating Kernel guest_image\n");
                return -EFAULT;
            }
 
            memset(guest, 0, sizeof(struct v3_guest));
 
-           printk("Palacios: Creating V3 Guest...\n");
+           INFO("Palacios: Creating V3 Guest...\n");
 
            vm_minor = register_vm(guest);
 
            if (vm_minor == -1) {
-               printk("Palacios Error: Too many VMs are currently running\n");
+               ERROR("Palacios Error: Too many VMs are currently running\n");
                return -EFAULT;
            }
 
            guest->vm_dev = MKDEV(v3_major_num, vm_minor);
 
            if (copy_from_user(&user_image, argp, sizeof(struct v3_guest_img))) {
-               printk("Palacios Error: copy from user error getting guest image...\n");
+               ERROR("Palacios Error: copy from user error getting guest image...\n");
                return -EFAULT;
            }
 
            guest->img_size = user_image.size;
 
-           printk("Palacios: Allocating kernel memory for guest image (%llu bytes)\n", user_image.size);
+           DEBUG("Palacios: Allocating kernel memory for guest image (%llu bytes)\n", user_image.size);
            guest->img = vmalloc(guest->img_size);
 
            if (IS_ERR(guest->img)) {
-               printk("Palacios Error: Could not allocate space for guest image\n");
+               ERROR("Palacios Error: Could not allocate space for guest image\n");
                return -EFAULT;
            }
 
            if (copy_from_user(guest->img, user_image.guest_data, guest->img_size)) {
-               printk("Palacios: Error loading guest data\n");
+               ERROR("Palacios: Error loading guest data\n");
                return -EFAULT;
            }      
 
@@ -116,7 +116,7 @@ static long v3_dev_ioctl(struct file * filp,
            INIT_LIST_HEAD(&(guest->exts));
 
            if (create_palacios_vm(guest) == -1) {
-               printk("Palacios: Error creating guest\n");
+               ERROR("Palacios: Error creating guest\n");
                return -EFAULT;
            }
 
@@ -127,7 +127,7 @@ static long v3_dev_ioctl(struct file * filp,
            unsigned long vm_idx = arg;
            struct v3_guest * guest = guest_map[vm_idx];
 
-           printk("Freeing VM (%s) (%p)\n", guest->name, guest);
+           INFO("Freeing VM (%s) (%p)\n", guest->name, guest);
 
            free_palacios_vm(guest);
            guest_map[vm_idx] = NULL;
@@ -139,14 +139,14 @@ static long v3_dev_ioctl(struct file * filp,
            memset(&mem, 0, sizeof(struct v3_mem_region));
            
            if (copy_from_user(&mem, argp, sizeof(struct v3_mem_region))) {
-               printk("copy from user error getting mem_region...\n");
+               ERROR("copy from user error getting mem_region...\n");
                return -EFAULT;
            }
 
-           printk("Adding %llu pages to Palacios memory\n", mem.num_pages);
+           DEBUG("Adding %llu pages to Palacios memory\n", mem.num_pages);
 
            if (add_palacios_memory(mem.base_addr, mem.num_pages) == -1) {
-               printk("Error adding memory to Palacios\n");
+               ERROR("Error adding memory to Palacios\n");
                return -EFAULT;
            }
 
@@ -154,7 +154,7 @@ static long v3_dev_ioctl(struct file * filp,
        }
 
        default: 
-           printk("\tUnhandled\n");
+           ERROR("\tUnhandled\n");
            return -EINVAL;
     }
 
@@ -188,16 +188,16 @@ static int __init v3_init(void) {
 
     v3_class = class_create(THIS_MODULE, "vms");
     if (IS_ERR(v3_class)) {
-       printk("Failed to register V3 VM device class\n");
+       ERROR("Failed to register V3 VM device class\n");
        return PTR_ERR(v3_class);
     }
 
-    printk("intializing V3 Control device\n");
+    INFO("intializing V3 Control device\n");
 
     ret = alloc_chrdev_region(&dev, 0, MAX_VMS + 1, "v3vee");
 
     if (ret < 0) {
-       printk("Error registering device region for V3 devices\n");
+       ERROR("Error registering device region for V3 devices\n");
        goto failure2;
     }
 
@@ -206,7 +206,7 @@ static int __init v3_init(void) {
     dev = MKDEV(v3_major_num, MAX_VMS + 1);
 
     
-    printk("Creating V3 Control device: Major %d, Minor %d\n", v3_major_num, MINOR(dev));
+    DEBUG("Creating V3 Control device: Major %d, Minor %d\n", v3_major_num, MINOR(dev));
     cdev_init(&ctrl_dev, &v3_ctrl_fops);
     ctrl_dev.owner = THIS_MODULE;
     ctrl_dev.ops = &v3_ctrl_fops;
@@ -215,7 +215,7 @@ static int __init v3_init(void) {
     device_create(v3_class, NULL, dev, NULL, "v3vee");
 
     if (ret != 0) {
-       printk("Error adding v3 control device\n");
+       ERROR("Error adding v3 control device\n");
        goto failure1;
     }
 
@@ -245,13 +245,13 @@ static void __exit v3_exit(void) {
 
     dev_t dev = MKDEV(v3_major_num, MAX_VMS + 1);
 
-    printk("Removing V3 Control device\n");
+    INFO("Removing V3 Control device\n");
 
 
     palacios_vmm_exit();
 
-    printk("Palacios Mallocs = %d, Frees = %d\n", mallocs, frees);
-    printk("Palacios Page Allocs = %d, Page Frees = %d\n", pg_allocs, pg_frees);
+    DEBUG("Palacios Mallocs = %d, Frees = %d\n", mallocs, frees);
+    DEBUG("Palacios Page Allocs = %d, Page Frees = %d\n", pg_allocs, pg_frees);
 
     unregister_chrdev_region(MKDEV(v3_major_num, 0), MAX_VMS + 1);
 
@@ -265,7 +265,7 @@ static void __exit v3_exit(void) {
 
     palacios_deinit_mm();
 
-    printk("Palacios Module Mallocs = %d, Frees = %d\n", mod_allocs, mod_frees);
+    DEBUG("Palacios Module Mallocs = %d, Frees = %d\n", mod_allocs, mod_frees);
 }
 
 
index 166cfd2..ef6e1bd 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/mm.h>
 //static struct list_head pools;
 
+#include "palacios.h"
 
 struct mempool {
     uintptr_t base_addr;
@@ -48,11 +49,11 @@ static uintptr_t alloc_contig_pgs(u64 num_pages, u32 alignment) {
     int i = 0;
     int start = 0;
 
-    printk("Allocating %llu pages (align=%lu)\n", 
+    DEBUG("Allocating %llu pages (align=%lu)\n", 
           num_pages, (unsigned long)alignment);
 
     if (pool.bitmap == NULL) {
-       printk("ERROR: Attempting to allocate from non initialized memory\n");
+       ERROR("ERROR: Attempting to allocate from non initialized memory\n");
        return 0;
     }
 
@@ -65,7 +66,7 @@ static uintptr_t alloc_contig_pgs(u64 num_pages, u32 alignment) {
        start = ((alignment - (pool.base_addr % alignment)) >> 12);
     }
 
-    printk("\t Start idx %d (base_addr=%p)\n", start, (void *)(u64)pool.base_addr);
+    ERROR("\t Start idx %d (base_addr=%p)\n", start, (void *)(u64)pool.base_addr);
 
     for (i = start; i < (pool.num_pages - num_pages); i += step) {
        if (get_page_bit(i) == 0) {
@@ -91,7 +92,7 @@ static uintptr_t alloc_contig_pgs(u64 num_pages, u32 alignment) {
        }
     }
 
-    /* printk("PALACIOS BAD: LARGE PAGE ALLOCATION FAILED\n"); */
+    /* ERROR("PALACIOS BAD: LARGE PAGE ALLOCATION FAILED\n"); */
 
     return 0;
 }
@@ -109,27 +110,27 @@ uintptr_t alloc_palacios_pgs(u64 num_pages, u32 alignment) {
     
        WARN(!pgs, "Could not allocate pages\n");
  
-        /* if (!pgs) { printk("PALACIOS BAD: SMALL PAGE ALLOCATION FAILED\n");  } */
+        /* if (!pgs) { ERROR("PALACIOS BAD: SMALL PAGE ALLOCATION FAILED\n");  } */
        
-       /* printk("%llu pages (order=%d) aquired from alloc_pages\n", 
+       /* DEBUG("%llu pages (order=%d) aquired from alloc_pages\n", 
               num_pages, order); */
 
        addr = page_to_pfn(pgs) << PAGE_SHIFT; 
     } else {
-       //printk("Allocating %llu pages from bitmap allocator\n", num_pages);
+       //DEBUG("Allocating %llu pages from bitmap allocator\n", num_pages);
        //addr = pool.base_addr;
        addr = alloc_contig_pgs(num_pages, alignment);
     }
 
 
-    //printk("Returning from alloc addr=%p, vaddr=%p\n", (void *)addr, __va(addr));
+    //DEBUG("Returning from alloc addr=%p, vaddr=%p\n", (void *)addr, __va(addr));
     return addr;
 }
 
 
 
 void free_palacios_pgs(uintptr_t pg_addr, int num_pages) {
-    //printk("Freeing Memory page %p\n", (void *)pg_addr);
+    //DEBUG("Freeing Memory page %p\n", (void *)pg_addr);
 
     if ((pg_addr >= pool.base_addr) && 
        (pg_addr < pool.base_addr + (4096 * pool.num_pages))) {
@@ -137,7 +138,7 @@ void free_palacios_pgs(uintptr_t pg_addr, int num_pages) {
        int i = 0;
 
        if ((pg_idx + num_pages) > pool.num_pages) {
-           printk("Freeing memory bounds exceeded\n");
+           ERROR("Freeing memory bounds exceeded\n");
            return;
        }
 
@@ -161,11 +162,11 @@ int add_palacios_memory(uintptr_t base_addr, u64 num_pages) {
     int bitmap_size = (num_pages / 8) + ((num_pages % 8) > 0); 
 
     if (pool.num_pages != 0) {
-       printk("ERROR: Memory has already been added\n");
+       ERROR("ERROR: Memory has already been added\n");
        return -1;
     }
 
-    printk("Managing %dMB of memory starting at %llu (%lluMB)\n", 
+    DEBUG("Managing %dMB of memory starting at %llu (%lluMB)\n", 
           (unsigned int)(num_pages * 4096) / (1024 * 1024), 
           (unsigned long long)base_addr, 
           (unsigned long long)(base_addr / (1024 * 1024)));
@@ -174,7 +175,7 @@ int add_palacios_memory(uintptr_t base_addr, u64 num_pages) {
     pool.bitmap = kmalloc(bitmap_size, GFP_KERNEL);
     
     if (IS_ERR(pool.bitmap)) {
-       printk("Error allocating Palacios MM bitmap\n");
+       WARNING("Error allocating Palacios MM bitmap\n");
        return -1;
     }
     
index 12b4e45..a8f2923 100644 (file)
@@ -165,7 +165,7 @@ static int lnx_thread_target(void * arg) {
     struct lnx_thread_arg * thread_info = (struct lnx_thread_arg *)arg;
     int ret = 0;
     /*
-      printk("Daemonizing new Palacios thread (name=%s)\n", thread_info->name);
+      INFO("Daemonizing new Palacios thread (name=%s)\n", thread_info->name);
 
       daemonize(thread_info->name);
       allow_signal(SIGKILL);
@@ -223,7 +223,7 @@ palacios_start_thread_on_cpu(int cpu_id,
     thread = kthread_create( lnx_thread_target, thread_info, thread_name );
 
     if (IS_ERR(thread)) {
-       printk("Palacios error creating thread: %s\n", thread_name);
+       WARNING("Palacios error creating thread: %s\n", thread_name);
        return NULL;
     }
 
@@ -248,7 +248,7 @@ palacios_move_thread_to_cpu(int new_cpu_id,
                            void * thread_ptr) {
     struct task_struct * thread = (struct task_struct *)thread_ptr;
 
-    printk("Moving thread (%p) to cpu %d\n", thread, new_cpu_id);
+    INFO("Moving thread (%p) to cpu %d\n", thread, new_cpu_id);
 
     if (thread == NULL) {
        thread = current;
@@ -331,16 +331,16 @@ palacios_dispatch_interrupt( int vector, void * dev, struct pt_regs * regs ) {
 static int
 palacios_hook_interrupt(struct v3_vm_info *    vm,
                        unsigned int            vector ) {
-    printk("hooking vector %d\n", vector);     
+    INFO("hooking vector %d\n", vector);       
 
     if (irq_to_guest_map[vector]) {
-       printk(KERN_WARNING
+       WARNING(
               "%s: Interrupt vector %u is already hooked.\n",
               __func__, vector);
        return -1;
     }
 
-    printk(KERN_DEBUG
+    DEBUG(
           "%s: Hooking interrupt vector %u to vm %p.\n",
           __func__, vector, vm);
 
@@ -363,7 +363,7 @@ palacios_hook_interrupt(struct v3_vm_info * vm,
        int flag = 0;
        int error;
                
-       printk("hooking vector: %d\n", vector);         
+       DEBUG("hooking vector: %d\n", vector);          
 
        if (vector == 32) {
            flag = IRQF_TIMER;
@@ -378,7 +378,7 @@ palacios_hook_interrupt(struct v3_vm_info * vm,
                            &device_id);
        
        if (error) {
-           printk("error code for request_irq is %d\n", error);
+           ERROR("error code for request_irq is %d\n", error);
            panic("request vector %d failed",vector);
        }
     }
@@ -397,7 +397,7 @@ palacios_ack_interrupt(
 ) 
 {
   ack_APIC_irq(); 
-  printk("Pretending to ack interrupt, vector=%d\n",vector);
+  DEBUG("Pretending to ack interrupt, vector=%d\n",vector);
   return 0;
 }
   
@@ -407,10 +407,10 @@ palacios_ack_interrupt(
 static unsigned int
 palacios_get_cpu_khz(void) 
 {
-    printk("cpu_khz is %u\n",cpu_khz);
+    INFO("cpu_khz is %u\n",cpu_khz);
 
     if (cpu_khz == 0) { 
-       printk("faking cpu_khz to 1000000\n");
+       INFO("faking cpu_khz to 1000000\n");
        return 1000000;
     } else {
        return cpu_khz;
@@ -518,7 +518,7 @@ int palacios_vmm_init( void )
         
         for (i = 0; i < cpu_list_len; i++) {
            if (cpu_list[i] >= num_cpus) {
-               printk("CPU (%d) exceeds number of available CPUs. Ignoring...\n", cpu_list[i]);
+               WARNING("CPU (%d) exceeds number of available CPUs. Ignoring...\n", cpu_list[i]);
                continue;
            }
 
@@ -531,7 +531,7 @@ int palacios_vmm_init( void )
 
     memset(irq_to_guest_map, 0, sizeof(struct v3_vm_info *) * 256);
 
-    printk("palacios_init starting - calling init_v3\n");
+    INFO("palacios_init starting - calling init_v3\n");
     
     Init_V3(&palacios_os_hooks, cpu_mask, num_cpus);
 
index 7eee09c..4efbb86 100644 (file)
@@ -22,6 +22,7 @@
 #include <vnet/vnet.h>
 #include <vnet/vnet_hashtable.h>
 #include "palacios-vnet.h"
+#include "palacios.h"
 
 #define VNET_SERVER_PORT 9000
 
@@ -100,7 +101,7 @@ static void _delete_link(struct vnet_link * link){
     vnet_brg_s.num_links --;
     spin_unlock_irqrestore(&(vnet_brg_s.lock), flags);
 
-    printk("VNET Bridge: Link deleted, ip 0x%x, port: %d, idx: %d\n", 
+    INFO("VNET Bridge: Link deleted, ip 0x%x, port: %d, idx: %d\n", 
           link->dst_ip, 
           link->dst_port, 
           link->idx);
@@ -139,12 +140,12 @@ static uint32_t _create_link(struct vnet_link * link) {
            break;
 
        default:
-           printk("Unsupported VNET Server Protocol\n");
+           WARNING("Unsupported VNET Server Protocol\n");
            return -1;
     }
    
     if ((err = sock_create(AF_INET, SOCK_DGRAM, protocol, &link->sock)) < 0) {
-       printk("Could not create socket for VNET Link, error %d\n", err);
+       WARNING("Could not create socket for VNET Link, error %d\n", err);
        return -1;
     }
 
@@ -155,7 +156,7 @@ static uint32_t _create_link(struct vnet_link * link) {
     link->sock_addr.sin_port = htons(link->dst_port);
 
     if ((err = link->sock->ops->connect(link->sock, (struct sockaddr *)&(link->sock_addr), sizeof(struct sockaddr), 0) < 0)) {
-       printk("Could not connect to remote VNET Server, error %d\n", err);
+       WARNING("Could not connect to remote VNET Server, error %d\n", err);
        return -1;
     }
 
@@ -166,7 +167,7 @@ static uint32_t _create_link(struct vnet_link * link) {
     vnet_htable_insert(vnet_brg_s.ip2link, (addr_t)&(link->dst_ip), (addr_t)link);
     spin_unlock_irqrestore(&(vnet_brg_s.lock), flags);
 
-    printk("VNET Bridge: Link created, ip 0x%x, port: %d, idx: %d, link: %p, protocol: %s\n", 
+    INFO("VNET Bridge: Link created, ip 0x%x, port: %d, idx: %d, link: %p, protocol: %s\n", 
           link->dst_ip, 
           link->dst_port, 
           link->idx, 
@@ -193,7 +194,7 @@ uint32_t vnet_brg_add_link(uint32_t ip, uint16_t port, vnet_brg_proto_t proto){
 
      idx = _create_link(new_link);
      if (idx < 0) {
-       printk("Could not create link\n");
+       WARNING("Could not create link\n");
        kfree(new_link);
        return -1;
      }
@@ -299,7 +300,7 @@ send_to_palacios(unsigned char * buf,
     pkt.data = buf;
 
     if(net_debug >= 2){
-       printk("VNET Lnx Bridge: send pkt to VNET core (size: %d, src_id: %d, src_type: %d)\n", 
+       DEBUG("VNET Lnx Bridge: send pkt to VNET core (size: %d, src_id: %d, src_type: %d)\n", 
                        pkt.size,  pkt.src_id, pkt.src_type);
        if(net_debug >= 4){
            print_hex_dump(NULL, "pkt_data: ", 0, 20, 20, pkt.data, pkt.size, 0);
@@ -320,7 +321,7 @@ bridge_send_pkt(struct v3_vm_info * vm,
     struct vnet_link * link;
 
     if(net_debug >= 2){
-       printk("VNET Lnx Host Bridge: packet received from VNET Core ... pkt size: %d, link: %d\n",
+       DEBUG("VNET Lnx Host Bridge: packet received from VNET Core ... pkt size: %d, link: %d\n",
                        pkt->size,
                        pkt->dst_id);
        if(net_debug >= 4){
@@ -342,13 +343,13 @@ bridge_send_pkt(struct v3_vm_info * vm,
                break;  
 
            default:
-               printk("VNET Server: Invalid Link Protocol\n");
+               WARNING("VNET Server: Invalid Link Protocol\n");
                vnet_brg_s.stats.pkt_drop_vmm ++;
        }
        link->stats.tx_bytes += pkt->size;
        link->stats.tx_pkts ++;
     } else {
-       printk("VNET Bridge Linux Host: wrong dst link, idx: %d, discards the packet\n", pkt->dst_id);
+       INFO("VNET Bridge Linux Host: wrong dst link, idx: %d, discards the packet\n", pkt->dst_id);
        vnet_brg_s.stats.pkt_drop_vmm ++;
     }
 
@@ -369,12 +370,12 @@ static int init_vnet_serv(void) {
            break;
 
        default:
-           printk("Unsupported VNET Server Protocol\n");
+           WARNING("Unsupported VNET Server Protocol\n");
            return -1;
     }
         
     if ((err = sock_create(AF_INET, SOCK_DGRAM, protocol, &vnet_brg_s.serv_sock)) < 0) {
-       printk("Could not create VNET server socket, error: %d\n", err);
+       WARNING("Could not create VNET server socket, error: %d\n", err);
        return -1;
     }
 
@@ -385,15 +386,15 @@ static int init_vnet_serv(void) {
     vnet_brg_s.serv_addr.sin_port = htons(VNET_SERVER_PORT);
 
     if ((err = vnet_brg_s.serv_sock->ops->bind(vnet_brg_s.serv_sock, (struct sockaddr *)&(vnet_brg_s.serv_addr), sizeof(struct sockaddr))) < 0) {
-       printk("Could not bind VNET server socket to port %d, error: %d\n", VNET_SERVER_PORT, err);
+       WARNING("Could not bind VNET server socket to port %d, error: %d\n", VNET_SERVER_PORT, err);
        return -1;
     }
 
-    printk("VNET server bind to port: %d\n", VNET_SERVER_PORT);
+    INFO("VNET server bind to port: %d\n", VNET_SERVER_PORT);
 
     if(vnet_brg_s.serv_proto == TCP){
        if((err = vnet_brg_s.serv_sock->ops->listen(vnet_brg_s.serv_sock, 32)) < 0){
-           printk("VNET Server error listening on port %d, error %d\n", VNET_SERVER_PORT, err);
+           WARNING("VNET Server error listening on port %d, error %d\n", VNET_SERVER_PORT, err);
            return -1;
        }
     }
@@ -407,20 +408,20 @@ static int _udp_server(void * arg) {
     struct vnet_link * link = NULL;
     int len;
 
-    printk("Palacios VNET Bridge: UDP receiving server ..... \n");
+    INFO("Palacios VNET Bridge: UDP receiving server ..... \n");
 
     pkt = kmalloc(MAX_PACKET_LEN, GFP_KERNEL);
     while (!kthread_should_stop()) {
        
        len = _udp_recv(vnet_brg_s.serv_sock, &pkt_addr, pkt, MAX_PACKET_LEN); 
        if(len < 0) {
-           printk("Receive error: Could not get packet, error %d\n", len);
+           WARNING("Receive error: Could not get packet, error %d\n", len);
            continue;
        }
 
        link = _link_by_ip(pkt_addr.sin_addr.s_addr);
        if (link == NULL){
-           printk("VNET Server: No VNET Link match the src IP\n");
+           WARNING("VNET Server: No VNET Link match the src IP\n");
            vnet_brg_s.stats.pkt_drop_phy ++;
            continue;
        }
@@ -447,7 +448,7 @@ static int _rx_server(void * arg) {
        //use select to receive pkt from physical network
        //or create new kthread to handle each connection?
     }else {
-       printk ("VNET Server: Unsupported Protocol\n");
+       WARNING ("VNET Server: Unsupported Protocol\n");
        return -1;
     }
 
@@ -480,12 +481,12 @@ int vnet_bridge_init(void) {
 
     vnet_brg_s.ip2link = vnet_create_htable(10, hash_fn, hash_eq);
     if(vnet_brg_s.ip2link == NULL){
-       printk("Failure to initiate VNET link hashtable\n");
+       WARNING("Failure to initiate VNET link hashtable\n");
        return -1;
     }
        
     if(init_vnet_serv() < 0){
-       printk("Failure to initiate VNET server\n");
+       WARNING("Failure to initiate VNET server\n");
        return -1;
     }
 
@@ -495,10 +496,10 @@ int vnet_bridge_init(void) {
     bridge_ops.poll = NULL;
        
     if( v3_vnet_add_bridge(NULL, &bridge_ops, HOST_LNX_BRIDGE, NULL) < 0){
-       printk("VNET LNX Bridge: Fails to register bridge to VNET core");
+       WARNING("VNET LNX Bridge: Fails to register bridge to VNET core");
     }
 
-    printk("VNET Linux Bridge initiated\n");
+    INFO("VNET Linux Bridge initiated\n");
 
     return 0;
 }
index 12dec1f..992556c 100644 (file)
@@ -22,6 +22,7 @@
 #include <vnet/vnet.h>
 #include <vnet/vnet_hashtable.h>
 #include "palacios-vnet.h"
+#include "palacios.h"
 
 #define VNET_SERVER_PORT 9000
 
@@ -64,7 +65,7 @@ static struct vnet_ctrl_state vnet_ctrl_s;
 static int parse_mac_str(char * str, uint8_t * qual, uint8_t * mac) {
     char * token;
 
-    printk("Parsing MAC (%s)\n", str);
+    INFO("Parsing MAC (%s)\n", str);
        
     *qual = MAC_NOSET;
     if(strnicmp("any", str, strlen(str)) == 0){
@@ -80,7 +81,7 @@ static int parse_mac_str(char * str, uint8_t * qual, uint8_t * mac) {
            if (strnicmp("not", token, strlen("not")) == 0) {
                *qual = MAC_NOT;
            } else {
-               printk("Invalid MAC String token (%s)\n", token);
+               WARNING("Invalid MAC String token (%s)\n", token);
                return -1;
            }
        }
@@ -95,15 +96,15 @@ static int parse_mac_str(char * str, uint8_t * qual, uint8_t * mac) {
            for (i = 0; i < 6; i++) {
                token = strsep(&str, ":");
                if (!token) {
-                   printk("Invalid MAC String token (%s)\n", token);
+                   WARNING("Invalid MAC String token (%s)\n", token);
                    return -1;
                }
                mac[i] = simple_strtol(token, &token, 16);
            }
-           printk("MAC: %2x:%2x:%2x:%2x:%2x:%2x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+           DEBUG("MAC: %2x:%2x:%2x:%2x:%2x:%2x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
                
        }else {
-           printk("Invalid MAC String token (%s)\n", token);
+           WARNING("Invalid MAC String token (%s)\n", token);
            return -1;
        }
                
@@ -120,7 +121,7 @@ static int str2mac(char * str, uint8_t * mac){
     for (i = 0; i < ETH_ALEN; i++) {           
        hex = strsep(&str, ":");
        if (!hex) {
-           printk("Invalid MAC String token (%s)\n", str);
+           WARNING("Invalid MAC String token (%s)\n", str);
            return -1;
        }
        mac[i] = simple_strtol(hex, &hex, 16);
@@ -179,14 +180,14 @@ static int parse_route_str(char * str, struct v3_vnet_route * route) {
     if (!token) {
        return -1;
     }
-    printk("dst type =(%s)\n", token);
+    INFO("dst type =(%s)\n", token);
     
     if (strnicmp("interface", token, strlen("interface")) == 0) {
        route->dst_type = LINK_INTERFACE;
     } else if (strnicmp("edge", token, strlen("edge")) == 0) {
        route->dst_type = LINK_EDGE;
     } else {
-       printk("Invalid Destination Link Type (%s)\n", token);
+       WARNING("Invalid Destination Link Type (%s)\n", token);
        return -1;
     }
 
@@ -195,7 +196,7 @@ static int parse_route_str(char * str, struct v3_vnet_route * route) {
     if (!token) {
        return -1;
     }
-    printk("dst ID=(%s)\n", token);
+    DEBUG("dst ID=(%s)\n", token);
 
     // Figure out link here
     if (route->dst_type == LINK_EDGE) {
@@ -203,7 +204,7 @@ static int parse_route_str(char * str, struct v3_vnet_route * route) {
 
        // Figure out Link Here
        if (in4_pton(token, strlen(token), (uint8_t *)&(link_ip), '\0', NULL) != 1) {
-           printk("Invalid Dst IP address (%s)\n", token);
+           WARNING("Invalid Dst IP address (%s)\n", token);
            return -EFAULT;
        }
 
@@ -211,26 +212,26 @@ static int parse_route_str(char * str, struct v3_vnet_route * route) {
        if (link != NULL){
            route->dst_id = link->idx;
        }else{
-           printk("can not find dst link %s\n", token);
+           WARNING("can not find dst link %s\n", token);
            return -1;
        }
 
-       printk("link_ip = %d, link_id = %d\n", link_ip, link->idx);     
+       INFO("link_ip = %d, link_id = %d\n", link_ip, link->idx);       
     } else if (route->dst_type == LINK_INTERFACE) {
        uint8_t mac[ETH_ALEN];
        
        if(str2mac(token, mac) == -1){
-          printk("wrong MAC format (%s)\n", token);
+          WARNING("wrong MAC format (%s)\n", token);
           return -1;
        }
           
        route->dst_id = v3_vnet_find_dev(mac);
        if (route->dst_id == -1){
-           printk("can not find dst device %s\n", token);
+           WARNING("can not find dst device %s\n", token);
            return -1;
        }               
     } else {
-       printk("Unsupported dst link type\n");
+       WARNING("Unsupported dst link type\n");
        return -1;
     }
 
@@ -240,7 +241,7 @@ static int parse_route_str(char * str, struct v3_vnet_route * route) {
     // src LINK
     token = strsep(&str, " ");
 
-    printk("SRC type = %s\n", token);
+    INFO("SRC type = %s\n", token);
 
     if (!token) {
        return -1;
@@ -253,7 +254,7 @@ static int parse_route_str(char * str, struct v3_vnet_route * route) {
     } else if (strnicmp("any", token, strlen("any")) == 0) {
        route->src_type = LINK_ANY;
     } else {
-       printk("Invalid Src link type (%s)\n", token);
+       WARNING("Invalid Src link type (%s)\n", token);
        return -1;
     }
 
@@ -270,7 +271,7 @@ static int parse_route_str(char * str, struct v3_vnet_route * route) {
 
        // Figure out Link Here
        if (in4_pton(token, strlen(token), (uint8_t *)&(src_ip), '\0', NULL) != 1) {
-           printk("Invalid SRC IP address (%s)\n", token);
+           WARNING("Invalid SRC IP address (%s)\n", token);
            return -EFAULT;
        }
 
@@ -278,24 +279,24 @@ static int parse_route_str(char * str, struct v3_vnet_route * route) {
        if (link != NULL){
            route->src_id = link->idx;
        }else{
-           printk("can not find src link %s\n", token);
+           WARNING("can not find src link %s\n", token);
            return -1;
        }
     } else if(route->src_type == LINK_INTERFACE){
        uint8_t mac[ETH_ALEN];
        
        if(str2mac(token, mac) == -1){
-          printk("wrong MAC format (%s)\n", token);
+          WARNING("wrong MAC format (%s)\n", token);
           return -1;
        }
           
        route->src_id = v3_vnet_find_dev(mac);
        if (route->src_id == -1){
-           printk("can not find dst device %s\n", token);
+           WARNING("can not find dst device %s\n", token);
            return -1;
        }               
     } else {
-       printk("Invalid link type\n");
+       WARNING("Invalid link type\n");
        return -1;
     }
 
@@ -525,7 +526,7 @@ static int inject_route(struct vnet_route_iter * route) {
     vnet_ctrl_s.num_routes ++;
     spin_unlock_irqrestore(&(vnet_ctrl_s.lock), flags);
 
-    printk("VNET Control: One route added to VNET core\n");
+    INFO("VNET Control: One route added to VNET core\n");
 
     return 0;
 }
@@ -541,7 +542,7 @@ static void delete_route(struct vnet_route_iter * route) {
     vnet_ctrl_s.num_routes --;
     spin_unlock_irqrestore(&(vnet_ctrl_s.lock), flags);
 
-    printk("VNET Control: Route %d deleted from VNET\n", route->idx);
+    INFO("VNET Control: Route %d deleted from VNET\n", route->idx);
 
     kfree(route);
     route = NULL;
@@ -581,7 +582,7 @@ route_write(struct file * file,
     }
 
     route_buf[size] = '\0';
-    printk("Route written: %s\n", route_buf);
+    INFO("Route written: %s\n", route_buf);
 
     while ((buf_iter = strsep(&line_str, "\r\n"))) {
 
@@ -617,13 +618,13 @@ route_write(struct file * file,
            idx_str = strsep(&buf_iter, " ");
            
            if (!idx_str) {
-               printk("Missing route idx in DEL Route command\n");
+               WARNING("Missing route idx in DEL Route command\n");
                return -EFAULT;
            }
 
            d_idx = simple_strtoul(idx_str, &idx_str, 10);
 
-           printk("VNET: deleting route %d\n", d_idx);
+           INFO("VNET: deleting route %d\n", d_idx);
 
            list_for_each_entry(route, &(vnet_ctrl_s.route_list), node) {
                if (route->idx == d_idx) {
@@ -632,7 +633,7 @@ route_write(struct file * file,
                }
            }
        } else {
-           printk("Invalid Route command string\n");
+           WARNING("Invalid Route command string\n");
        }
     }
 
@@ -689,7 +690,7 @@ link_write(struct file * file, const char * buf, size_t size, loff_t * ppos) {
     }
 
     while ((link_iter = strsep(&line_str, "\r\n"))) {
-       printk("Link written: %s\n", link_buf);
+       DEBUG("Link written: %s\n", link_buf);
        
        token = strsep(&link_iter, " ");
        
@@ -709,12 +710,12 @@ link_write(struct file * file, const char * buf, size_t size, loff_t * ppos) {
            ip_str = strsep(&link_iter, " ");
            
            if ((!ip_str) || (!link_iter)) {
-               printk("Missing fields in ADD Link command\n");
+               WARNING("Missing fields in ADD Link command\n");
                return -EFAULT;
            }
            
            if (in4_pton(ip_str, strlen(ip_str), (uint8_t *)&(d_ip), '\0', NULL) != 1) {
-               printk("Invalid Dst IP address (%s)\n", ip_str);
+               WARNING("Invalid Dst IP address (%s)\n", ip_str);
                return -EFAULT;
            }
 
@@ -723,7 +724,7 @@ link_write(struct file * file, const char * buf, size_t size, loff_t * ppos) {
 
            link_idx = vnet_brg_add_link(d_ip, d_port, d_proto);
            if(link_idx < 0){
-               printk("VNET Control: Failed to create link\n");
+               WARNING("VNET Control: Failed to create link\n");
                return -EFAULT;
            }
 
@@ -746,7 +747,7 @@ link_write(struct file * file, const char * buf, size_t size, loff_t * ppos) {
            idx_str = strsep(&link_iter, " ");
            
            if (!idx_str) {
-               printk("Missing link idx in DEL Link command\n");
+               WARNING("Missing link idx in DEL Link command\n");
                return -EFAULT;
            }
 
@@ -754,9 +755,9 @@ link_write(struct file * file, const char * buf, size_t size, loff_t * ppos) {
 
            vnet_brg_delete_link(d_idx);
                
-           printk("VNET Control: One link deleted\n");         
+           DEBUG("VNET Control: One link deleted\n");          
        } else {
-           printk("Invalid Link command string\n");
+           WARNING("Invalid Link command string\n");
        }
     }
 
@@ -802,7 +803,7 @@ debug_write(struct file * file, const char * buf, size_t size, loff_t * ppos) {
     in_iter = strsep(&line_str, "\r\n");
     level = simple_strtol(in_iter, &in_iter, 10);
 
-    printk("VNET Control: Set VNET Debug level to %d\n", level);
+    DEBUG("VNET Control: Set VNET Debug level to %d\n", level);
 
     if(level >= 0){
        net_debug = level;
@@ -949,7 +950,7 @@ int vnet_ctrl_init(void) {
 
     init_proc_files();
        
-    printk("VNET Linux control module initiated\n");
+    NOTICE("VNET Linux control module initiated\n");
 
     return 0;
 }
index 4aaa8d5..f13a0a9 100644 (file)
@@ -284,7 +284,7 @@ static int vnet_init( void ) {
     vnet_bridge_init();
     vnet_ctrl_init();
 
-    printk("V3 VNET Inited\n");
+    INFO("V3 VNET Inited\n");
         
     return 0;
 }
@@ -296,7 +296,7 @@ static int vnet_deinit( void ) {
     vnet_bridge_deinit();
     vnet_ctrl_deinit();
 
-    printk("V3 VNET Deinited\n");
+    INFO("V3 VNET Deinited\n");
 
     return 0;
 }
index e2b621a..88e3bef 100644 (file)
@@ -72,7 +72,7 @@ int add_guest_ctrl(struct v3_guest * guest, unsigned int cmd,
     struct vm_ctrl * ctrl = kmalloc(sizeof(struct vm_ctrl), GFP_KERNEL);
 
     if (ctrl == NULL) {
-       printk("Error: Could not allocate vm ctrl %d\n", cmd);
+       WARNING("Error: Could not allocate vm ctrl %d\n", cmd);
        return -1;
     }
 
@@ -81,7 +81,7 @@ int add_guest_ctrl(struct v3_guest * guest, unsigned int cmd,
     ctrl->priv_data = priv_data;
 
     if (__insert_ctrl(guest, ctrl) != NULL) {
-       printk("Could not insert guest ctrl %d\n", cmd);
+       WARNING("Could not insert guest ctrl %d\n", cmd);
        kfree(ctrl);
        return -1;
     }
@@ -125,24 +125,24 @@ static long v3_vm_ioctl(struct file * filp,
 
     struct v3_guest * guest = filp->private_data;
 
-    printk("V3 IOCTL %d\n", ioctl);
+    INFO("V3 IOCTL %d\n", ioctl);
 
     switch (ioctl) {
        case V3_VM_LAUNCH: {
-           printk("palacios: launching vm\n");
+           NOTICE("palacios: launching vm\n");
 
            if (v3_start_vm(guest->v3_ctx, (0x1 << num_online_cpus()) - 1) < 0) { 
-               printk("palacios: launch of vm failed\n");
+               WARNING("palacios: launch of vm failed\n");
                return -1;
            }
            
            break;
        }
        case V3_VM_STOP: {
-           printk("Stopping VM (%s) (%p)\n", guest->name, guest);
+           NOTICE("Stopping VM (%s) (%p)\n", guest->name, guest);
 
            if (irqs_disabled()) {
-               printk("WHAT!!?? IRQs are disabled??\n");
+               ERROR("WHAT!!?? IRQs are disabled??\n");
                break;
            }
 
@@ -150,17 +150,17 @@ static long v3_vm_ioctl(struct file * filp,
            break;
        }
        case V3_VM_PAUSE: {
-           printk("Pausing VM (%s)\n", guest->name);
+           NOTICE("Pausing VM (%s)\n", guest->name);
            v3_pause_vm(guest->v3_ctx);
            break;
        }
        case V3_VM_CONTINUE: {
-           printk("Continuing VM (%s)\n", guest->name);
+           NOTICE("Continuing VM (%s)\n", guest->name);
            v3_continue_vm(guest->v3_ctx);
            break;
        }
        case V3_VM_SIMULATE: {
-           printk("Simulating VM (%s) for %lu msecs\n", guest->name, arg);
+           NOTICE("Simulating VM (%s) for %lu msecs\n", guest->name, arg);
            v3_simulate_vm(guest->v3_ctx, arg);
            break;
        }
@@ -174,14 +174,14 @@ static long v3_vm_ioctl(struct file * filp,
            memset(&chkpt, 0, sizeof(struct v3_chkpt_info));
 
            if (copy_from_user(&chkpt, argp, sizeof(struct v3_chkpt_info))) {
-               printk("Copy from user error getting checkpoint info\n");
+               WARNING("Copy from user error getting checkpoint info\n");
                return -EFAULT;
            }
            
-           printk("Saving Guest to %s:%s\n", chkpt.store, chkpt.url);
+           NOTICE("Saving Guest to %s:%s\n", chkpt.store, chkpt.url);
 
            if (v3_save_vm(guest->v3_ctx, chkpt.store, chkpt.url) == -1) {
-               printk("Error checkpointing VM state\n");
+               WARNING("Error checkpointing VM state\n");
                return -EFAULT;
            }
            
@@ -194,14 +194,14 @@ static long v3_vm_ioctl(struct file * filp,
            memset(&chkpt, 0, sizeof(struct v3_chkpt_info));
 
            if (copy_from_user(&chkpt, argp, sizeof(struct v3_chkpt_info))) {
-               printk("Copy from user error getting checkpoint info\n");
+               WARNING("Copy from user error getting checkpoint info\n");
                return -EFAULT;
            }
            
-           printk("Loading Guest to %s:%s\n", chkpt.store, chkpt.url);
+           NOTICE("Loading Guest to %s:%s\n", chkpt.store, chkpt.url);
 
            if (v3_load_vm(guest->v3_ctx, chkpt.store, chkpt.url) == -1) {
-               printk("Error Loading VM state\n");
+               WARNING("Error Loading VM state\n");
                return -EFAULT;
            }
            
@@ -215,11 +215,11 @@ static long v3_vm_ioctl(struct file * filp,
            memset(&cmd, 0, sizeof(struct v3_core_move_cmd));
            
            if (copy_from_user(&cmd, argp, sizeof(struct v3_core_move_cmd))) {
-               printk("copy from user error getting migrate command...\n");
+               WARNING("copy from user error getting migrate command...\n");
                return -EFAULT;
            }
        
-           printk("moving guest %s vcore %d to CPU %d\n", guest->name, cmd.vcore_id, cmd.pcore_id);
+           INFO("moving guest %s vcore %d to CPU %d\n", guest->name, cmd.vcore_id, cmd.pcore_id);
 
            v3_move_vm_core(guest->v3_ctx, cmd.vcore_id, cmd.pcore_id);
 
@@ -233,7 +233,7 @@ static long v3_vm_ioctl(struct file * filp,
            }
            
            
-           printk("\tUnhandled ctrl cmd: %d\n", ioctl);
+           WARNING("\tUnhandled ctrl cmd: %d\n", ioctl);
            return -EINVAL;
        }
     }
@@ -283,12 +283,12 @@ int create_palacios_vm(struct v3_guest * guest)  {
     guest->v3_ctx = v3_create_vm(guest->img, (void *)guest, guest->name);
 
     if (guest->v3_ctx == NULL) { 
-       printk("palacios: failed to create vm\n");
+       WARNING("palacios: failed to create vm\n");
        return -1;
     }
 
 
-    printk("Creating VM device: Major %d, Minor %d\n", MAJOR(guest->vm_dev), MINOR(guest->vm_dev));
+    NOTICE("Creating VM device: Major %d, Minor %d\n", MAJOR(guest->vm_dev), MINOR(guest->vm_dev));
 
     cdev_init(&(guest->cdev), &v3_vm_fops);
 
@@ -296,23 +296,23 @@ int create_palacios_vm(struct v3_guest * guest)  {
     guest->cdev.ops = &v3_vm_fops;
 
 
-    printk("Adding VM device\n");
+    INFO("Adding VM device\n");
     err = cdev_add(&(guest->cdev), guest->vm_dev, 1);
 
     if (err) {
-       printk("Fails to add cdev\n");
+       WARNING("Fails to add cdev\n");
        v3_free_vm(guest->v3_ctx);
        return -1;
     }
 
     if (device_create(v3_class, NULL, guest->vm_dev, guest, "v3-vm%d", MINOR(guest->vm_dev)) == NULL){
-       printk("Fails to create device\n");
+       WARNING("Fails to create device\n");
        cdev_del(&(guest->cdev));
        v3_free_vm(guest->v3_ctx);
        return -1;
     }
 
-    printk("palacios: vm created at /dev/v3-vm%d\n", MINOR(guest->vm_dev));
+    NOTICE("palacios: vm created at /dev/v3-vm%d\n", MINOR(guest->vm_dev));
 
     return 0;
 }