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.


Revised check for already-launched VM
[palacios.git] / palacios / src / devices / lnx_virtio_nic.c
index 4e5f449..92dee7e 100644 (file)
@@ -286,6 +286,7 @@ static int handle_pkt_tx(struct guest_info * core,
        if(q->cur_avail_idx == q->avail->index ||
            (quote > 0 && txed >= quote)) {
            left = (q->cur_avail_idx != q->avail->index);
+           v3_unlock_irqrestore(virtio_state->tx_lock, flags);
            break;
        }
        
@@ -321,8 +322,6 @@ static int handle_pkt_tx(struct guest_info * core,
        q->used->ring[q->used->index % q->queue_size].id = 
            q->avail->ring[tmp_idx % q->queue_size];
        
-       //q->used->ring[q->used->index % q->queue_size].length = buf_desc->length; /* What do we set this to???? */
-       
        q->used->index ++;
        
        v3_unlock_irqrestore(virtio_state->tx_lock, flags);
@@ -332,7 +331,7 @@ static int handle_pkt_tx(struct guest_info * core,
         
     if (txed && !(q->avail->flags & VIRTIO_NO_IRQ_FLAG)) {
        v3_pci_raise_irq(virtio_state->virtio_dev->pci_bus, 
-                        0, virtio_state->pci_dev);
+                        virtio_state->pci_dev, 0);
        virtio_state->virtio_cfg.pci_isr = 0x1;
        virtio_state->stats.rx_interrupts ++;
     }
@@ -554,7 +553,7 @@ static int virtio_io_read(struct guest_info *core,
            *(uint8_t *)dst = virtio->virtio_cfg.pci_isr;
            virtio->virtio_cfg.pci_isr = 0;
            v3_pci_lower_irq(virtio->virtio_dev->pci_bus, 
-                            0, virtio->pci_dev);
+                            virtio->pci_dev, 0);
            break;
 
        case VIRTIO_NET_CONFIG ... VIRTIO_NET_CONFIG + ETH_ALEN:
@@ -709,7 +708,7 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) {
                     virtio->pci_dev->config_header.intr_line);
 
        virtio->virtio_cfg.pci_isr = 0x1;       
-       v3_pci_raise_irq(virtio->virtio_dev->pci_bus, 0, virtio->pci_dev);
+       v3_pci_raise_irq(virtio->virtio_dev->pci_bus, virtio->pci_dev, 0);
        virtio->stats.rx_interrupts ++;
     }
 
@@ -804,7 +803,7 @@ static int register_dev(struct virtio_dev_state * virtio,
     pci_dev = v3_pci_register_device(virtio->pci_bus, PCI_STD_DEVICE, 
                                     0, PCI_AUTO_DEV_NUM, 0,
                                     "LNX_VIRTIO_NIC", bars,
-                                    NULL, NULL, NULL, net_state);
+                                    NULL, NULL, NULL, NULL, net_state);
     
     if (!pci_dev) {
        PrintError("Virtio NIC: Could not register PCI Device\n");
@@ -917,6 +916,11 @@ static int connect_fn(struct v3_vm_info * info,
     struct virtio_dev_state * virtio = (struct virtio_dev_state *)frontend_data;
     struct virtio_net_state * net_state  = (struct virtio_net_state *)V3_Malloc(sizeof(struct virtio_net_state));
 
+    if (!net_state) {
+       PrintError("Cannot allocate in connect\n");
+       return -1;
+    }
+
     memset(net_state, 0, sizeof(struct virtio_net_state));
     register_dev(virtio, net_state);
 
@@ -955,6 +959,12 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     }
 
     virtio_state  = (struct virtio_dev_state *)V3_Malloc(sizeof(struct virtio_dev_state));
+
+    if (!virtio_state) {
+       PrintError("Cannot allocate in init\n");
+       return -1;
+    }
+
     memset(virtio_state, 0, sizeof(struct virtio_dev_state));
 
     INIT_LIST_HEAD(&(virtio_state->dev_list));