From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O5II3-00061R-DZ for qemu-devel@nongnu.org; Fri, 23 Apr 2010 08:47:27 -0400 Received: from [140.186.70.92] (port=48136 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O5II2-00060s-1H for qemu-devel@nongnu.org; Fri, 23 Apr 2010 08:47:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O5II0-0002hY-4s for qemu-devel@nongnu.org; Fri, 23 Apr 2010 08:47:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54203) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O5IHz-0002hE-SE for qemu-devel@nongnu.org; Fri, 23 Apr 2010 08:47:24 -0400 Message-ID: <4BD196BB.6050603@redhat.com> Date: Fri, 23 Apr 2010 14:46:51 +0200 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] give some useful error messages when tap open fails References: <20100422092826.EF03612B5C@gandalf.tls.msk.ru> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Michael Tokarev , qemu-devel@nongnu.org Am 22.04.2010 11:52, schrieb Markus Armbruster: > Michael Tokarev writes: > >> 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 >> >> 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)); > > This might apply to the stable branch (I haven't tried), but I don't > think it works on master. There, it should look like this (untested): > > + error_report("could not open /dev/net/tun: %m"); I'm not sure where this %m is defined exactly (Linux specific? Maybe BSDs, too?), but it doesn't seem to work with mingw. Kevin