/* Free resources used by a router instance */ static int c3725_delete_instance(vm_instance_t *vm) { c3725_t *router = VM_C3725(vm); int i; /* Stop all CPUs */ if (vm->cpu_group != NULL) { vm_stop(vm); if (cpu_group_sync_state(vm->cpu_group) == -1) { vm_error(vm,"unable to sync with system CPUs.\n"); return(FALSE); } } /* Remove NIO bindings */ for(i=0;i<vm->nr_slots;i++) vm_slot_remove_all_nio_bindings(vm,i); /* Shutdown all Network Modules */ vm_slot_shutdown_all(vm); /* Free mainboard EEPROM */ cisco_eeprom_free(&router->mb_eeprom); /* Free all resources used by VM */ vm_free(vm); /* Free the router structure */ free(router); return(TRUE); }
/* Remove a slot binding */ int vm_slot_remove_binding(vm_instance_t *vm,u_int slot_id,u_int port_id) { struct cisco_card **rc,*sc; u_int i,real_port_id; if (vm_slot_get_info(vm,slot_id,port_id,&rc,&real_port_id) == -1) return(-1); if (*rc == NULL) return(-1); if ((*rc)->drv_info != NULL) { vm_error(vm,"slot %u/%u is still active\n",slot_id,port_id); return(-1); } for(i=0;i<CISCO_CARD_MAX_SUBSLOTS;i++) { if ((sc = (*rc)->sub_slots[i]) != NULL) { vm_error(vm,"sub-slot %u/%u is still active\n", slot_id,sc->subslot_id); return(-1); } } /* Remove all NIOs bindings */ vm_slot_remove_all_nio_bindings(vm,slot_id); /* Free the card info structure */ free(*rc); *rc = NULL; return(0); }