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.


Bug fix and cleanup
Peter Dinda [Sun, 24 Aug 2014 20:22:17 +0000 (15:22 -0500)]
- fix create/start thread distinction
- clean up distinction to make it clearer what happens throughout vmm and kernel module
- compilation tweak for swapping

linux_module/palacios-stubs.c
linux_module/palacios-vnet.c
linux_module/palacios.h
palacios/include/palacios/vmm.h
palacios/include/palacios/vmm_swapping.h
palacios/src/devices/telnet_cons.c
palacios/src/palacios/vmm_swapping.c

index 90b3ad4..5ef9c5c 100644 (file)
@@ -84,7 +84,7 @@ static int init_print_buffers(void)
        if (!print_buffer[i]) { 
            ERROR("Cannot allocate print buffer for cpu %d\n",i);
            deinit_print_buffers();
-           return -1;
+    return -1;
        }
        memset(print_buffer[i],0,V3_PRINTK_BUF_SIZE);
     }
@@ -417,7 +417,7 @@ static int lnx_thread_target(void * arg) {
  * Creates a kernel thread.
  */
 void *
-palacios_start_kernel_thread(
+palacios_create_and_start_kernel_thread(
        int (*fn)               (void * arg),
        void *                  arg,
        char *                  thread_name) {
@@ -484,6 +484,27 @@ palacios_start_thread(void * th){
        wake_up_process(thread);
 
 }
+
+/*
+  Convenience wrapper
+*/
+void * 
+palacios_create_and_start_thread_on_cpu(int cpu_id,
+                                       int (*fn)(void * arg), 
+                                       void * arg, 
+                                       char * thread_name ) {
+
+    void *t = palacios_create_thread_on_cpu(cpu_id, fn, arg, thread_name);
+
+    if (t) { 
+       palacios_start_thread(t);
+    } 
+    
+    return t;
+}
+
+
+
 /**
  * Rebind a kernel thread to the specified CPU
  * The thread will be running on target CPU on return
@@ -849,7 +870,7 @@ static struct v3_os_hooks palacios_os_hooks = {
        .hook_interrupt         = palacios_hook_interrupt,
        .ack_irq                = palacios_ack_interrupt,
        .get_cpu_khz            = palacios_get_cpu_khz,
-       .start_kernel_thread    = palacios_start_kernel_thread,
+       .start_kernel_thread    = palacios_create_and_start_kernel_thread,
        .yield_cpu              = palacios_yield_cpu,
        .sleep_cpu              = palacios_sleep_cpu,
        .wakeup_cpu             = palacios_wakeup_cpu,
@@ -862,7 +883,7 @@ static struct v3_os_hooks palacios_os_hooks = {
        .get_cpu                = palacios_get_cpu,
        .interrupt_cpu          = palacios_interrupt_cpu,
        .call_on_cpu            = palacios_xcall,
-       .create_thread_on_cpu   = palacios_start_thread_on_cpu,
+       .create_thread_on_cpu   = palacios_create_thread_on_cpu,
        .start_thread           = palacios_start_thread,
        .move_thread_to_cpu     = palacios_move_thread_to_cpu,
 };
index 4b23772..014d191 100644 (file)
@@ -155,7 +155,7 @@ static struct vnet_host_hooks vnet_host_hooks = {
     .timer_stop                        = host_stop_timer,
     .timer_reset               = host_reset_timer,
 
-    .thread_start              = palacios_start_kernel_thread,
+    .thread_start              = palacios_create_and_start_kernel_thread,
     .thread_sleep              = host_kthread_sleep,
     .thread_wakeup             = host_kthread_wakeup,
     .thread_stop               = host_kthread_stop,
index 3c023ff..f254522 100644 (file)
@@ -163,8 +163,10 @@ void *palacios_valloc(unsigned int size); // use instead of vmalloc
 void  palacios_vfree(void *);             // use instead of vfree
 void *palacios_vaddr_to_paddr(void *vaddr);
 void *palacios_paddr_to_vaddr(void *paddr);
-void *palacios_start_kernel_thread(int (*fn)(void * arg), void *arg, char *thread_name);
-void *palacios_start_thread_on_cpu(int cpu_id, int (*fn)(void * arg), void *arg, char *thread_name);
+void *palacios_create_and_start_kernel_thread(int (*fn)(void * arg), void *arg, char *thread_name);
+void *palacios_create_thread_on_cpu(int cpu_id, int (*fn)(void * arg), void *arg, char *thread_name);
+void  palacios_start_thread(void *thread_ptr);
+void *palacios_creeate_and_start_thread_on_cpu(int cpu_id, int (*fn)(void * arg), void *arg, char *thread_name);
 int   palacios_move_thread_to_cpu(int new_cpu_id, void *thread_ptr);
 void  palacios_yield_cpu(void);
 void  palacios_sleep_cpu(unsigned int us);
index db94298..9071fb7 100644 (file)
@@ -192,7 +192,7 @@ int      v3_get_vcore(struct guest_info *);
 
 
 
-#define V3_CREATE_THREAD(fn, arg, name)        ({                              \
+#define V3_CREATE_AND_START_THREAD(fn, arg, name)      ({              \
            void * thread = NULL;                                       \
            extern struct v3_os_hooks * os_hooks;                       \
            if ((os_hooks) && (os_hooks)->start_kernel_thread) {        \
@@ -230,6 +230,14 @@ int      v3_get_vcore(struct guest_info *);
        }                                                               \
   })
 
+#define V3_CREATE_AND_START_THREAD_ON_CPU(cpu, fn, arg, name) ({        \
+           void *thread = V3_CREATE_THREAD_ON_CPU(cpu,fn,arg,name);    \
+           if (thread) {                                               \
+               V3_START_THREAD(thread);                                \
+            }                                                           \
+            thread;                                                     \
+       })
+
 #define V3_MOVE_THREAD_TO_CPU(pcpu, thread) ({                         \
        int ret = -1;                                                   \
        extern struct v3_os_hooks * os_hooks;                           \
index ea5deb6..a5e1d3f 100644 (file)
@@ -59,12 +59,12 @@ struct v3_swap_region_state {
 
 struct v3_mem_region;
 
-typedef struct v3_xml v3_cfg_tree_t;
+struct v3_xml;
 
 int v3_init_swapping();
 int v3_deinit_swapping();
 
-int v3_init_swapping_vm(struct v3_vm_info *vm, v3_cfg_tree_t *config);
+int v3_init_swapping_vm(struct v3_vm_info *vm, struct v3_xml *config);
 int v3_deinit_swapping_vm(struct v3_vm_info *vm);
 
 // not needed yet
index 4e7471b..5ba8a1b 100644 (file)
@@ -555,7 +555,7 @@ static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
 
     v3_console_register_cga(frontend, &cons_ops, state);
 
-    V3_CREATE_THREAD(cons_server, state, "Telnet Console Network Server");
+    V3_CREATE_AND_START_THREAD(cons_server, state, "Telnet Console Network Server");
 
     return 0;
 }
index a24ef42..90475d1 100644 (file)
@@ -103,7 +103,7 @@ static int read_all(v3_file_t fd, void *buf, uint64_t len, uint64_t offset)
 
 #define CEIL_DIV(x,y) (((x)/(y)) + !!((x)%(y)))
 
-int v3_init_swapping_vm(struct v3_vm_info *vm, v3_cfg_tree_t *config)
+int v3_init_swapping_vm(struct v3_vm_info *vm, struct v3_xml *config)
 {
     v3_cfg_tree_t *swap_config;
     char *enable;