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.


Minor fix on virtio network device config
Lei Xia [Sun, 21 Nov 2010 17:02:54 +0000 (11:02 -0600)]
raw packet interface implementation

Kconfig
palacios/include/palacios/vmm_packet.h
palacios/src/devices/lnx_virtio_nic.c
palacios/src/devices/vnet_nic.c
palacios/src/palacios/Makefile
palacios/src/palacios/vmm_packet.c [new file with mode: 0644]

diff --git a/Kconfig b/Kconfig
index 2a7a385..6485d75 100644 (file)
--- a/Kconfig
+++ b/Kconfig
@@ -95,12 +95,20 @@ config CONSOLE
        help 
          Select this if you want to forward a guest console interface to some host OS service
 
-
 config SOCKET
-       bool "Host support for Network Sockets"
-       default y
+        bool "Host support for Network Sockets"
+        default y
+        help
+          Select this if you host OS implements a socket API that is available to Palacios. This is required
+          to support the internal networking features of Palacios.
+
+
+config PACKET
+       bool "Host support for Raw Packet Transmision"
+       depends on EXPERIMENTAL
+       default n
        help 
-         Select this if you host OS implements a socket API that is available to Palacios. This is required 
+         Select this if you host OS implements a raw packet network API that is available to Palacios. This is required 
          to support the internal networking features of Palacios.
 
 endmenu
index 78585c1..8f696e2 100644 (file)
 
 #ifdef __V3VEE__
 
-#define V3_send_Raw(pkt, size, data) ({                                \
-           extern struct v3_packet_hooks * packet_hooks;               \
-           int ret;                                                                    \
-           if ((packet_hooks) && (packet_hooks)->send) {       \
-               ret = (packet_hooks)->send(pkt,size,data);              \
-           }                                                   \
-           ret;                                                \
-       })
+int V3_send_raw(const char * pkt, const int len);
 
 #endif
 
-
 struct v3_packet_hooks {
 
     int (*send)(const char * pkt, const int size, void * private_data);
 
 };
 
-
 extern void V3_Init_Packet(struct v3_packet_hooks * hooks);
 
 #endif
index acbce0d..1f55bfd 100644 (file)
@@ -792,9 +792,9 @@ static int connect_fn(struct v3_vm_info * info,
 static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     struct vm_device * pci_bus = v3_find_dev(vm, v3_cfg_val(cfg, "bus"));
     struct virtio_dev_state * virtio_state = NULL;
-    char * name = v3_cfg_val(cfg, "name");
+    char * dev_id = v3_cfg_val(cfg, "ID");
 
-    PrintDebug("Virtio NIC: Initializing VIRTIO Network device: %s\n", name);
+    PrintDebug("Virtio NIC: Initializing VIRTIO Network device: %s\n", dev_id);
 
     if (pci_bus == NULL) {
        PrintError("Virtio NIC: VirtIO devices require a PCI Bus");
@@ -808,14 +808,14 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     virtio_state->pci_bus = pci_bus;
     virtio_state->vm = vm;
 
-    struct vm_device * dev = v3_allocate_device(name, &dev_ops, virtio_state);
+    struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, virtio_state);
     if (v3_attach_device(vm, dev) == -1) {
-       PrintError("Virtio NIC: Could not attach device %s\n", name);
+       PrintError("Virtio NIC: Could not attach device %s\n", dev_id);
        return -1;
     }
 
-    if (v3_dev_add_net_frontend(vm, name, connect_fn, (void *)virtio_state) == -1) {
-       PrintError("Virtio NIC: Could not register %s as net frontend\n", name);
+    if (v3_dev_add_net_frontend(vm, dev_id, connect_fn, (void *)virtio_state) == -1) {
+       PrintError("Virtio NIC: Could not register %s as net frontend\n", dev_id);
        return -1;
     }
        
index c24eed7..869cecd 100644 (file)
@@ -162,7 +162,7 @@ static int str2mac(char * macstr, char mac[6]){
 
 static int vnet_nic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     struct vnet_nic_state * vnetnic = NULL;
-    char * name = v3_cfg_val(cfg, "name");
+    char * dev_id = v3_cfg_val(cfg, "ID");
     char * macstr = NULL;
     char mac[6];
     int vnet_dev_id;
@@ -179,10 +179,10 @@ static int vnet_nic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     vnetnic = (struct vnet_nic_state *)V3_Malloc(sizeof(struct vnet_nic_state));
     memset(vnetnic, 0, sizeof(struct vnet_nic_state));
 
-    struct vm_device * dev = v3_allocate_device(name, &dev_ops, vnetnic);
+    struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, vnetnic);
 
     if (v3_attach_device(vm, dev) == -1) {
-       PrintError("Could not attach device %s\n", name);
+       PrintError("Could not attach device %s\n", dev_id);
        return -1;
     }
 
@@ -195,20 +195,20 @@ static int vnet_nic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     if (v3_dev_connect_net(vm, v3_cfg_val(frontend_cfg, "tag"), 
                           &(vnetnic->net_ops), frontend_cfg, vnetnic) == -1) {
        PrintError("Could not connect %s to frontend %s\n", 
-                  name, v3_cfg_val(frontend_cfg, "tag"));
+                  dev_id, v3_cfg_val(frontend_cfg, "tag"));
        return -1;
     }
 
     PrintDebug("Vnet-nic: Connect %s to frontend %s\n", 
-             name, v3_cfg_val(frontend_cfg, "tag"));
+             dev_id, v3_cfg_val(frontend_cfg, "tag"));
 
