int V3_deinit_devices() {
- v3_free_htable(master_dev_table, 0, 0);
+ if (master_dev_table) {
+ v3_free_htable(master_dev_table, 0, 0);
+ master_dev_table=0;
+ }
return 0;
}
mgr->net_table = v3_create_htable(0, dev_hash_fn, dev_eq_fn);
mgr->char_table = v3_create_htable(0, dev_hash_fn, dev_eq_fn);
mgr->cons_table = v3_create_htable(0, dev_hash_fn, dev_eq_fn);
-
+
+ mgr->inited = 1;
+
return 0;
}
struct vm_device * dev;
struct vm_device * tmp;
- list_for_each_entry_safe(dev, tmp, &(mgr->dev_list), dev_link) {
- v3_remove_device(dev);
+ if (mgr && mgr->num_devs > 0) {
+ list_for_each_entry_safe(dev, tmp, &(mgr->dev_list), dev_link) {
+ v3_remove_device(dev);
+ }
}
return 0;
static int free_frontends(struct v3_vm_info * vm, struct vmm_dev_mgr * mgr);
int v3_deinit_dev_mgr(struct v3_vm_info * vm) {
- struct vmm_dev_mgr * mgr = &(vm->dev_mgr);
-
+ struct vmm_dev_mgr * mgr=0;
+
+ if (vm) {
+ mgr = &(vm->dev_mgr);
+ if (!mgr->inited) {
+ return 0;
+ }
+ } else {
+ return 0;
+ }
+
// clear frontend lists
free_frontends(vm, mgr);
- v3_free_htable(mgr->dev_table, 0, 0);
+ if (mgr->dev_table) {
+ v3_free_htable(mgr->dev_table, 0, 0);
+ mgr->dev_table=0;
+ }
return 0;
}
struct blk_frontend * tmp_blk = NULL;
-
+
list_for_each_entry_safe(chr, tmp_chr, &(mgr->char_list), char_node) {
list_del(&(chr->char_node));
V3_Free(chr);