}
-int v3_init_devices() {
+int V3_init_devices() {
extern struct v3_device_info __start__v3_devices[];
extern struct v3_device_info __stop__v3_devices[];
struct v3_device_info * tmp_dev = __start__v3_devices;
}
+int V3_deinit_devices() {
+ v3_free_htable(master_dev_table, 0, 0);
+ return 0;
+}
+
+
int v3_init_dev_mgr(struct v3_vm_info * vm) {
struct vmm_dev_mgr * mgr = &(vm->dev_mgr);
}
-int v3_dev_mgr_deinit(struct v3_vm_info * vm) {
- struct vm_device * dev;
+int v3_free_vm_devices(struct v3_vm_info * vm) {
struct vmm_dev_mgr * mgr = &(vm->dev_mgr);
+ struct vm_device * dev;
struct vm_device * tmp;
list_for_each_entry_safe(dev, tmp, &(mgr->dev_list), dev_link) {
v3_remove_device(dev);
}
- v3_free_htable(mgr->blk_table, 0, 0);
- v3_free_htable(mgr->net_table, 0, 0);
- v3_free_htable(mgr->char_table, 0, 0);
- v3_free_htable(mgr->cons_table, 0, 0);
+ 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);
+
+ // clear frontend lists
+
+ free_frontends(vm, mgr);
+
+
v3_free_htable(mgr->dev_table, 0, 0);
return 0;
}
+
+
+static int free_frontends(struct v3_vm_info * vm, struct vmm_dev_mgr * mgr) {
+ struct char_frontend * chr = NULL;
+ struct char_frontend * tmp_chr = NULL;
+ struct cons_frontend * cons = NULL;
+ struct cons_frontend * tmp_cons = NULL;
+ struct net_frontend * net = NULL;
+ struct net_frontend * tmp_net = NULL;
+ struct blk_frontend * blk = NULL;
+ 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);
+ }
+
+ list_for_each_entry_safe(cons, tmp_cons, &(mgr->cons_list), cons_node) {
+ list_del(&(cons->cons_node));
+ V3_Free(cons);
+ }
+
+ list_for_each_entry_safe(net, tmp_net, &(mgr->net_list), net_node) {
+ list_del(&(net->net_node));
+ V3_Free(net);
+ }
+
+ list_for_each_entry_safe(blk, tmp_blk, &(mgr->blk_list), blk_node) {
+ list_del(&(blk->blk_node));
+ V3_Free(blk);
+ }
+
+ v3_free_htable(mgr->blk_table, 0, 0);
+ v3_free_htable(mgr->net_table, 0, 0);
+ v3_free_htable(mgr->char_table, 0, 0);
+ v3_free_htable(mgr->cons_table, 0, 0);
+
+
+ return 0;
+}