-    if ((vnet_dev_id = register_to_vnet(vm, vnetnic, name, vnetnic->mac)) == -1) {
-       PrintError("Vnet-nic device %s (mac: %s) fails to registered to VNET\n", name, macstr);
+    if ((vnet_dev_id = register_to_vnet(vm, vnetnic, dev_id, vnetnic->mac)) == -1) {
+       PrintError("Vnet-nic device %s (mac: %s) fails to registered to VNET\n", dev_id, macstr);
     }
     vnetnic->vnet_dev_id = vnet_dev_id;
 
     PrintDebug("Vnet-nic device %s (mac: %s, %ld) registered to VNET\n", 
-               name, macstr, *((ulong_t *)vnetnic->mac));
+               dev_id, macstr, *((ulong_t *)vnetnic->mac));
 
 
 //for temporary hack for vnet bridge test
@@ -216,7 +216,7 @@ static int vnet_nic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     {
        uchar_t zeromac[6] = {0,0,0,0,0,0};
                
-       if(!strcmp(name, "vnet_nic")){
+       if(!strcmp(dev_id, "vnet_nic")){
            struct v3_vnet_route route;
                
            route.dst_id = vnet_dev_id;
@@ -251,10 +251,10 @@ static int vnet_nic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
        static int vnet_nic_dom0 = -1;
        uchar_t zeromac[6] = {0,0,0,0,0,0};
                
-       if(!strcmp(name, "vnet_nic")){ //domu
+       if(!strcmp(dev_id, "vnet_nic")){ //domu
            vnet_nic_guestid = vnet_dev_id;
        }
-       if (!strcmp(name, "vnet_nic_dom0")){
+       if (!strcmp(dev_id, "vnet_nic_dom0")){
            vnet_nic_dom0 = vnet_dev_id;
        }
 
index 696315f..f3b2c0c 100644 (file)
@@ -60,6 +60,7 @@ obj-$(CONFIG_VMX) +=          vmx.o \
 obj-$(CONFIG_INSTRUMENT_VMM) += vmm_instrument.o
 obj-$(CONFIG_TELEMETRY) += vmm_telemetry.o 
 obj-$(CONFIG_SOCKET) +=  vmm_socket.o
+obj-$(CONFIG_PACKET) +=  vmm_packet.o
 obj-$(CONFIG_VNET) += vmm_vnet_core.o
 obj-$(CONFIG_FILE) += vmm_file.o
 obj-$(CONFIG_CONSOLE) += vmm_console.o vmm_stream.o
diff --git a/palacios/src/palacios/vmm_packet.c b/palacios/src/palacios/vmm_packet.c
new file mode 100644 (file)
index 0000000..f6fd6bb
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National 
+ * Science Foundation and the Department of Energy.  
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico.  You can find out more at 
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2010, Lei Xia <lxia@cs.northwestern.edu> 
+ * Copyright (c) 2010, The V3VEE Project <http://www.v3vee.org> 
+ * All rights reserved.
+ *
+ * Author: Lei Xia <lxia@cs.northwestern.edu>
+ *
+ * This is free software.  You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+#include <palacios/vmm.h>
+#include <palacios/vmm_debug.h>
+#include <palacios/vmm_types.h>
+#include <palacios/vm_guest.h>
+#include <palacios/vmm_packet.h>
+
+static struct v3_packet_hooks * packet_hooks = 0;
+
+int V3_send_raw(const char * pkt, const int len) {
+    V3_ASSERT(packet_hooks);
+    V3_ASSERT(packet_hooks->send);
+
+    return packet_hooks->send(pkt, len, NULL);
+}
+
+
+void V3_Init_Packet(struct v3_packet_hooks * hooks) {
+    packet_hooks = hooks;
+    PrintDebug("V3 raw packet interface inited\n");
+
+    return;
+}