Skip to content

Commit

Permalink
net: Adding netmap network backend
Browse files Browse the repository at this point in the history
This patch adds support for a network backend based on netmap.
netmap is a framework for high speed packet I/O. You can use it
to build extremely fast traffic generators, monitors, software
switches or network middleboxes. Its companion software switch
VALE lets you interconnect virtual machines.
netmap and VALE are implemented as a non-intrusive kernel module,
support NICs from multiple vendors, are part of standard FreeBSD
distributions and available in source format for Linux too.

To compile QEMU with netmap support, use the following configure
options:
    ./configure [...] --enable-netmap --extra-cflags=-I/path/to/netmap/sys
where "/path/to/netmap" contains the netmap source code, available at
    http://info.iet.unipi.it/~luigi/netmap/

The same webpage contains more information about the netmap project
(together with papers and presentations).

Signed-off-by: Vincenzo Maffione <v.maffione@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
vmaffione authored and stefanhaRH committed Dec 9, 2013
1 parent a1d22a3 commit 5895213
Show file tree
Hide file tree
Showing 8 changed files with 513 additions and 3 deletions.
32 changes: 32 additions & 0 deletions configure
Expand Up @@ -169,6 +169,7 @@ curl=""
curses=""
docs=""
fdt=""
netmap="no"
pixman=""
sdl=""
virtfs=""
Expand Down Expand Up @@ -488,6 +489,7 @@ FreeBSD)
audio_possible_drivers="oss sdl esd pa"
# needed for kinfo_getvmmap(3) in libutil.h
LIBS="-lutil $LIBS"
netmap="" # enable netmap autodetect
;;
DragonFly)
bsd="yes"
Expand Down Expand Up @@ -797,6 +799,10 @@ for opt do
;;
--enable-vde) vde="yes"
;;
--disable-netmap) netmap="no"
;;
--enable-netmap) netmap="yes"
;;
--disable-xen) xen="no"
;;
--enable-xen) xen="yes"
Expand Down Expand Up @@ -1182,6 +1188,8 @@ echo " --disable-uuid disable uuid support"
echo " --enable-uuid enable uuid support"
echo " --disable-vde disable support for vde network"
echo " --enable-vde enable support for vde network"
echo " --disable-netmap disable support for netmap network"
echo " --enable-netmap enable support for netmap network"
echo " --disable-linux-aio disable Linux AIO support"
echo " --enable-linux-aio enable Linux AIO support"
echo " --disable-cap-ng disable libcap-ng support"
Expand Down Expand Up @@ -2094,6 +2102,26 @@ EOF
fi
fi

##########################################
# netmap headers probe
if test "$netmap" != "no" ; then
cat > $TMPC << EOF
#include <inttypes.h>
#include <net/if.h>
#include <net/netmap.h>
#include <net/netmap_user.h>
int main(void) { return 0; }
EOF
if compile_prog "" "" ; then
netmap=yes
else
if test "$netmap" = "yes" ; then
feature_not_found "netmap"
fi
netmap=no
fi
fi

##########################################
# libcap-ng library probe
if test "$cap_ng" != "no" ; then
Expand Down Expand Up @@ -3751,6 +3779,7 @@ echo "uname -r $uname_release"
echo "GUEST_BASE $guest_base"
echo "PIE $pie"
echo "vde support $vde"
echo "netmap support $netmap"
echo "Linux AIO support $linux_aio"
echo "ATTR/XATTR support $attr"
echo "Install blobs $blobs"
Expand Down Expand Up @@ -3888,6 +3917,9 @@ fi
if test "$vde" = "yes" ; then
echo "CONFIG_VDE=y" >> $config_host_mak
fi
if test "$netmap" = "yes" ; then
echo "CONFIG_NETMAP=y" >> $config_host_mak
fi
if test "$cap_ng" = "yes" ; then
echo "CONFIG_LIBCAP=y" >> $config_host_mak
fi
Expand Down
4 changes: 2 additions & 2 deletions hmp-commands.hx
Expand Up @@ -1190,7 +1190,7 @@ ETEXI
{
.name = "host_net_add",
.args_type = "device:s,opts:s?",
.params = "tap|user|socket|vde|dump [options]",
.params = "tap|user|socket|vde|netmap|dump [options]",
.help = "add host VLAN client",
.mhandler.cmd = net_host_device_add,
},
Expand Down Expand Up @@ -1218,7 +1218,7 @@ ETEXI
{
.name = "netdev_add",
.args_type = "netdev:O",
.params = "[user|tap|socket|hubport],id=str[,prop=value][,...]",
.params = "[user|tap|socket|hubport|netmap],id=str[,prop=value][,...]",
.help = "add host network device",
.mhandler.cmd = hmp_netdev_add,
},
Expand Down
1 change: 1 addition & 0 deletions net/Makefile.objs
Expand Up @@ -11,3 +11,4 @@ common-obj-$(CONFIG_AIX) += tap-aix.o
common-obj-$(CONFIG_HAIKU) += tap-haiku.o
common-obj-$(CONFIG_SLIRP) += slirp.o
common-obj-$(CONFIG_VDE) += vde.o
common-obj-$(CONFIG_NETMAP) += netmap.o
5 changes: 5 additions & 0 deletions net/clients.h
Expand Up @@ -52,4 +52,9 @@ int net_init_vde(const NetClientOptions *opts, const char *name,
NetClientState *peer);
#endif

#ifdef CONFIG_NETMAP
int net_init_netmap(const NetClientOptions *opts, const char *name,
NetClientState *peer);
#endif

#endif /* QEMU_NET_CLIENTS_H */
6 changes: 6 additions & 0 deletions net/net.c
Expand Up @@ -725,6 +725,9 @@ static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])(
[NET_CLIENT_OPTIONS_KIND_SOCKET] = net_init_socket,
#ifdef CONFIG_VDE
[NET_CLIENT_OPTIONS_KIND_VDE] = net_init_vde,
#endif
#ifdef CONFIG_NETMAP
[NET_CLIENT_OPTIONS_KIND_NETMAP] = net_init_netmap,
#endif
[NET_CLIENT_OPTIONS_KIND_DUMP] = net_init_dump,
#ifdef CONFIG_NET_BRIDGE
Expand Down Expand Up @@ -757,6 +760,9 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)
#ifdef CONFIG_VDE
case NET_CLIENT_OPTIONS_KIND_VDE:
#endif
#ifdef CONFIG_NETMAP
case NET_CLIENT_OPTIONS_KIND_NETMAP:
#endif
#ifdef CONFIG_NET_BRIDGE
case NET_CLIENT_OPTIONS_KIND_BRIDGE:
#endif
Expand Down

0 comments on commit 5895213

Please sign in to comment.