summaryrefslogtreecommitdiff
path: root/net/tap-linux.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tap-linux.c')
-rw-r--r--net/tap-linux.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 03b83012f8..c92983cb53 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -33,14 +33,16 @@
#include "qemu-common.h"
#include "qemu-error.h"
+#define PATH_NET_TUN "/dev/net/tun"
+
int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required)
{
struct ifreq ifr;
int fd, ret;
- TFR(fd = open("/dev/net/tun", O_RDWR));
+ TFR(fd = open(PATH_NET_TUN, O_RDWR));
if (fd < 0) {
- fprintf(stderr, "warning: could not open /dev/net/tun: no virtual network emulation\n");
+ error_report("could not open %s: %m", PATH_NET_TUN);
return -1;
}
memset(&ifr, 0, sizeof(ifr));
@@ -71,7 +73,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d");
ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
if (ret != 0) {
- fprintf(stderr, "warning: could not configure /dev/net/tun: no virtual network emulation\n");
+ error_report("could not configure %s (%s): %m", PATH_NET_TUN, ifr.ifr_name);
close(fd);
return -1;
}