/* Create a virtual ethernet switch */ ethsw_table_t *ethsw_create(char *name) { ethsw_table_t *t; /* Allocate a new switch structure */ if (!(t = malloc(sizeof(*t)))) return NULL; memset(t,0,sizeof(*t)); pthread_mutex_init(&t->lock,NULL); if (!(t->name = strdup(name))) goto err_name; /* Record this object in registry */ if (registry_add(t->name,OBJ_TYPE_ETHSW,t) == -1) { fprintf(stderr,"ethsw_create: unable to register switch '%s'\n",name); goto err_reg; } return t; err_reg: free(t->name); err_name: free(t); return NULL; }
/* Create a virtual ATM bridge */ atm_bridge_t *atm_bridge_create(char *name) { atm_bridge_t *t; /* Allocate a new switch structure */ if (!(t = malloc(sizeof(*t)))) return NULL; memset(t,0,sizeof(*t)); pthread_mutex_init(&t->lock,NULL); atm_aal5_recv_reset(&t->arc); if (!(t->name = strdup(name))) goto err_name; /* Record this object in registry */ if (registry_add(t->name,OBJ_TYPE_ATM_BRIDGE,t) == -1) { fprintf(stderr,"atm_bridge_create: unable to create bridge '%s'\n", name); goto err_reg; } return t; err_reg: free(t->name); err_name: free(t); return NULL; }
/* Create a new VM instance */ static vm_instance_t *vm_create(char *name,int instance_id, vm_platform_t *platform) { vm_instance_t *vm; if (!(vm = malloc(sizeof(*vm)))) { fprintf(stderr,"VM %s: unable to create new instance!\n",name); return NULL; } memset(vm,0,sizeof(*vm)); if (!(vm->name = strdup(name))) { fprintf(stderr,"VM %s: unable to store instance name!\n",name); goto err_name; } vm->instance_id = instance_id; vm->platform = platform; vm->status = VM_STATUS_HALTED; vm->jit_use = JIT_SUPPORT; vm->exec_blk_direct_jump = TRUE; vm->vtty_con_type = VTTY_TYPE_TERM; vm->vtty_aux_type = VTTY_TYPE_NONE; vm->timer_irq_check_itv = VM_TIMER_IRQ_CHECK_ITV; vm->log_file_enabled = TRUE; vm->rommon_vars.filename = vm_build_filename(vm,"rommon_vars"); if (!vm->rommon_vars.filename) goto err_rommon; /* XXX */ rommon_load_file(&vm->rommon_vars); /* create lock file */ if (vm_get_lock(vm) == -1) goto err_lock; /* create log file */ if (vm_create_log(vm) == -1) goto err_log; if (registry_add(vm->name,OBJ_TYPE_VM,vm) == -1) { fprintf(stderr,"VM: Unable to store instance '%s' in registry!\n", vm->name); goto err_reg_add; } m_log("VM","VM %s created.\n",vm->name); return vm; err_reg_add: vm_close_log(vm); err_log: free(vm->lock_file); err_lock: free(vm->rommon_vars.filename); err_rommon: free(vm->name); err_name: free(vm); return NULL; }
/* Record an NIO in registry */ static int netio_record(netio_desc_t *nio) { return(registry_add(nio->name,OBJ_TYPE_NIO,nio)); }
static void ev_global(k_u32 name,enum wl_itfs itf) { registry_add(name,itf); }