#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));
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;
}