summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-10-22 17:49:13 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-30 08:39:28 -0500
commit15ac913bfe10abe142334a8b432c1f4c410fb04b (patch)
treea273c3b9b4f6cf5671c6e2980337b9feae979058 /net
parentnet: move linux code into net/tap-linux.c (diff)
downloadqemu-kvm-15ac913bfe10abe142334a8b432c1f4c410fb04b.tar.gz
qemu-kvm-15ac913bfe10abe142334a8b432c1f4c410fb04b.tar.bz2
qemu-kvm-15ac913bfe10abe142334a8b432c1f4c410fb04b.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')
-rw-r--r--net/tap-aix.c6
-rw-r--r--net/tap-bsd.c5
-rw-r--r--net/tap-linux.c23
-rw-r--r--net/tap-solaris.c5
-rw-r--r--net/tap.c25
-rw-r--r--net/tap.h2
6 files changed, 42 insertions, 24 deletions
diff --git a/net/tap-aix.c b/net/tap-aix.c
index 5ec3b2c10..3f9ccddda 100644
--- a/net/tap-aix.c
+++ b/net/tap-aix.c
@@ -30,3 +30,9 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
fprintf(stderr, "no tap on AIX\n");
return -1;
}
+
+int tap_set_sndbuf(int fd, QemuOpts *opts)
+{
+ return 0;
+}
+
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index 6940434ef..e28615fba 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -60,3 +60,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
fcntl(fd, F_SETFL, O_NONBLOCK);
return fd;
}
+
+int tap_set_sndbuf(int fd, QemuOpts *opts)
+{
+ return 0;
+}
diff --git a/net/tap-linux.c b/net/tap-linux.c
index c6f751ee7..6c3b6e311 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;
+}
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
index 0dd5b6847..de5855aa0 100644
--- a/net/tap-solaris.c
+++ b/net/tap-solaris.c
@@ -183,3 +183,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
fcntl(fd, F_SETFL, O_NONBLOCK);
return fd;
}
+
+int tap_set_sndbuf(int fd, QemuOpts *opts)
+{
+ return 0;
+}
diff --git a/net/tap.c b/net/tap.c
index 539293792..df2cfbe13 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -209,29 +209,6 @@ static void tap_send(void *opaque)
} while (size > 0);
}
-/* 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
-
-static int tap_set_sndbuf(TAPState *s, QemuOpts *opts)
-{
- int sndbuf;
-
- sndbuf = qemu_opt_get_size(opts, "sndbuf", TAP_DEFAULT_SNDBUF);
- if (!sndbuf) {
- sndbuf = INT_MAX;
- }
-
- if (ioctl(s->fd, TUNSETSNDBUF, &sndbuf) == -1 && qemu_opt_get(opts, "sndbuf")) {
- qemu_error("TUNSETSNDBUF ioctl failed: %s\n", strerror(errno));
- return -1;
- }
- return 0;
-}
-
int tap_has_ufo(VLANClientState *vc)
{
TAPState *s = vc->opaque;
@@ -465,7 +442,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
return -1;
}
- if (tap_set_sndbuf(s, opts) < 0) {
+ if (tap_set_sndbuf(s->fd, opts) < 0) {
return -1;
}
diff --git a/net/tap.h b/net/tap.h
index 5648ddd6b..0d67c249c 100644
--- a/net/tap.h
+++ b/net/tap.h
@@ -43,4 +43,6 @@ int tap_has_vnet_hdr(VLANClientState *vc);
void tap_using_vnet_hdr(VLANClientState *vc, int using_vnet_hdr);
void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, int ecn, int ufo);
+int tap_set_sndbuf(int fd, QemuOpts *opts);
+
#endif /* QEMU_NET_TAP_H */