From patchwork Mon Jul 25 09:03:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Egger X-Patchwork-Id: 106622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 655D7B6F68 for ; Mon, 25 Jul 2011 19:04:02 +1000 (EST) Received: from localhost ([::1]:33268 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlH4w-0002xH-5F for incoming@patchwork.ozlabs.org; Mon, 25 Jul 2011 05:03:58 -0400 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 Received: from mail56-tx2-R.bigfish.com (10.9.14.246) by TX2EHSOBE007.bigfish.com (10.9.40.27) with Microsoft SMTP Server id 14.1.225.22; Mon, 25 Jul 2011 09:03:49 +0000 Received: from mail56-tx2 (localhost.localdomain [127.0.0.1]) by mail56-tx2-R.bigfish.com (Postfix) with ESMTP id 5AFCF5B836A; Mon, 25 Jul 2011 09:03:49 +0000 (UTC) X-SpamScore: -16 X-BigFish: VPS-16(zzbb2dK9371Mc85dh1432N98dKzz1202hzz8275bh8275dhz32i668h839h34h61h) X-Forefront-Antispam-Report: CIP:163.181.249.109; KIP:(null); UIP:(null); IPVD:NLI; H:ausb3twp02.amd.com; RD:none; EFVD:NLI Received: from mail56-tx2 (localhost.localdomain [127.0.0.1]) by mail56-tx2 (MessageSwitch) id 1311584629217902_4750; Mon, 25 Jul 2011 09:03:49 +0000 (UTC) Received: from TX2EHSMHS031.bigfish.com (unknown [10.9.14.242]) by mail56-tx2.bigfish.com (Postfix) with ESMTP id 310767D004C; Mon, 25 Jul 2011 09:03:49 +0000 (UTC) Received: from ausb3twp02.amd.com (163.181.249.109) by TX2EHSMHS031.bigfish.com (10.9.99.131) with Microsoft SMTP Server id 14.1.225.22; Mon, 25 Jul 2011 09:03:48 +0000 X-WSS-ID: 0LOVT6A-02-ALZ-02 X-M-MSG: Received: from sausexedgep01.amd.com (sausexedgep01-ext.amd.com [163.181.249.72]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Axway MailGate 3.8.1) with ESMTP id 22046C83EB; Mon, 25 Jul 2011 04:03:45 -0500 (CDT) Received: from SAUSEXDAG01.amd.com (163.181.55.1) by sausexedgep01.amd.com (163.181.36.54) with Microsoft SMTP Server (TLS) id 8.3.106.1; Mon, 25 Jul 2011 04:03:51 -0500 Received: from storexhtp02.amd.com (172.24.4.4) by sausexdag01.amd.com (163.181.55.1) with Microsoft SMTP Server (TLS) id 14.1.289.1; Mon, 25 Jul 2011 04:03:47 -0500 Received: from rhodium.osrc.amd.com (165.204.15.173) by storexhtp02.amd.com (172.24.4.4) with Microsoft SMTP Server id 8.3.83.0; Mon, 25 Jul 2011 05:03:46 -0400 Message-ID: <4E2D316F.5020300@amd.com> Date: Mon, 25 Jul 2011 11:03:43 +0200 From: Christoph Egger User-Agent: Mozilla/5.0 (X11; U; NetBSD amd64; en-US; rv:1.9.2.17) Gecko/20110523 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: Anthony Liguori References: <4DFB16B2.7020302@amd.com> <4E2AF409.5010909@codemonkey.ws> In-Reply-To: <4E2AF409.5010909@codemonkey.ws> X-OriginatorOrg: amd.com X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP2+, XP SP1+ (seldom 98) X-Received-From: 65.55.88.14 Cc: "qemu-devel@nongnu.org" Subject: Re: [Qemu-devel] [PATCH] fix network interface tap backend X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 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 */