* [Qemu-devel] [PATCH] give some useful error messages when tap open
@ 2010-06-02 17:33 Luiz Capitulino
2010-06-02 18:26 ` Markus Armbruster
2010-06-23 1:47 ` Anthony Liguori
0 siblings, 2 replies; 5+ messages in thread
From: Luiz Capitulino @ 2010-06-02 17:33 UTC (permalink / raw)
To: qemu-devel; +Cc: mjt
From: Michael Tokarev <mjt@tls.msk.ru>
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 <mjt@tls.msk.ru>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
IMPORTANT: this an old fix that got forgotten, probably because it was
submitted in the middle of thread. I've just compiled tested it.
net/tap-linux.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 03b8301..c92983c 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;
}
--
1.7.1.231.gd0b16
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] give some useful error messages when tap open
2010-06-02 17:33 [Qemu-devel] [PATCH] give some useful error messages when tap open Luiz Capitulino
@ 2010-06-02 18:26 ` Markus Armbruster
2010-06-02 18:33 ` Luiz Capitulino
2010-06-23 1:47 ` Anthony Liguori
1 sibling, 1 reply; 5+ messages in thread
From: Markus Armbruster @ 2010-06-02 18:26 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: mjt, qemu-devel
Luiz Capitulino <lcapitulino@redhat.com> writes:
> From: Michael Tokarev <mjt@tls.msk.ru>
>
> 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().
To error_report(), you mean.
> 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 <mjt@tls.msk.ru>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Looks good.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] give some useful error messages when tap open
2010-06-02 18:26 ` Markus Armbruster
@ 2010-06-02 18:33 ` Luiz Capitulino
2010-06-03 7:07 ` Markus Armbruster
0 siblings, 1 reply; 5+ messages in thread
From: Luiz Capitulino @ 2010-06-02 18:33 UTC (permalink / raw)
To: Markus Armbruster; +Cc: mjt, qemu-devel
On Wed, 02 Jun 2010 20:26:58 +0200
Markus Armbruster <armbru@redhat.com> wrote:
> Luiz Capitulino <lcapitulino@redhat.com> writes:
>
> > From: Michael Tokarev <mjt@tls.msk.ru>
> >
> > 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().
>
> To error_report(), you mean.
It's the original commit log.. Should this be fixed? If so, Michael,
could you resend?
>
> > 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 <mjt@tls.msk.ru>
> > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
>
> Looks good.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] give some useful error messages when tap open
2010-06-02 18:33 ` Luiz Capitulino
@ 2010-06-03 7:07 ` Markus Armbruster
0 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2010-06-03 7:07 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: mjt, qemu-devel
Luiz Capitulino <lcapitulino@redhat.com> writes:
> On Wed, 02 Jun 2010 20:26:58 +0200
> Markus Armbruster <armbru@redhat.com> wrote:
>
>> Luiz Capitulino <lcapitulino@redhat.com> writes:
>>
>> > From: Michael Tokarev <mjt@tls.msk.ru>
>> >
>> > 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().
>>
>> To error_report(), you mean.
>
> It's the original commit log.. Should this be fixed? If so, Michael,
> could you resend?
Or maybe it could be fixed up on commit.
[...]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] give some useful error messages when tap open
2010-06-02 17:33 [Qemu-devel] [PATCH] give some useful error messages when tap open Luiz Capitulino
2010-06-02 18:26 ` Markus Armbruster
@ 2010-06-23 1:47 ` Anthony Liguori
1 sibling, 0 replies; 5+ messages in thread
From: Anthony Liguori @ 2010-06-23 1:47 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: mjt, qemu-devel
On 06/02/2010 12:33 PM, Luiz Capitulino wrote:
> From: Michael Tokarev<mjt@tls.msk.ru>
>
> 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<mjt@tls.msk.ru>
> Signed-off-by: Luiz Capitulino<lcapitulino@redhat.com>
>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> IMPORTANT: this an old fix that got forgotten, probably because it was
> submitted in the middle of thread. I've just compiled tested it.
>
> net/tap-linux.c | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/net/tap-linux.c b/net/tap-linux.c
> index 03b8301..c92983c 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;
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-06-23 1:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-02 17:33 [Qemu-devel] [PATCH] give some useful error messages when tap open Luiz Capitulino
2010-06-02 18:26 ` Markus Armbruster
2010-06-02 18:33 ` Luiz Capitulino
2010-06-03 7:07 ` Markus Armbruster
2010-06-23 1:47 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).