From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlH4q-0002x8-A1 for qemu-devel@nongnu.org; Mon, 25 Jul 2011 05:03:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlH4p-0004bA-7L for qemu-devel@nongnu.org; Mon, 25 Jul 2011 05:03:52 -0400 Received: from tx2ehsobe004.messaging.microsoft.com ([65.55.88.14]:13047 helo=TX2EHSOBE007.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlH4p-0004b2-2t for qemu-devel@nongnu.org; Mon, 25 Jul 2011 05:03:51 -0400 Message-ID: <4E2D316F.5020300@amd.com> Date: Mon, 25 Jul 2011 11:03:43 +0200 From: Christoph Egger MIME-Version: 1.0 References: <4DFB16B2.7020302@amd.com> <4E2AF409.5010909@codemonkey.ws> In-Reply-To: <4E2AF409.5010909@codemonkey.ws> Content-Type: multipart/mixed; boundary="------------020302030803080508070405" Subject: Re: [Qemu-devel] [PATCH] fix network interface tap backend List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: "qemu-devel@nongnu.org" --------------020302030803080508070405 Content-Type: text/plain; charset="ISO-8859-15"; format=flowed Content-Transfer-Encoding: 7bit On 07/23/11 18:17, Anthony Liguori wrote: > On 06/17/2011 03:56 AM, Christoph Egger wrote: >> >> Fix network interface tap backend work on NetBSD. >> It uses an ioctl to get the tap name. >> >> From Manuel Bouyer >> Signed-off-by: Christoph Egger >> >> diff --git a/net/tap-bsd.c b/net/tap-bsd.c >> index 2f3efde..577aafe 100644 >> --- a/net/tap-bsd.c >> +++ b/net/tap-bsd.c >> @@ -28,6 +28,8 @@ >> #include "qemu-error.h" >> >> #ifdef __NetBSD__ >> +#include > > Your mailer munged this patch. ... or by the MS Exchange Server. Resending the patch as attachment, the only one way I have that works for everyone. Sorry. Fix network interface tap backend work on NetBSD. It uses an ioctl to get the tap name. From Manuel Bouyer Signed-off-by: Christoph Egger -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 --------------020302030803080508070405 Content-Type: text/plain; name="qemu_net_tap.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="qemu_net_tap.diff" Content-Description: qemu_net_tap.diff diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 2f3efde..577aafe 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -28,6 +28,8 @@ #include "qemu-error.h" #ifdef __NetBSD__ +#include +#include #include #endif @@ -40,8 +42,12 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required) { int fd; +#ifdef TAPGIFNAME + struct ifreq ifr; +#else char *dev; struct stat s; +#endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) /* if no ifname is given, always start the search from tap0/tun0. */ @@ -77,14 +83,30 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required #else TFR(fd = open("/dev/tap", O_RDWR)); if (fd < 0) { - fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n"); + fprintf(stderr, + "warning: could not open /dev/tap: no virtual network emulation: %s\n", + strerror(errno)); return -1; } #endif - fstat(fd, &s); +#ifdef TAPGIFNAME + if (ioctl(fd, TAPGIFNAME, (void *)&ifr) < 0) { + fprintf(stderr, "warning: could not get tap name: %s\n", + strerror(errno)); + return -1; + } + pstrcpy(ifname, ifname_size, ifr.ifr_name); +#else + if (fstat(fd, &s) < 0) { + fprintf(stderr, + "warning: could not stat /dev/tap: no virtual network emulation: %s\n", + strerror(errno)); + return -1; + } dev = devname(s.st_rdev, S_IFCHR); pstrcpy(ifname, ifname_size, dev); +#endif if (*vnet_hdr) { /* BSD doesn't have IFF_VNET_HDR */ --------------020302030803080508070405--