* [Qemu-devel] [PATCH] fix network interface tap backend
@ 2011-06-17 8:56 Christoph Egger
2011-07-23 16:17 ` Anthony Liguori
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Egger @ 2011-06-17 8:56 UTC (permalink / raw)
To: qemu-devel@nongnu.org
Fix network interface tap backend work on NetBSD.
It uses an ioctl to get the tap name.
From Manuel Bouyer <bouyer@netbsd.org>
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
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 <sys/ioctl.h>
+#include <net/if.h>
#include <net/if_tap.h>
#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 */
--
---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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] fix network interface tap backend
2011-06-17 8:56 [Qemu-devel] [PATCH] fix network interface tap backend Christoph Egger
@ 2011-07-23 16:17 ` Anthony Liguori
2011-07-25 9:03 ` Christoph Egger
0 siblings, 1 reply; 4+ messages in thread
From: Anthony Liguori @ 2011-07-23 16:17 UTC (permalink / raw)
To: Christoph Egger; +Cc: qemu-devel@nongnu.org
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 <bouyer@netbsd.org>
> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
>
> 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 <sys/ioctl.h>
Your mailer munged this patch.
Regards,
Anthony Liguori
> +#include <net/if.h>
> #include <net/if_tap.h>
> #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 */
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] fix network interface tap backend
2011-07-23 16:17 ` Anthony Liguori
@ 2011-07-25 9:03 ` Christoph Egger
2011-08-07 9:54 ` Blue Swirl
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Egger @ 2011-07-25 9:03 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel@nongnu.org
[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]
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<bouyer@netbsd.org>
>> Signed-off-by: Christoph Egger<Christoph.Egger@amd.com>
>>
>> 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<sys/ioctl.h>
>
> 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<bouyer@netbsd.org>
Signed-off-by: Christoph Egger<Christoph.Egger@amd.com>
--
---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
[-- Attachment #2: qemu_net_tap.diff --]
[-- Type: text/plain, Size: 1691 bytes --]
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 <sys/ioctl.h>
+#include <net/if.h>
#include <net/if_tap.h>
#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 */
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] fix network interface tap backend
2011-07-25 9:03 ` Christoph Egger
@ 2011-08-07 9:54 ` Blue Swirl
0 siblings, 0 replies; 4+ messages in thread
From: Blue Swirl @ 2011-08-07 9:54 UTC (permalink / raw)
To: Christoph Egger; +Cc: qemu-devel@nongnu.org
On Mon, Jul 25, 2011 at 9:03 AM, Christoph Egger
<Christoph.Egger@amd.com> wrote:
> 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<bouyer@netbsd.org>
>>> Signed-off-by: Christoph Egger<Christoph.Egger@amd.com>
>>>
>>> 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<sys/ioctl.h>
>>
>> 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.
Please attach the whole commit for example from 'git show', instead of
just the diff. That can be fed to 'git am' directly. Now I had to
combine the lines below and the patch by hand.
Thanks, applied.
> Fix network interface tap backend work on NetBSD.
> It uses an ioctl to get the tap name.
>
> From Manuel Bouyer<bouyer@netbsd.org>
> Signed-off-by: Christoph Egger<Christoph.Egger@amd.com>
>
> --
> ---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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-07 9:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-17 8:56 [Qemu-devel] [PATCH] fix network interface tap backend Christoph Egger
2011-07-23 16:17 ` Anthony Liguori
2011-07-25 9:03 ` Christoph Egger
2011-08-07 9:54 ` Blue Swirl
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).