X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fvnet%2Fvnet_host.c;h=c5d366a50890a5855ffa9b9a5c2d66a8d71a0258;hb=43ad442bb80368840b97aa2e099a672ca6f7569b;hp=ea64c6d4a9f38e6a2c56135bac66565830153245;hpb=6cff7c8b0ec58e3b94d9583f709ca9056ae928dd;p=palacios.git diff --git a/palacios/src/vnet/vnet_host.c b/palacios/src/vnet/vnet_host.c index ea64c6d..c5d366a 100644 --- a/palacios/src/vnet/vnet_host.c +++ b/palacios/src/vnet/vnet_host.c @@ -22,46 +22,45 @@ struct vnet_host_hooks * host_hooks; - int vnet_lock_init(vnet_lock_t * lock) { - *lock = (addr_t)(host_hooks->mutex_alloc()); - - if (!(*lock)) { - return -1; + if((host_hooks) && host_hooks->mutex_alloc){ + *lock = (addr_t)(host_hooks->mutex_alloc()); + + if (*lock) { + return 0; + } } - return 0; + return -1; } struct vnet_thread * vnet_start_thread(int (*func)(void *), void *arg, char * name){ - struct vnet_thread * thread; - - thread = Vnet_Malloc(sizeof(struct vnet_thread)); - - thread->host_thread = host_hooks->thread_start(func, arg, name); + if((host_hooks) && host_hooks->thread_start){ + struct vnet_thread * thread = Vnet_Malloc(sizeof(struct vnet_thread)); + 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; - + void (* timer_fun)(void * priv_data), + void * priv_data){ if((host_hooks) && host_hooks->timer_create){ - timer = Vnet_Malloc(sizeof(struct vnet_timer)); - + struct vnet_timer * timer = Vnet_Malloc(sizeof(struct vnet_timer)); timer->host_timer = host_hooks->timer_create(interval, timer_fun, priv_data); + return timer; } - return timer; + return NULL; } @@ -71,3 +70,8 @@ void init_vnet(struct vnet_host_hooks * hooks){ } +void deinit_vnet(){ + host_hooks = NULL; + v3_deinit_vnet(); +} +