diff options
author | Mark McLoughlin <markmc@redhat.com> | 2009-10-22 17:49:13 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-10-30 08:39:28 -0500 |
commit | d3f0c9903895a70119ca7c5c2bc4bb901b0e4adc (patch) | |
tree | a273c3b9b4f6cf5671c6e2980337b9feae979058 /net/tap-linux.c | |
parent | c72aa12df3d794b973885f0b9f747cb73514d9b2 (diff) | |
download | qemu-d3f0c9903895a70119ca7c5c2bc4bb901b0e4adc.tar.gz qemu-d3f0c9903895a70119ca7c5c2bc4bb901b0e4adc.tar.bz2 qemu-d3f0c9903895a70119ca7c5c2bc4bb901b0e4adc.zip |
net: move tap_set_sndbuf() to tap-linux.c
TUNSETSNDBUF is only available on linux
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'net/tap-linux.c')
-rw-r--r-- | net/tap-linux.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/net/tap-linux.c b/net/tap-linux.c index c6f751ee7c..6c3b6e311b 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -76,3 +76,26 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required fcntl(fd, F_SETFL, O_NONBLOCK); return fd; } + +/* sndbuf should be set to a value lower than the tx queue + * capacity of any destination network interface. + * Ethernet NICs generally have txqueuelen=1000, so 1Mb is + * a good default, given a 1500 byte MTU. + */ +#define TAP_DEFAULT_SNDBUF 1024*1024 + +int tap_set_sndbuf(int fd, QemuOpts *opts) +{ + int sndbuf; + + sndbuf = qemu_opt_get_size(opts, "sndbuf", TAP_DEFAULT_SNDBUF); + if (!sndbuf) { + sndbuf = INT_MAX; + } + + if (ioctl(fd, TUNSETSNDBUF, &sndbuf) == -1 && qemu_opt_get(opts, "sndbuf")) { + qemu_error("TUNSETSNDBUF ioctl failed: %s\n", strerror(errno)); + return -1; + } + return 0; +} |