Skip to contentSkip to conversation

[7224] xen: add net backend driver.

Qemu-devel Anthony Liguori 2 participants 2 messages Apr 22, 2009 – May 30, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

Revision: 7224

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7224
Author:   aliguori
Date:     2009-04-22 15:19:35 +0000 (Wed, 22 Apr 2009)

Log Message:
-----------
xen: add net backend driver. (Gerd Hoffmann)

This patch adds a network interface backend driver to qemu. It is a pure userspace implemention using the gntdev interface. It uses "qnet" as backend name in xenstore so it doesn't interfere with the netback backend (aka "vnif").

The network backend is hooked into the corrosponding qemu vlan, i.e. vif 0 is hooked into vlan 0. To make the packages actually arrive somewhere you additionally have to link the vlan to the outside world using the usual qemu command line options such as "-net tap,...".

Modified Paths:
--------------
trunk/Makefile.target
trunk/hw/xen_backend.h
trunk/hw/xen_machine_pv.c

Added Paths:
-----------
trunk/hw/xen_nic.c

Modified: trunk/Makefile.target
===================================================================

Makefile.target +1 -1
@@ -562,7 +562,7 @@
 
 # xen backend driver support
 XEN_OBJS := xen_machine_pv.o xen_backend.o
-XEN_OBJS += xen_console.o xenfb.o xen_disk.o
+XEN_OBJS += xen_console.o xenfb.o xen_disk.o xen_nic.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
   LIBS += $(XEN_LIBS)

Modified: trunk/hw/xen_backend.h
===================================================================

hw/xen_backend.h +1 -0
@@ -89,6 +89,7 @@
 extern struct XenDevOps xen_kbdmouse_ops;     /* xen_framebuffer.c */
 extern struct XenDevOps xen_framebuffer_ops;  /* xen_framebuffer.c */
 extern struct XenDevOps xen_blkdev_ops;       /* xen_disk.c        */
+extern struct XenDevOps xen_netdev_ops;       /* xen_nic.c         */
 
 void xen_init_display(int domid);
 

Modified: trunk/hw/xen_machine_pv.c
===================================================================

hw/xen_machine_pv.c +1 -0
@@ -60,6 +60,7 @@
     xen_be_register("vkbd", &xen_kbdmouse_ops);
     xen_be_register("vfb", &xen_framebuffer_ops);
     xen_be_register("qdisk", &xen_blkdev_ops);
+    xen_be_register("qnic", &xen_netdev_ops);
 
     /* setup framebuffer */
     xen_init_display(xen_domid);

Added: trunk/hw/xen_nic.c
===================================================================

hw/xen_nic.c +406 -0

406 lines not on this page · raw message

#1 lore raw

Hi,

Am 22.04.2009 um 17:19 schrieb Anthony Liguori:

Quoted 6 lines

Revision: 7224

         http://svn.sv.gnu.org/viewvc/? 
view=rev&root=qemu&revision=7224
Author:   aliguori
Date:     2009-04-22 15:19:35 +0000 (Wed, 22 Apr 2009)

Log Message:

[...]

Quoted 23 lines

Modified Paths:
--------------
trunk/Makefile.target
trunk/hw/xen_backend.h
trunk/hw/xen_machine_pv.c

Added Paths:
-----------
trunk/hw/xen_nic.c

Modified: trunk/Makefile.target
===================================================================

Makefile.target +0 -0
@@ -562,7 +562,7 @@
 
 # xen backend driver support

XEN_OBJS := xen_machine_pv.o xen_backend.o

Makefile.target +1 -1
-XEN_OBJS += xen_console.o xenfb.o xen_disk.o
+XEN_OBJS += xen_console.o xenfb.o xen_disk.o xen_nic.o

ifeq ($(CONFIG_XEN), yes)
OBJS += $(XEN_OBJS)
LIBS += $(XEN_LIBS)

[...]

Quoted 4 lines

Added: trunk/hw/xen_nic.c
===================================================================

hw/xen_nic.c +0 -0

[...]

Quoted 8 lines
hw/xen_nic.c +8 -0
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <unistd.h>
+#include <signal.h>
+#include <inttypes.h>
+#include <fcntl.h>

hw/xen_nic.c line 37

Quoted 10 lines
hw/xen_nic.c +10 -0
+#include <errno.h>
+#include <pthread.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <linux/if.h>
+#include <linux/if_tun.h>

This breaks on OpenSolaris 2008.11, which has Xen-based xVM, so that Xen support gets enabled by configure, but no linux/ headers obviously to compile the above. Any thoughts on how to fix?

Andreas

Quoted 10 lines
hw/xen_nic.c +10 -0
+
+#include <xs.h>
+#include <xenctrl.h>
+#include <xen/io/xenbus.h>
+#include <xen/io/netif.h>
+
+#include "hw.h"
+#include "net.h"
+#include "qemu-char.h"
+#include "xen_backend.h"

[...]