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.


5d0c3bfa9084cea10536e545755f4b9a080e2f05
[palacios.git] / palacios / src / vnet / vnet_host.c
1 /* 
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2011, Lei Xia <lxia@northwestern.edu> 
11  * Copyright (c) 2011, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Lei Xia <lxia@northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19  
20 #include <vnet/vnet_host.h>
21 #include <vnet/vnet.h>
22
23 struct vnet_host_hooks * host_hooks;
24
25 struct vnet_thread * vnet_start_thread(int (*func)(void *), void *arg, char * name){
26     if((host_hooks) && host_hooks->thread_start){
27
28         struct vnet_thread * thread = Vnet_Malloc(sizeof(struct vnet_thread));
29
30         if (!thread) {
31             PrintError(VM_NONE, VCORE_NONE, "Cannot allocate space to create a vnet thread\n");
32             return NULL;
33         }
34
35         thread->host_thread = host_hooks->thread_start(func, arg, name);
36
37         if(thread->host_thread){
38             return thread;
39         }
40         Vnet_Free(thread);
41     }
42
43     return NULL;
44 }
45
46
47 struct vnet_timer * vnet_create_timer(unsigned long interval, 
48                                       void (* timer_fun)(void * priv_data), 
49                                       void * priv_data){
50     if((host_hooks) && host_hooks->timer_create){
51         struct vnet_timer * timer = Vnet_Malloc(sizeof(struct vnet_timer));
52
53         if (!timer) {
54             PrintError(VM_NONE, VCORE_NONE, "Cannot allocate space to create a vnet timer\n");
55             return NULL;
56         }
57
58         timer->host_timer = host_hooks->timer_create(interval, timer_fun, priv_data);
59
60         return timer;
61     }
62
63     return NULL;
64  }
65
66
67 void init_vnet(struct vnet_host_hooks * hooks){
68     host_hooks = hooks;
69     v3_init_vnet();
70 }
71
72
73 void deinit_vnet(){
74     v3_deinit_vnet();
75     //    host_hooks = NULL;
76 }
77