X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fvnet%2Fvnet_host.c;h=459f6b7358e2888f04eabd0e4e9eb68f381cf025;hb=a5264d4dcf50d633e01e92dba62a5cf00c3bae2a;hp=9d3bb31dd47d22c5d981bb9e867fdf91bd64cf1a;hpb=f904d129c5f7f44493bba3c9a82c150bbb613217;p=palacios.git diff --git a/palacios/src/vnet/vnet_host.c b/palacios/src/vnet/vnet_host.c index 9d3bb31..459f6b7 100644 --- a/palacios/src/vnet/vnet_host.c +++ b/palacios/src/vnet/vnet_host.c @@ -22,47 +22,45 @@ struct vnet_host_hooks * host_hooks; +struct vnet_thread * vnet_start_thread(int (*func)(void *), void *arg, char * name){ + if((host_hooks) && host_hooks->thread_start){ -int vnet_lock_init(vnet_lock_t * lock) { - *lock = (addr_t)(host_hooks->mutex_alloc()); - - if (!(*lock)) { - return -1; - } - - return 0; -} - + struct vnet_thread * thread = Vnet_Malloc(sizeof(struct vnet_thread)); -struct vnet_thread * vnet_start_thread(int (*func)(void *), void *arg, char * name){ - struct vnet_thread * thread; + if (!thread) { + PrintError("Cannot allocate space to create a vnet thread\n"); + return NULL; + } - thread = Vnet_Malloc(sizeof(struct vnet_thread)); - - thread->host_thread = host_hooks->thread_start(func, arg, name); + thread->host_thread = host_hooks->thread_start(func, arg, name); - if(thread->host_thread == NULL){ + if(thread->host_thread){ + return thread; + } Vnet_Free(thread); - return NULL; } - return thread; + return NULL; } - struct vnet_timer * vnet_create_timer(unsigned long interval, void (* timer_fun)(void * priv_data), void * priv_data){ - struct vnet_timer * timer = NULL; - if((host_hooks) && host_hooks->timer_create){ - timer = Vnet_Malloc(sizeof(struct vnet_timer)); + struct vnet_timer * timer = Vnet_Malloc(sizeof(struct vnet_timer)); + + if (!timer) { + PrintError("Cannot allocate space to create a vnet timer\n"); + return NULL; + } timer->host_timer = host_hooks->timer_create(interval, timer_fun, priv_data); + + return timer; } - return timer; + return NULL; } @@ -72,3 +70,8 @@ void init_vnet(struct vnet_host_hooks * hooks){ } +void deinit_vnet(){ + v3_deinit_vnet(); + // host_hooks = NULL; +} +