diff options
author | Kusanagi Kouichi <slash@ac.auone-net.jp> | 2014-01-18 14:38:45 +0900 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2014-01-27 15:44:06 +0100 |
commit | 1f149e721feb617d14a3ee4f5911c47b29866a54 (patch) | |
tree | 11d16f254b4a2a9610a767990d947e2865aa2e85 /net | |
parent | c444dfabfc21cb5f093862100e333b808eea32e4 (diff) | |
download | qemu-1f149e721feb617d14a3ee4f5911c47b29866a54.tar.gz qemu-1f149e721feb617d14a3ee4f5911c47b29866a54.tar.bz2 qemu-1f149e721feb617d14a3ee4f5911c47b29866a54.zip |
tap-linux: Get features once and use it many times
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/tap-linux.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/net/tap-linux.c b/net/tap-linux.c index 36c09e24d8..812bf2dfc6 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -52,14 +52,17 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; - if (ioctl(fd, TUNGETFEATURES, &features) == 0 && - features & IFF_ONE_QUEUE) { + if (ioctl(fd, TUNGETFEATURES, &features) == -1) { + error_report("warning: TUNGETFEATURES failed: %s", strerror(errno)); + features = 0; + } + + if (features & IFF_ONE_QUEUE) { ifr.ifr_flags |= IFF_ONE_QUEUE; } if (*vnet_hdr) { - if (ioctl(fd, TUNGETFEATURES, &features) == 0 && - features & IFF_VNET_HDR) { + if (features & IFF_VNET_HDR) { *vnet_hdr = 1; ifr.ifr_flags |= IFF_VNET_HDR; } else { @@ -82,8 +85,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, } if (mq_required) { - if ((ioctl(fd, TUNGETFEATURES, &features) != 0) || - !(features & IFF_MULTI_QUEUE)) { + if (!(features & IFF_MULTI_QUEUE)) { error_report("multiqueue required, but no kernel " "support for IFF_MULTI_QUEUE available"); close(fd); |