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.


More fix on VNET code
Lei Xia [Tue, 23 Nov 2010 03:55:41 +0000 (21:55 -0600)]
Now it is working on Linux host

palacios/src/devices/lnx_virtio_nic.c
palacios/src/devices/nic_bridge.c
palacios/src/devices/vnet_nic.c
palacios/src/palacios/vmm_vnet_core.c

index 1f55bfd..a9825b9 100644 (file)
@@ -237,7 +237,7 @@ 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);
+    //disable_cb(&virtio->rx_vq);
 
     v3_unlock_irqrestore(virtio->rx_lock, flags);
        
@@ -375,7 +375,6 @@ static int virtio_io_write(struct guest_info *core,
     struct virtio_net_state * virtio = (struct virtio_net_state *)private_data;
     int port_idx = port % virtio->io_range_size;
 
-
     PrintDebug("VIRTIO NIC %p Write for port %d (index=%d) len=%d, value=%x\n", private_data,
               port, port_idx,  length, *(uint32_t *)src);
 
@@ -399,11 +398,11 @@ static int virtio_io_write(struct guest_info *core,
            switch (queue_idx) {
                case 0:
                    virtio_setup_queue(core, virtio, &virtio->rx_vq, pfn, page_addr);
-                   disable_cb(&virtio->rx_vq);
+                   //disable_cb(&virtio->rx_vq);
                    break;
                case 1:
                    virtio_setup_queue(core, virtio, &virtio->tx_vq, pfn, page_addr);
-                   disable_cb(&virtio->tx_vq);
+                   //disable_cb(&virtio->tx_vq);
                    break;
                case 2:
                    virtio_setup_queue(core, virtio, &virtio->ctrl_vq, pfn, page_addr);
@@ -427,9 +426,7 @@ static int virtio_io_write(struct guest_info *core,
                uint16_t queue_idx = *(uint16_t *)src;                  
                if (queue_idx == 0){
                    handle_rx_kick(core, virtio);
-                   PrintError("rx kick\n");
                } else if (queue_idx == 1){
-                   PrintError("tx kick\n");
                    if (handle_pkt_tx(core, virtio) == -1) {
                        PrintError("Could not handle NIC Notification\n");
                        return -1;
@@ -559,6 +556,13 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) {
     int ret_val = -ERR_VIRTIO_OTHER;
     int raw = 1;
 
+#ifndef CONFIG_DEBUG_VIRTIO_NET
+   {
+       PrintDebug("Virtio-NIC: virtio_rx: size: %d\n", size);  
+       //v3_hexdump(buf, size, NULL, 0);
+   }
+#endif
+
     flags = v3_lock_irqsave(virtio->rx_lock);
 
     virtio->pkt_recv ++;
index 4ed1d50..eb5500b 100644 (file)
@@ -36,13 +36,13 @@ struct nic_bridge_state {
 };
 
 static int bridge_send(uint8_t * buf, uint32_t len, 
-                      void * private_data, struct vm_device *dev){
+                        void * private_data, struct vm_device *dev){
     //struct nic_bridge_state *bridge = (struct nic_bridge_state *)private_data;
 
 #ifdef CONFIG_DEBUG_NIC_BRIDGE
     {
        PrintDebug("NIC Bridge: send pkt size: %d\n", len);
-       v3_hexdump(buf, len, NULL, 0);
+       //v3_hexdump(buf, len, NULL, 0);
     }
 #endif
 
@@ -50,9 +50,9 @@ static int bridge_send(uint8_t * buf, uint32_t len,
 }
 
 
-static int packet_input(struct v3_vm_info * vm,
-                       struct v3_packet_event * evt, 
-                       void * private_data) {
+static int packet_input(struct v3_vm_info * vm, 
+                            struct v3_packet_event * evt, 
+                            void * private_data) {
     struct nic_bridge_state *bridge = (struct nic_bridge_state *)private_data;
 
     PrintDebug("NIC_BRIDGE: Incoming packet size: %d\n", evt->size);
index 869cecd..57904ba 100644 (file)
@@ -71,9 +71,9 @@ static int vnet_nic_send(uint8_t * buf, uint32_t len,
 
 #ifdef CONFIG_DEBUG_VNET_NIC
     {
-       PrintDebug("Virtio VNET-NIC: send pkt size: %d, pkt src_id: %d\n", 
-                       len,  vnetnic->vnet_dev_id);
-       v3_hexdump(buf, len, NULL, 0);
+       PrintDebug("VNET-NIC: send pkt (size: %d, src_id: %d, src_type: %d)\n", 
+                  pkt.size, pkt.src_id, pkt.src_type);
+       //v3_hexdump(buf, len, NULL, 0);
     }
 #endif
 
@@ -86,10 +86,12 @@ static int virtio_input(struct v3_vm_info * info,
                        struct v3_vnet_pkt * pkt, 
                        void * private_data){
     struct vnet_nic_state *vnetnic = (struct vnet_nic_state *)private_data;
+
+    PrintDebug("VNET-NIC: receive pkt (size %d, src_id:%d, src_type: %d, dst_id: %d, dst_type: %d)\n", 
+               pkt->size, pkt->src_id, pkt->src_type, pkt->dst_id, pkt->dst_type);
        
-    return vnetnic->net_ops.recv(pkt->data, 
-                                                       pkt->size, 
-                                                       vnetnic->net_ops.frontend_data);
+    return vnetnic->net_ops.recv(pkt->data, pkt->size,
+                                vnetnic->net_ops.frontend_data);
 }
 
 /* tell frontend device to poll data from guest */
@@ -212,7 +214,7 @@ static int vnet_nic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
 
 
 //for temporary hack for vnet bridge test
-#if 0
+#if 1
     {
        uchar_t zeromac[6] = {0,0,0,0,0,0};
                
@@ -245,7 +247,7 @@ static int vnet_nic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
 #endif
 
 //for temporary hack for Linux bridge (w/o encapuslation) test
-#if 1
+#if 0
     {
        static int vnet_nic_guestid = -1;
        static int vnet_nic_dom0 = -1;
index 5a4275f..2412120 100644 (file)
@@ -135,7 +135,7 @@ static void dump_routes(){
        int i = 0;
        PrintDebug("\n========Dump routes starts ============\n");
        list_for_each_entry(route, &(vnet_state.routes), node) {
-           PrintDebug("\nroute %d:\n", ++i);
+           PrintDebug("\nroute %d:\n", i++);
                
            print_route(route);
        }
@@ -229,7 +229,7 @@ int v3_vnet_add_route(struct v3_vnet_route route) {
     memset(new_route, 0, sizeof(struct vnet_route_info));
 
     PrintDebug("Vnet: vnet_add_route_entry: dst_id: %d, dst_type: %d\n",
-                       route.dst_id, route.dst_type);  
+              route.dst_id, route.dst_type);   
     
     memcpy(new_route->route_def.src_mac, route.src_mac, 6);
     memcpy(new_route->route_def.dst_mac, route.dst_mac, 6);
@@ -400,14 +400,11 @@ int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void * private_data) {
 
 #ifdef CONFIG_DEBUG_VNET
    {
-       struct eth_hdr * hdr = (struct eth_hdr *)(pkt->header);
-       char dest_str[100];
-       char src_str[100];
-
-       mac_to_string(hdr->src_mac, src_str);  
-       mac_to_string(hdr->dst_mac, dest_str);
        int cpu = V3_Get_CPU();
-       PrintDebug("Vnet: on cpu %d, HandleDataOverLink. SRC(%s), DEST(%s), pkt size: %d\n", cpu, src_str, dest_str, pkt->size);
+       PrintDebug("VNET-core: cpu %d: pkt (size %d, src_id:%d, src_type: %d, dst_id: %d, dst_type: %d)\n",
+                 cpu, pkt->size, pkt->src_id, 
+                 pkt->src_type, pkt->dst_id, pkt->dst_type);
+       //v3_hexdump(pkt->data, pkt->size, NULL, 0);
    }
 #endif
 
@@ -416,7 +413,7 @@ int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void * private_data) {
     look_into_cache(pkt, &matched_routes);
        
     if (matched_routes == NULL) {  
-       PrintError("Vnet: send pkt Looking into routing table\n");
+       PrintDebug("Vnet: send pkt Looking into routing table\n");
        
        matched_routes = match_route(pkt);
        
@@ -434,34 +431,35 @@ int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void * private_data) {
     PrintDebug("Vnet: send pkt route matches %d\n", matched_routes->num_routes);
 
     for (i = 0; i < matched_routes->num_routes; i++) {
-        struct vnet_route_info * route = matched_routes->routes[i];
+       struct vnet_route_info * route = matched_routes->routes[i];
        
         if (route->route_def.dst_type == LINK_EDGE) {
-            struct vnet_brg_dev *bridge = vnet_state.bridge;
+           struct vnet_brg_dev *bridge = vnet_state.bridge;
             pkt->dst_type = LINK_EDGE;
             pkt->dst_id = route->route_def.dst_id;
 
-            if (bridge == NULL || (bridge->active == 0)) {
-               PrintError("VNET: No active bridge to sent data to links\n");
+           if (bridge == NULL || (bridge->active == 0)) {
+               PrintDebug("VNET: No active bridge to sent data to\n");
                continue;
-            }
+           }
 
-            if(bridge->brg_ops.input(bridge->vm, pkt, bridge->private_data) == -1){
+           if(bridge->brg_ops.input(bridge->vm, pkt, bridge->private_data) < 0){
                 PrintDebug("VNET: Packet not sent properly to bridge\n");
                 continue;
-            }         
+           }         
         } else if (route->route_def.dst_type == LINK_INTERFACE) {
-            if (route->dst_dev && route->dst_dev->active){ 
-                 if(route->dst_dev->dev_ops.input(route->dst_dev->vm, pkt, route->dst_dev->private_data) == -1) {
-                       PrintDebug("VNET: Packet not sent properly\n");
-                       continue;
-                 }
-            }
+            if (route->dst_dev == NULL || route->dst_dev->active == 0){
+               PrintDebug("VNET: No active device to sent data to\n");
+               continue;
+            }
+
+           if(route->dst_dev->dev_ops.input(route->dst_dev->vm, pkt, route->dst_dev->private_data) < 0) {
+                PrintDebug("VNET: Packet not sent properly\n");
+                continue;
+           }
         } else {
             PrintError("VNET: Wrong dst type\n");
         }
-
-        PrintDebug("VNET: Forward one packet according to Route %d\n", i);
     }
     
     return 0;
@@ -485,7 +483,9 @@ int v3_vnet_add_dev(struct v3_vm_info * vm, uint8_t mac[6],
     new_dev->dev_ops.poll = ops->poll;
     new_dev->private_data = priv_data;
     new_dev->vm = vm;
-    new_dev->dev_id = 0;       
+    new_dev->dev_id = 0;
+    new_dev->active = 1;
+    new_dev->mode = GUEST_DRIVERN;
 
     flags = v3_lock_irqsave(vnet_state.lock);