Skip to contentSkip to conversation

networking: add Virtual Distributed Ethernet native support

PATCH RESEND New Luca Bigliardi 1 participant 1 message Jul 14, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 networking: add Virtual Distributed Ethernet native support

Hi guys,
any comments on this patch ?

----- Forwarded message from Luca Bigliardi <[email protected]> -----

Subject: [Qemu-devel] [PATCH] native vde support
From: Luca Bigliardi <[email protected]>
Reply-To: [email protected]
Date: Tue, 1 Jul 2008 21:11:31 +0100
To: [email protected]
User-Agent: Mutt/1.5.17+20080114 (2008-01-14)
List-Unsubscribe: <http://lists.nongnu.org/mailman/listinfo/qemu-devel>,
<mailto:[email protected]?subject=unsubscribe>

Hi!

The patch I'm proposing here adds native support to Virtual Distributed Ethernet using libvdeplug.

A small example:
- patch latest svn with the attached patch
- configure qemu to use vde support (disabled by default) using "./configure --enable-vde"
- start a vde switch
vde_switch -F -sock /tmp/my_qemu_test
- start qemu (full syntax explanation is in the qemu-doc and appears into qemu online help if it's compiled with vde support) qemu -net nic -net vde,sock=/tmp/my_qemu_test linux-0.2.img

What is VDE?
Virtual Distributed Ethernet is a virtual network that can be spawned over a set of physical computer over the Internet and that can be shared between physical hosts and various kinds of virtual machines. vde_switch, core app of VDE framework, is an evolution of uml_switch. The project was originally written by Renzo Davoli and now is maintained and developed by Virtualsquare Team (which I'm part of).
For more information and simple examples of vde usage visit:
http://wiki.virtualsquare.org/index.php/VDE and
http://wiki.virtualsquare.org/index.php/VDE_Basic_Networking

Why add native support to VDE?
Nowadays a number of qemu instances already use vde networking, to give you an idea simply search "qemu vde" on google, or think that vde is the recommended networking tool for qemu in major distributions as debian or ubuntu (and maybe others..), so in my opinion native vde networking will be widely used!

What's wrong with the present solution?
What are you doing with your patch?
Unfortunately at the moment qemu is connected to a vde_switch through a dirty hack called 'vdeq' which places itself in the middle between the two applications.
The life of a vdeq is quite simple:
- do some tricky syntax parsing and mangling
- connect to vde_switch using libvdeplug
- open socketpair
- fork qemu giving him one end of socketpair
- enter a loop to forward data between vde_switch and qemu
- when qemu exits close the connection with vde_switch
This is of course far from being optimal for obvious reasons, so with my patch I simply put into qemu the part of vdeq which connects/disconnects to vde_switch and send/receive data to it.

Please tell me what do you think about this idea and the attached patch, thank you!

Regards,

Luca

----- End forwarded message -----

luca

Signature · 4 lines
Beware of programmers who carry screwdrivers.
                        -- Leonard Brandwein

http://shammash.homelinux.org/ - http://www.artha.org/ - http://www.yue.it/
Makefile.target +1 -1
Index: Makefile.target
===================================================================
@@ -652,7 +652,7 @@
 endif
 
 $(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a
-	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS)
+	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS)
 
 endif # !CONFIG_USER_ONLY
 
vl.c +101 -0

131 lines not on this page · raw message

Makefile +4 -0
Index: Makefile
===================================================================
@@ -127,6 +127,10 @@
 OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
 endif
 
+ifdef CONFIG_VDE
+LIBS+=-lvdeplug
+endif
+
 cocoa.o: cocoa.m
 	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
 
qemu-doc.texi +15 -0
Index: qemu-doc.texi
===================================================================
@@ -672,6 +672,21 @@
 /path/to/linux ubd0=/path/to/root_fs eth0=mcast
 @end example
 
+@item -net vde[,vlan=@var{n}][,sock=@var{socketpath}][,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]
+Connect VLAN @var{n} to PORT @var{n} of a vde switch running on host and
+listening for incoming connections on @var{socketpath}. Use GROUP @var{groupname}
+and MODE @var{octalmode} to change default ownership and permissions for
+communication port. This option is available only if QEMU has been compiled
+with vde support enabled.
+
+Example:
+@example
+# launch vde switch
+vde_switch -F -sock /tmp/myswitch
+# launch QEMU instance
+qemu linux.img -net nic -net vde,sock=/tmp/myswitch
+@end example
+
 @item -net none
 Indicate that no network devices should be configured. It is used to
 override the default configuration (@option{-net nic -net user}) which
configure +23 -0
Index: configure
===================================================================
@@ -89,6 +89,7 @@
 EXESUF=""
 gdbstub="yes"
 slirp="yes"
+vde="no"
 fmod_lib=""
 fmod_inc=""
 vnc_tls="yes"
@@ -280,6 +281,8 @@
   ;;
   --disable-slirp) slirp="no"
   ;;
+  --enable-vde) vde="yes"
+  ;;
   --disable-kqemu) kqemu="no"
   ;;
   --disable-brlapi) brlapi="no"
@@ -432,6 +435,7 @@
 echo "  --fmod-inc               path to FMOD includes"
 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
 echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
+echo "  --enable-vde             enable support for vde network [$vde]"
 echo ""
 echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
@@ -722,6 +726,19 @@
 fi
 
 ##########################################
+# vde libraries probe
+if test "$vde" = "yes" ; then
+  vde=no
+  cat > $TMPC << EOF
+#include <libvdeplug.h>
+int main(void) { struct vde_open_args a = {0, 0, 0} ; return 0;}
+EOF
+  if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
+    vde=yes
+  fi
+fi
+
+##########################################
 # Sound support libraries probe
 
 audio_drv_probe()
@@ -868,6 +885,7 @@
 [ ! -z "$uname_release" ] && \
 echo "uname -r          $uname_release"
 echo "NPTL support      $nptl"
+echo "vde support       $vde"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1032,6 +1050,11 @@
   echo "CONFIG_SLIRP=yes" >> $config_mak
   echo "#define CONFIG_SLIRP 1" >> $config_h
 fi
+if test "$vde" = "yes" ; then
+  echo "CONFIG_VDE=yes" >> $config_mak
+  echo "#define CONFIG_VDE 1" >> $config_h
+  echo "VDE_LIBS=-lvdeplug" >> $config_mak
+fi
 for card in $audio_card_list; do
     def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
     echo "$def=yes" >> $config_mak