Revision 82b0d80e
b/net.c | ||
---|---|---|
976 | 976 |
.name = "vnet_hdr", |
977 | 977 |
.type = QEMU_OPT_BOOL, |
978 | 978 |
.help = "enable the IFF_VNET_HDR flag on the tap interface" |
979 |
}, { |
|
980 |
.name = "vhost", |
|
981 |
.type = QEMU_OPT_BOOL, |
|
982 |
.help = "enable vhost-net network accelerator", |
|
983 |
}, { |
|
984 |
.name = "vhostfd", |
|
985 |
.type = QEMU_OPT_STRING, |
|
986 |
.help = "file descriptor of an already opened vhost net device", |
|
979 | 987 |
}, |
980 | 988 |
#endif /* _WIN32 */ |
981 | 989 |
{ /* end of list */ } |
b/net/tap.c | ||
---|---|---|
42 | 42 |
|
43 | 43 |
#include "net/tap-linux.h" |
44 | 44 |
|
45 |
#include "hw/vhost_net.h" |
|
46 |
|
|
45 | 47 |
/* Maximum GSO packet size (64k) plus plenty of room for |
46 | 48 |
* the ethernet and virtio_net headers |
47 | 49 |
*/ |
... | ... | |
58 | 60 |
unsigned int has_vnet_hdr : 1; |
59 | 61 |
unsigned int using_vnet_hdr : 1; |
60 | 62 |
unsigned int has_ufo: 1; |
63 |
VHostNetState *vhost_net; |
|
61 | 64 |
} TAPState; |
62 | 65 |
|
63 | 66 |
static int launch_script(const char *setup_script, const char *ifname, int fd); |
... | ... | |
253 | 256 |
{ |
254 | 257 |
TAPState *s = DO_UPCAST(TAPState, nc, nc); |
255 | 258 |
|
259 |
if (s->vhost_net) { |
|
260 |
vhost_net_cleanup(s->vhost_net); |
|
261 |
} |
|
262 |
|
|
256 | 263 |
qemu_purge_queued_packets(nc); |
257 | 264 |
|
258 | 265 |
if (s->down_script[0]) |
... | ... | |
308 | 315 |
s->has_ufo = tap_probe_has_ufo(s->fd); |
309 | 316 |
tap_set_offload(&s->nc, 0, 0, 0, 0, 0); |
310 | 317 |
tap_read_poll(s, 1); |
318 |
s->vhost_net = NULL; |
|
311 | 319 |
return s; |
312 | 320 |
} |
313 | 321 |
|
... | ... | |
457 | 465 |
} |
458 | 466 |
} |
459 | 467 |
|
468 |
if (qemu_opt_get_bool(opts, "vhost", !!qemu_opt_get(opts, "vhostfd"))) { |
|
469 |
int vhostfd, r; |
|
470 |
if (qemu_opt_get(opts, "vhostfd")) { |
|
471 |
r = net_handle_fd_param(mon, qemu_opt_get(opts, "vhostfd")); |
|
472 |
if (r == -1) { |
|
473 |
return -1; |
|
474 |
} |
|
475 |
vhostfd = r; |
|
476 |
} else { |
|
477 |
vhostfd = -1; |
|
478 |
} |
|
479 |
s->vhost_net = vhost_net_init(&s->nc, vhostfd); |
|
480 |
if (!s->vhost_net) { |
|
481 |
error_report("vhost-net requested but could not be initialized"); |
|
482 |
return -1; |
|
483 |
} |
|
484 |
} else if (qemu_opt_get(opts, "vhostfd")) { |
|
485 |
error_report("vhostfd= is not valid without vhost"); |
|
486 |
return -1; |
|
487 |
} |
|
488 |
|
|
460 | 489 |
return 0; |
461 | 490 |
} |
b/qemu-options.hx | ||
---|---|---|
892 | 892 |
"-net tap[,vlan=n][,name=str],ifname=name\n" |
893 | 893 |
" connect the host TAP network interface to VLAN 'n'\n" |
894 | 894 |
#else |
895 |
"-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off]\n" |
|
895 |
"-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off][,vhostfd=h]\n"
|
|
896 | 896 |
" connect the host TAP network interface to VLAN 'n' and use the\n" |
897 | 897 |
" network scripts 'file' (default=" DEFAULT_NETWORK_SCRIPT ")\n" |
898 | 898 |
" and 'dfile' (default=" DEFAULT_NETWORK_DOWN_SCRIPT ")\n" |
... | ... | |
902 | 902 |
" default of 'sndbuf=1048576' can be disabled using 'sndbuf=0')\n" |
903 | 903 |
" use vnet_hdr=off to avoid enabling the IFF_VNET_HDR tap flag\n" |
904 | 904 |
" use vnet_hdr=on to make the lack of IFF_VNET_HDR support an error condition\n" |
905 |
" use vhost=on to enable experimental in kernel accelerator\n" |
|
906 |
" use 'vhostfd=h' to connect to an already opened vhost net device\n" |
|
905 | 907 |
#endif |
906 | 908 |
"-net socket[,vlan=n][,name=str][,fd=h][,listen=[host]:port][,connect=host:port]\n" |
907 | 909 |
" connect the vlan 'n' to another VLAN using a socket connection\n" |
Also available in: Unified diff