Add Virtual Distributed Ethernet native support, by Luca Bigliardi.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4896 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
c4d10628c1
commit
8a16d27388
2
Makefile
2
Makefile
@ -133,6 +133,8 @@ tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
|
|||||||
OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
|
OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
LIBS+=$(VDE_LIBS)
|
||||||
|
|
||||||
cocoa.o: cocoa.m
|
cocoa.o: cocoa.m
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
@ -655,7 +655,7 @@ main.o: CFLAGS+=-p
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a
|
$(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
|
endif # !CONFIG_USER_ONLY
|
||||||
|
|
||||||
|
28
configure
vendored
28
configure
vendored
@ -89,6 +89,7 @@ mingw32="no"
|
|||||||
EXESUF=""
|
EXESUF=""
|
||||||
gdbstub="yes"
|
gdbstub="yes"
|
||||||
slirp="yes"
|
slirp="yes"
|
||||||
|
vde="no"
|
||||||
fmod_lib=""
|
fmod_lib=""
|
||||||
fmod_inc=""
|
fmod_inc=""
|
||||||
vnc_tls="yes"
|
vnc_tls="yes"
|
||||||
@ -280,6 +281,8 @@ for opt do
|
|||||||
;;
|
;;
|
||||||
--disable-slirp) slirp="no"
|
--disable-slirp) slirp="no"
|
||||||
;;
|
;;
|
||||||
|
--enable-vde) vde="yes"
|
||||||
|
;;
|
||||||
--disable-kqemu) kqemu="no"
|
--disable-kqemu) kqemu="no"
|
||||||
;;
|
;;
|
||||||
--disable-brlapi) brlapi="no"
|
--disable-brlapi) brlapi="no"
|
||||||
@ -432,6 +435,7 @@ echo " --fmod-lib path to FMOD library"
|
|||||||
echo " --fmod-inc path to FMOD includes"
|
echo " --fmod-inc path to FMOD includes"
|
||||||
echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
|
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 " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
|
||||||
|
echo " --enable-vde enable support for vde network [$vde]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "NOTE: The object files are built at the place where configure is launched"
|
echo "NOTE: The object files are built at the place where configure is launched"
|
||||||
exit 1
|
exit 1
|
||||||
@ -721,6 +725,24 @@ if test "$vnc_tls" = "yes" ; then
|
|||||||
vnc_tls_libs=`pkg-config --libs gnutls`
|
vnc_tls_libs=`pkg-config --libs gnutls`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# vde libraries probe
|
||||||
|
if test "$vde" = "yes" ; then
|
||||||
|
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
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo "Error: VDE check failed"
|
||||||
|
echo "Make sure to have the VDE libs and headers installed."
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
# Sound support libraries probe
|
# Sound support libraries probe
|
||||||
|
|
||||||
@ -874,6 +896,7 @@ echo "Documentation $build_docs"
|
|||||||
[ ! -z "$uname_release" ] && \
|
[ ! -z "$uname_release" ] && \
|
||||||
echo "uname -r $uname_release"
|
echo "uname -r $uname_release"
|
||||||
echo "NPTL support $nptl"
|
echo "NPTL support $nptl"
|
||||||
|
echo "vde support $vde"
|
||||||
|
|
||||||
if test $sdl_too_old = "yes"; then
|
if test $sdl_too_old = "yes"; then
|
||||||
echo "-> Your SDL version is too old - please upgrade to have SDL support"
|
echo "-> Your SDL version is too old - please upgrade to have SDL support"
|
||||||
@ -1038,6 +1061,11 @@ if test "$slirp" = "yes" ; then
|
|||||||
echo "CONFIG_SLIRP=yes" >> $config_mak
|
echo "CONFIG_SLIRP=yes" >> $config_mak
|
||||||
echo "#define CONFIG_SLIRP 1" >> $config_h
|
echo "#define CONFIG_SLIRP 1" >> $config_h
|
||||||
fi
|
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
|
for card in $audio_card_list; do
|
||||||
def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
|
def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
|
||||||
echo "$def=yes" >> $config_mak
|
echo "$def=yes" >> $config_mak
|
||||||
|
@ -675,6 +675,21 @@ qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
|
|||||||
/path/to/linux ubd0=/path/to/root_fs eth0=mcast
|
/path/to/linux ubd0=/path/to/root_fs eth0=mcast
|
||||||
@end example
|
@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
|
@item -net none
|
||||||
Indicate that no network devices should be configured. It is used to
|
Indicate that no network devices should be configured. It is used to
|
||||||
override the default configuration (@option{-net nic -net user}) which
|
override the default configuration (@option{-net nic -net user}) which
|
||||||
|
101
vl.c
101
vl.c
@ -106,6 +106,10 @@ int inet_aton(const char *cp, struct in_addr *ia);
|
|||||||
#include "libslirp.h"
|
#include "libslirp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_VDE)
|
||||||
|
#include <libvdeplug.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
@ -4418,6 +4422,66 @@ static int net_tap_init(VLANState *vlan, const char *ifname1,
|
|||||||
|
|
||||||
#endif /* !_WIN32 */
|
#endif /* !_WIN32 */
|
||||||
|
|
||||||
|
#if defined(CONFIG_VDE)
|
||||||
|
typedef struct VDEState {
|
||||||
|
VLANClientState *vc;
|
||||||
|
VDECONN *vde;
|
||||||
|
} VDEState;
|
||||||
|
|
||||||
|
static void vde_to_qemu(void *opaque)
|
||||||
|
{
|
||||||
|
VDEState *s = opaque;
|
||||||
|
uint8_t buf[4096];
|
||||||
|
int size;
|
||||||
|
|
||||||
|
size = vde_recv(s->vde, buf, sizeof(buf), 0);
|
||||||
|
if (size > 0) {
|
||||||
|
qemu_send_packet(s->vc, buf, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vde_from_qemu(void *opaque, const uint8_t *buf, int size)
|
||||||
|
{
|
||||||
|
VDEState *s = opaque;
|
||||||
|
int ret;
|
||||||
|
for(;;) {
|
||||||
|
ret = vde_send(s->vde, buf, size, 0);
|
||||||
|
if (ret < 0 && errno == EINTR) {
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int net_vde_init(VLANState *vlan, const char *sock, int port,
|
||||||
|
const char *group, int mode)
|
||||||
|
{
|
||||||
|
VDEState *s;
|
||||||
|
char *init_group = strlen(group) ? (char *)group : NULL;
|
||||||
|
char *init_sock = strlen(sock) ? (char *)sock : NULL;
|
||||||
|
|
||||||
|
struct vde_open_args args = {
|
||||||
|
.port = port,
|
||||||
|
.group = init_group,
|
||||||
|
.mode = mode,
|
||||||
|
};
|
||||||
|
|
||||||
|
s = qemu_mallocz(sizeof(VDEState));
|
||||||
|
if (!s)
|
||||||
|
return -1;
|
||||||
|
s->vde = vde_open(init_sock, "QEMU", &args);
|
||||||
|
if (!s->vde){
|
||||||
|
free(s);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
s->vc = qemu_new_vlan_client(vlan, vde_from_qemu, NULL, s);
|
||||||
|
qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s);
|
||||||
|
snprintf(s->vc->info_str, sizeof(s->vc->info_str), "vde: sock=%s fd=%d",
|
||||||
|
sock, vde_datafd(s->vde));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* network connection */
|
/* network connection */
|
||||||
typedef struct NetSocketState {
|
typedef struct NetSocketState {
|
||||||
VLANClientState *vc;
|
VLANClientState *vc;
|
||||||
@ -5047,6 +5111,30 @@ static int net_client_init(const char *str)
|
|||||||
}
|
}
|
||||||
vlan->nb_host_devs++;
|
vlan->nb_host_devs++;
|
||||||
} else
|
} else
|
||||||
|
#ifdef CONFIG_VDE
|
||||||
|
if (!strcmp(device, "vde")) {
|
||||||
|
char vde_sock[1024], vde_group[512];
|
||||||
|
int vde_port, vde_mode;
|
||||||
|
vlan->nb_host_devs++;
|
||||||
|
if (get_param_value(vde_sock, sizeof(vde_sock), "sock", p) <= 0) {
|
||||||
|
vde_sock[0] = '\0';
|
||||||
|
}
|
||||||
|
if (get_param_value(buf, sizeof(buf), "port", p) > 0) {
|
||||||
|
vde_port = strtol(buf, NULL, 10);
|
||||||
|
} else {
|
||||||
|
vde_port = 0;
|
||||||
|
}
|
||||||
|
if (get_param_value(vde_group, sizeof(vde_group), "group", p) <= 0) {
|
||||||
|
vde_group[0] = '\0';
|
||||||
|
}
|
||||||
|
if (get_param_value(buf, sizeof(buf), "mode", p) > 0) {
|
||||||
|
vde_mode = strtol(buf, NULL, 8);
|
||||||
|
} else {
|
||||||
|
vde_mode = 0700;
|
||||||
|
}
|
||||||
|
ret = net_vde_init(vlan, vde_sock, vde_port, vde_group, vde_mode);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unknown network device: %s\n", device);
|
fprintf(stderr, "Unknown network device: %s\n", device);
|
||||||
return -1;
|
return -1;
|
||||||
@ -7418,6 +7506,13 @@ static void help(int exitcode)
|
|||||||
" connect the vlan 'n' to another VLAN using a socket connection\n"
|
" connect the vlan 'n' to another VLAN using a socket connection\n"
|
||||||
"-net socket[,vlan=n][,fd=h][,mcast=maddr:port]\n"
|
"-net socket[,vlan=n][,fd=h][,mcast=maddr:port]\n"
|
||||||
" connect the vlan 'n' to multicast maddr and port\n"
|
" connect the vlan 'n' to multicast maddr and port\n"
|
||||||
|
#ifdef CONFIG_VDE
|
||||||
|
"-net vde[,vlan=n][,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n"
|
||||||
|
" connect the vlan 'n' to port 'n' of a vde switch running\n"
|
||||||
|
" on host and listening for incoming connections on 'socketpath'.\n"
|
||||||
|
" Use group 'groupname' and mode 'octalmode' to change default\n"
|
||||||
|
" ownership and permissions for communication port.\n"
|
||||||
|
#endif
|
||||||
"-net none use it alone to have zero network devices; if no -net option\n"
|
"-net none use it alone to have zero network devices; if no -net option\n"
|
||||||
" is provided, the default is '-net nic -net user'\n"
|
" is provided, the default is '-net nic -net user'\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -8907,6 +9002,12 @@ int main(int argc, char **argv)
|
|||||||
s->down_script[0])
|
s->down_script[0])
|
||||||
launch_script(s->down_script, ifname, s->fd);
|
launch_script(s->down_script, ifname, s->fd);
|
||||||
}
|
}
|
||||||
|
#if defined(CONFIG_VDE)
|
||||||
|
if (vc->fd_read == vde_from_qemu) {
|
||||||
|
VDEState *s = vc->opaque;
|
||||||
|
vde_close(s->vde);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user