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-OLD.git] / palacios / src / devices / lnx_virtio_nic.c
index fb5c18b..ca56633 100644 (file)
@@ -115,11 +115,7 @@ struct virtio_net_state {
 #define ERR_VIRTIO_TXQ_DISABLED 6
 
 
-static int virtio_free(struct vm_device * dev) 
-{
-       
-    return 0;
-}
+
 
 static int virtio_init_state(struct virtio_net_state * virtio) 
 {
@@ -236,8 +232,10 @@ static int handle_rx_kick(struct guest_info *core,
 
     flags = v3_lock_irqsave(virtio->rx_lock);
 
-    virtio->net_ops->start_rx(virtio->backend_data);
-    //disable_cb(&virtio->rx_vq);
+    if(virtio->net_ops->start_rx != NULL){
+       virtio->net_ops->start_rx(virtio->backend_data);
+    }
+       //disable_cb(&virtio->rx_vq);
 
     v3_unlock_irqrestore(virtio->rx_lock, flags);
        
@@ -651,9 +649,26 @@ exit:
     return ret_val;
 }
 
+static int virtio_free(struct virtio_dev_state * virtio) {
+    struct virtio_net_state * backend = NULL;
+    struct virtio_net_state * tmp = NULL;
+
+
+    list_for_each_entry_safe(backend, tmp, &(virtio->dev_list), dev_link) {
+
+       // unregister from PCI
+
+       list_del(&(backend->dev_link));
+       V3_Free(backend);
+    }
+
+    V3_Free(virtio);
+    return 0;
+}
+
 
 static struct v3_device_ops dev_ops = {
-    .free = virtio_free,
+    .free = (int (*)(void *))virtio_free,
 };
 
 
@@ -764,6 +779,10 @@ static int register_dev(struct virtio_dev_state * virtio,
     
     virtio_init_state(net_state);
 
+
+    /* Add backend to list of devices */
+    list_add(&(net_state->dev_link), &(virtio->dev_list));
+
     return 0;
 }