[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] give some useful error messages when tap open fails
From: |
Michael Tokarev |
Subject: |
[Qemu-devel] [PATCH] give some useful error messages when tap open fails |
Date: |
Thu, 22 Apr 2010 13:28:26 +0400 (MSD) |
In net/tap-linux.c, when manipulation of /dev/net/tun fails, it prints
(with fprintf) something like this:
warning: could not open /dev/net/tun: no virtual network emulation
this has 2 issues:
1) it is not a warning really, it's a fatal error (kvm exits after that),
2) there's no indication as of what's actually wrong: printing errno there
is helpful.
The patch below removes the "warning" prefix, uses %m (since it's linux,
%m is available as format modifier), and changes fprintf() to qemu_error().
Now it prints something like this instead:
could not configure /dev/net/tun: Device or resource busy
(there are 2 messages like that in the same function)
This fixes Debian bug #578154, see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578154
Signed-Off-By: Michael Tokarev <address@hidden>
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 6af9e82..dbcbe6f 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -39,7 +39,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
int vnet_hdr_required
TFR(fd = open("/dev/net/tun", O_RDWR));
if (fd < 0) {
- fprintf(stderr, "warning: could not open /dev/net/tun: no virtual
network emulation\n");
+ qemu_error("could not open /dev/net/tun: %m\n");
return -1;
}
memset(&ifr, 0, sizeof(ifr));
@@ -70,7 +70,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");
+ qemu_error("could not configure /dev/net/tun: %m\n");
close(fd);
return -1;
}
- [Qemu-devel] [PATCH] give some useful error messages when tap open fails,
Michael Tokarev <=