Skip to contentSkip to conversation

[6073] virtio-net support

Qemu-devel Anthony Liguori 2 participants 4 messages Dec 17, 2008 – Dec 18, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

Revision: 6073

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6073
Author:   aliguori
Date:     2008-12-17 19:13:11 +0000 (Wed, 17 Dec 2008)

Log Message:
-----------
virtio-net support

This adds virtio-net support. This is based on the virtio-net driver that exists in kvm-userspace. This also adds a new qemu_sendv_packet which virtio-net requires.

Modified Paths:
--------------
trunk/Makefile.target
trunk/hw/pci.c
trunk/net.c
trunk/net.h

Added Paths:
-----------
trunk/hw/virtio-net.c
trunk/hw/virtio-net.h

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

Makefile.target +2 -2
@@ -637,7 +637,7 @@
 OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
 OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o
 # virtio support
-OBJS+= virtio.o virtio-blk.o virtio-balloon.o
+OBJS+= virtio.o virtio-blk.o virtio-balloon.o virtio-net.o
 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
 endif
 ifeq ($(TARGET_BASE_ARCH), ppc)
@@ -664,7 +664,7 @@
 OBJS+= kvm_ppc.o
 endif
 # virtio support
-OBJS+= virtio.o virtio-blk.o virtio-balloon.o
+OBJS+= virtio.o virtio-blk.o virtio-balloon.o virtio-net.o
 endif
 ifeq ($(TARGET_BASE_ARCH), mips)
 OBJS+= mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o

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

hw/pci.c +4 -1
@@ -25,6 +25,7 @@
 #include "pci.h"
 #include "console.h"
 #include "net.h"
+#include "virtio-net.h"
 
 //#define DEBUG_PCI
 
@@ -654,9 +655,11 @@
         pci_e1000_init(bus, nd, devfn);
     } else if (strcmp(nd->model, "pcnet") == 0) {
         pci_pcnet_init(bus, nd, devfn);
+    } else if (strcmp(nd->model, "virtio") == 0) {
+        virtio_net_init(bus, nd, devfn);
     } else if (strcmp(nd->model, "?") == 0) {
         fprintf(stderr, "qemu: Supported PCI NICs: i82551 i82557b i82559er"
-                        " ne2k_pci pcnet rtl8139 e1000\n");
+                        " ne2k_pci pcnet rtl8139 e1000 virtio\n");
         exit (1);
     } else {
         fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);

Added: trunk/hw/virtio-net.c
===================================================================

hw/virtio-net.c +329 -0

329 lines not on this page · raw message

Added: trunk/hw/virtio-net.h
===================================================================

hw/virtio-net.h +80 -0

80 lines not on this page · raw message

Modified: trunk/net.c
===================================================================

net.c +44 -0

50 lines not on this page · raw message

Modified: trunk/net.h
===================================================================

net.h +7 -0
@@ -1,12 +1,17 @@
 #ifndef QEMU_NET_H
 #define QEMU_NET_H
 
+#include "qemu-common.h"
+
 /* VLANs support */
 
+typedef ssize_t (IOReadvHandler)(void *, const struct iovec *, int);
+
 typedef struct VLANClientState VLANClientState;
 
 struct VLANClientState {
     IOReadHandler *fd_read;
+    IOReadvHandler *fd_readv;
     /* Packets may still be sent if this returns zero.  It's used to
        rate-limit the slirp code.  */
     IOCanRWHandler *fd_can_read;
@@ -30,6 +35,8 @@
                                       void *opaque);
 void qemu_del_vlan_client(VLANClientState *vc);
 int qemu_can_send_packet(VLANClientState *vc);
+ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov,
+                          int iovcnt);
 void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);
 void qemu_handler_true(void *opaque);
 
#1 lore raw
Quoted 8 lines · Anthony Liguori

Revision: 6073

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6073
Author:   aliguori
Date:     2008-12-17 19:13:11 +0000 (Wed, 17 Dec 2008)

Log Message:
-----------
virtio-net support

I think probably this patch broke compilation of arm-softmmu on Windows (I'm using r6081):

make[1]: Entering directory `/c/test/qemu/arm-softmmu'
gcc -g -Wl,--warn-common -m32 -static -o qemu-system-arm.exe vl.o /c/test/qemu/osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o fw_cfg.o /c/test/qemu/block-raw-win32.o lsi53c895a.o esp.o usb-ohci.o eeprom93xx.o eepro100.o ne2000.o pcnet.o rtl8139.o e1000.o integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o versatile_pci.o ptimer.o realview_gic.o realview.o arm_sysctl.o mpcore.o armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o pl061.o arm-semi.o pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o pflash_cfi01.o gumstix.o zaurus.o ide.o serial.o nand.o ecc.o spitz.o tosa.o tc6393xb.o omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o omap2.o omap_dss.o soc_dma.o omap_sx1.o palm.o tsc210x.o nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o tsc2005.o bt-hci-csr.o mst_fpga.o mainstone.o musicpal.o pflash_cfi02.o gdbstub.o gdbstub-xml.o ../libqemu_common.a libqemu.a -lm -lwinmm -lws2_32 -liphlpapi -lz -lole32 -ldxguid -L/mingw/sdl-1.2.8/lib -lmingw32 -lSDLmain -lSDL -luser32 -lgdi32 -lwinmm -ldxguid -mconsolepci.o(.text+0xd32): In function `pci_nic_init':
c:/test/qemu/hw/pci.c:659: undefined reference to `virtio_net_init'
collect2: ld returned 1 exit status

#2 lore raw
Quoted 6 lines · Consul
Quoted 5 lines · Anthony Liguori

Revision: 6073

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6073
Author:   aliguori
Date:     2008-12-17 19:13:11 +0000 (Wed, 17 Dec 2008)
Quoted 6 lines
Quoted 3 lines

Log Message:
-----------
virtio-net support

I think probably this patch broke compilation of arm-softmmu on Windows (I'm using r6081):

Sorry about that, should be fixed now. I was doing a partial build because the full build takes too long. I didn't cross my mind that it could break the full build. There's a strange dependency in pci.c that led to this.

Regards,

Anthony Liguori

#3 lore raw
Quoted 12 lines · Anthony Liguori
Quoted 11 lines · Consul
Quoted 8 lines · Anthony Liguori

Revision: 6073

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6073
Author:   aliguori
Date:     2008-12-17 19:13:11 +0000 (Wed, 17 Dec 2008)

Log Message:
-----------
virtio-net support

Quoted 11 lines
Quoted 1 line

I think probably this patch broke compilation of arm-softmmu on Windows (I'm using r6081):

Sorry about that, should be fixed now. I was doing a partial build because the full build takes too long. I didn't cross my mind that it could break the full build. There's a strange dependency in pci.c that led to this.

Regards,

Anthony Liguori

Thanks. It compiles fine now.

Alex.