Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


added machine check framework
[palacios.releases.git] / palacios / src / palacios / vmm_vnet_core.c
index 2412120..18720b1 100644 (file)
@@ -264,6 +264,27 @@ int v3_vnet_add_route(struct v3_vnet_route route) {
 }
 
 
+/* delete all route entries with specfied src or dst device id */ 
+static void inline del_routes(int dev_id){
+    struct vnet_route_info * route = NULL;
+    unsigned long flags; 
+
+    flags = v3_lock_irqsave(vnet_state.lock);
+
+    list_for_each_entry(route, &(vnet_state.routes), node) {
+       if((route->route_def.dst_type == LINK_INTERFACE &&
+            route->route_def.dst_id == dev_id) ||
+            (route->route_def.src_type == LINK_INTERFACE &&
+             route->route_def.src_id == dev_id)){
+             
+           list_del(&(route->node));
+           list_del(&(route->match_node));
+           V3_Free(route);    
+       }
+    }
+
+    v3_unlock_irqrestore(vnet_state.lock, flags);
+}
 
 /* At the end allocate a route_list
  * This list will be inserted into the cache so we don't need to free it
@@ -498,7 +519,7 @@ int v3_vnet_add_dev(struct v3_vm_info * vm, uint8_t mac[6],
 
     /* if the device was found previosly the id should still be 0 */
     if (new_dev->dev_id == 0) {
-       PrintError("Device Alrady exists\n");
+       PrintError("Device Already exists\n");
        return -1;
     }
 
@@ -508,6 +529,49 @@ int v3_vnet_add_dev(struct v3_vm_info * vm, uint8_t mac[6],
 }
 
 
+
+int v3_vnet_del_dev(int dev_id){
+    struct vnet_dev * dev = NULL;
+    unsigned long flags;
+
+    flags = v3_lock_irqsave(vnet_state.lock);
+       
+    dev = find_dev_by_id(dev_id);
+    if (dev != NULL){
+       list_del(&(dev->node));
+       del_routes(dev_id);
+    }
+       
+    v3_unlock_irqrestore(vnet_state.lock, flags);
+
+    V3_Free(dev);
+
+    PrintDebug("Vnet: Remove Device: dev_id %d\n", dev_id);
+
+    return 0;
+}
+
+
+static void free_devices(){
+    struct vnet_dev * dev = NULL; 
+
+    list_for_each_entry(dev, &(vnet_state.devs), node) {
+       list_del(&(dev->node));
+       V3_Free(dev);
+    }
+}
+
+static void free_routes(){
+    struct vnet_route_info * route = NULL; 
+
+    list_for_each_entry(route, &(vnet_state.routes), node) {
+       list_del(&(route->node));
+       list_del(&(route->match_node));
+       V3_Free(route);
+    }
+}
+
+
 void  v3_vnet_poll(struct v3_vm_info * vm){
     struct vnet_dev * dev = NULL; 
     struct vnet_brg_dev *bridge = vnet_state.bridge;
@@ -604,3 +668,17 @@ int v3_init_vnet() {
 
     return 0;
 }
+
+
+void v3_deinit_vnet(){
+
+    v3_lock_deinit(&(vnet_state.lock));
+
+    free_devices();
+    free_routes();
+
+    v3_free_htable(vnet_state.route_cache, 1, 1);
+    V3_Free(vnet_state.bridge);
+}
+
+