* [Qemu-devel][PATCH] Tap and VLAN socket support for win32 @ 2006-01-31 7:34 Kazu 2006-01-31 16:00 ` André Braga 2006-02-01 23:10 ` Fabrice Bellard 0 siblings, 2 replies; 12+ messages in thread From: Kazu @ 2006-01-31 7:34 UTC (permalink / raw) To: qemu-devel Hi, I updated a patch to support tap for win32. Here is patches and a binary. These patches are applied by patch -p1 option. Tap patch can be applied on top of VLAN patch. VLAN patch is updated. http://www.h7.dion.ne.jp/~qemu-win/download/qemu-20060111-vlan.patch http://www.h7.dion.ne.jp/~qemu-win/download/qemu-20060111-tap.patch http://www.h6.dion.ne.jp/~kazuw/qemu-win/qemu-20060111-vlan-tap.zip Options are: -net nic -net tap,ifname=my-tap Use ifname to set a name of Tap. my-tap is the name of my TAP-Win32 Adapter. Don't use the same network address as a physical network. For example, if the physical network is 192.168.0.x, use different network 192.168.10.y for TAP-Win32 Adapter. For more information, http://www.h7.dion.ne.jp/~qemu-win/TapWin32-en.html#vlan Regards, Kazu ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel][PATCH] Tap and VLAN socket support for win32 2006-01-31 7:34 [Qemu-devel][PATCH] Tap and VLAN socket support for win32 Kazu @ 2006-01-31 16:00 ` André Braga 2006-02-01 23:10 ` Fabrice Bellard 1 sibling, 0 replies; 12+ messages in thread From: André Braga @ 2006-01-31 16:00 UTC (permalink / raw) To: qemu-devel Wow, thanks! I almost gave up on seeing someone port over this patch :) -- "I decry the current tendency to seek patents on algorithms. There are better ways to earn a living than to prevent other people from making use of one's contributions to computer science." Donald Knuth On 1/31/06, Kazu <kazoo@r3.dion.ne.jp> wrote: > Hi, > > I updated a patch to support tap for win32. > > Here is patches and a binary. > These patches are applied by patch -p1 option. Tap patch can be applied on > top of VLAN patch. VLAN patch is updated. > http://www.h7.dion.ne.jp/~qemu-win/download/qemu-20060111-vlan.patch > http://www.h7.dion.ne.jp/~qemu-win/download/qemu-20060111-tap.patch > > http://www.h6.dion.ne.jp/~kazuw/qemu-win/qemu-20060111-vlan-tap.zip > > Options are: > -net nic -net tap,ifname=my-tap > Use ifname to set a name of Tap. > my-tap is the name of my TAP-Win32 Adapter. > > Don't use the same network address as a physical network. > For example, if the physical network is 192.168.0.x, use different network > 192.168.10.y for TAP-Win32 Adapter. > > For more information, > http://www.h7.dion.ne.jp/~qemu-win/TapWin32-en.html#vlan > > Regards, > Kazu ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel][PATCH] Tap and VLAN socket support for win32 2006-01-31 7:34 [Qemu-devel][PATCH] Tap and VLAN socket support for win32 Kazu 2006-01-31 16:00 ` André Braga @ 2006-02-01 23:10 ` Fabrice Bellard 2006-02-02 10:03 ` Kazu ` (2 more replies) 1 sibling, 3 replies; 12+ messages in thread From: Fabrice Bellard @ 2006-02-01 23:10 UTC (permalink / raw) To: qemu-devel Hi, I merged your patches and I made important changes to simplify them. I did not do any tests so tell me if you see problems. Regards, Fabrice. Kazu wrote: > Hi, > > I updated a patch to support tap for win32. > > Here is patches and a binary. > These patches are applied by patch -p1 option. Tap patch can be applied on > top of VLAN patch. VLAN patch is updated. > http://www.h7.dion.ne.jp/~qemu-win/download/qemu-20060111-vlan.patch > http://www.h7.dion.ne.jp/~qemu-win/download/qemu-20060111-tap.patch > > http://www.h6.dion.ne.jp/~kazuw/qemu-win/qemu-20060111-vlan-tap.zip > > Options are: > -net nic -net tap,ifname=my-tap > Use ifname to set a name of Tap. > my-tap is the name of my TAP-Win32 Adapter. > > Don't use the same network address as a physical network. > For example, if the physical network is 192.168.0.x, use different > network 192.168.10.y for TAP-Win32 Adapter. > > For more information, > http://www.h7.dion.ne.jp/~qemu-win/TapWin32-en.html#vlan > > Regards, > Kazu > > > > > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel][PATCH] Tap and VLAN socket support for win32 2006-02-01 23:10 ` Fabrice Bellard @ 2006-02-02 10:03 ` Kazu 2006-02-04 18:28 ` Fabrice Bellard 2006-02-05 4:05 ` Jim C. Brown 2006-02-07 21:18 ` Jim C. Brown 2 siblings, 1 reply; 12+ messages in thread From: Kazu @ 2006-02-02 10:03 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 1706 bytes --] Thursday, February 02, 2006 8:10 AM Fabrice Bellard wrote: > Hi, > > I merged your patches and I made important changes to simplify them. I > did not do any tests so tell me if you see problems. > -net socket,connect doesn't work. On Windows host, connect returns with err = WSAEWOULDBLOCK and second time err = WSAEINVAL. I think changing the place of EWOULDBLOCK would be good. On Linux host, EWOULDBLOCK is the same as EAGAIN but a patch works on both Linux and Windows. For -net socket,mcast, bind have to be done by sin_addr.s_addr = INADDR_ANY. It seems that it works on Linux host. Regards, Kazu Index: vl.c =================================================================== RCS file: /sources/qemu/qemu/vl.c,v retrieving revision 1.160 diff -u -r1.160 vl.c --- vl.c 1 Feb 2006 23:06:55 -0000 1.160 +++ vl.c 2 Feb 2006 09:28:19 -0000 @@ -2335,7 +2335,13 @@ goto fail; } - ret = bind(fd, (struct sockaddr *)mcastaddr, sizeof(*mcastaddr)); + struct sockaddr_in addr; + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = mcastaddr->sin_port; + addr.sin_addr.s_addr = INADDR_ANY; + + ret = bind(fd, (struct sockaddr *)&addr, sizeof(addr)); if (ret < 0) { perror("bind"); goto fail; @@ -2561,8 +2567,8 @@ ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)); if (ret < 0) { err = socket_error(); - if (err == EINTR || err == EWOULDBLOCK) { - } else if (err == EINPROGRESS) { + if (err == EINTR) { + } else if (err == EINPROGRESS || err == EWOULDBLOCK) { break; } else { perror("connect"); [-- Attachment #2: qemu-20060202-vlan.patch --] [-- Type: application/octet-stream, Size: 1132 bytes --] Index: vl.c =================================================================== RCS file: /sources/qemu/qemu/vl.c,v retrieving revision 1.160 diff -u -r1.160 vl.c --- vl.c 1 Feb 2006 23:06:55 -0000 1.160 +++ vl.c 2 Feb 2006 09:28:19 -0000 @@ -2335,7 +2335,13 @@ goto fail; } - ret = bind(fd, (struct sockaddr *)mcastaddr, sizeof(*mcastaddr)); + struct sockaddr_in addr; + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = mcastaddr->sin_port; + addr.sin_addr.s_addr = INADDR_ANY; + + ret = bind(fd, (struct sockaddr *)&addr, sizeof(addr)); if (ret < 0) { perror("bind"); goto fail; @@ -2561,8 +2567,8 @@ ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)); if (ret < 0) { err = socket_error(); - if (err == EINTR || err == EWOULDBLOCK) { - } else if (err == EINPROGRESS) { + if (err == EINTR) { + } else if (err == EINPROGRESS || err == EWOULDBLOCK) { break; } else { perror("connect"); ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel][PATCH] Tap and VLAN socket support for win32 2006-02-02 10:03 ` Kazu @ 2006-02-04 18:28 ` Fabrice Bellard 2006-02-09 2:29 ` Kazu 2006-02-09 14:00 ` Kazu 0 siblings, 2 replies; 12+ messages in thread From: Fabrice Bellard @ 2006-02-04 18:28 UTC (permalink / raw) To: qemu-devel Kazu wrote: > Thursday, February 02, 2006 8:10 AM Fabrice Bellard wrote: > >> Hi, >> >> I merged your patches and I made important changes to simplify them. I >> did not do any tests so tell me if you see problems. >> > > -net socket,connect doesn't work. On Windows host, connect returns with err > = WSAEWOULDBLOCK and second time err = WSAEINVAL. I think changing the > place > of EWOULDBLOCK would be good. On Linux host, EWOULDBLOCK is the same as > EAGAIN but a patch works on both Linux and Windows. Unfortunately on Linux the correct return value we are expecting is EINPROGRESS. EAGAIN means that the 'connect' was not initiated so it is necessary to redo it. > > For -net socket,mcast, bind have to be done by sin_addr.s_addr = > INADDR_ANY. > It seems that it works on Linux host. It works on Linux but it is not correct because it prevents from listening to several multicast addresses at the same time. If doing the same on Windows is not possible I agree to make a special case. Fabrice. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel][PATCH] Tap and VLAN socket support for win32 2006-02-04 18:28 ` Fabrice Bellard @ 2006-02-09 2:29 ` Kazu 2006-02-09 14:00 ` Kazu 1 sibling, 0 replies; 12+ messages in thread From: Kazu @ 2006-02-09 2:29 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 5582 bytes --] Sunday, February 05, 2006 3:28 AM Fabrice Bellard wrote: > Kazu wrote: >> Thursday, February 02, 2006 8:10 AM Fabrice Bellard wrote: >> >>> Hi, >>> >>> I merged your patches and I made important changes to simplify them. I >>> did not do any tests so tell me if you see problems. >>> >> >> -net socket,connect doesn't work. On Windows host, connect returns with >> err >> = WSAEWOULDBLOCK and second time err = WSAEINVAL. I think changing the >> place >> of EWOULDBLOCK would be good. On Linux host, EWOULDBLOCK is the same as >> EAGAIN but a patch works on both Linux and Windows. > > Unfortunately on Linux the correct return value we are expecting is > EINPROGRESS. EAGAIN means that the 'connect' was not initiated so it is > necessary to redo it. > There is not good way to detect a completion of asynchronous connect. So I used an event object to detect it. A patch is attached. >> >> For -net socket,mcast, bind have to be done by sin_addr.s_addr = >> INADDR_ANY. >> It seems that it works on Linux host. > > It works on Linux but it is not correct because it prevents from listening > to several multicast addresses at the same time. If doing the same on > Windows is not possible I agree to make a special case. > I couldn't find a way to set a multicast address. I made it a special case in the patch Regard, Kazu Index: vl.c =================================================================== RCS file: /sources/qemu/qemu/vl.c,v retrieving revision 1.162 diff -u -r1.162 vl.c --- vl.c 5 Feb 2006 04:14:41 -0000 1.162 +++ vl.c 8 Feb 2006 05:50:28 -0000 @@ -1083,9 +1083,10 @@ #define socket_error() WSAGetLastError() #undef EINTR -#define EWOULDBLOCK WSAEWOULDBLOCK -#define EINTR WSAEINTR -#define EINPROGRESS WSAEINPROGRESS +#define EWOULDBLOCK WSAEWOULDBLOCK +#define EINTR WSAEINTR +#define EINPROGRESS WSAEINPROGRESS +#define EADDRNOTAVAIL WSAEADDRNOTAVAIL static void socket_cleanup(void) { @@ -1136,6 +1137,59 @@ ioctlsocket(fd, FIONBIO, &opt); } +static int socket_set_event(SOCKET fd, WSAEVENT *phEvent) +{ + int ret; + + *phEvent = WSACreateEvent(); + if (*phEvent == WSA_INVALID_EVENT) { + perror("connect: CreateEvent"); + return -1; + } + + ret = WSAEventSelect(fd, *phEvent, FD_CONNECT); + if (ret == SOCKET_ERROR) { + perror("connect: EventSelect"); + return -1; + } + return 0; +} + +static int socket_wait_event(SOCKET fd, WSAEVENT *phEvent) +{ + WSANETWORKEVENTS events; + int ret; + + ret = WSAWaitForMultipleEvents(1, phEvent, FALSE, WSA_INFINITE, FALSE); + if (ret == WSA_WAIT_FAILED) { + perror("connect: Wait"); + goto fail; + } + + ret = WSAEnumNetworkEvents(fd, *phEvent, &events); + if (ret == SOCKET_ERROR) { + perror("connect: EnumEvent"); + goto fail; + } else { + if (events.lNetworkEvents & FD_CONNECT) { + if (events.iErrorCode[FD_CONNECT_BIT] == 0) { + if (*phEvent != WSA_INVALID_EVENT) + WSACloseEvent(*phEvent); + return 1; + } else { + perror("connect: refused"); + goto fail; + } + } else { + perror("connect: fd_connect"); + goto fail; + } + } + fail: + if (*phEvent != WSA_INVALID_EVENT) + WSACloseEvent(*phEvent); + return 0; +} #else #define socket_error() errno @@ -2330,7 +2384,9 @@ { struct ip_mreq imr; int fd; - int val, ret; + int val, ret, err; + struct sockaddr_in addr; + if (!IN_MULTICAST(ntohl(mcastaddr->sin_addr.s_addr))) { fprintf(stderr, "qemu: error: specified mcastaddr \"%s\" (0x%08x) does not contain a multicast address\n", inet_ntoa(mcastaddr->sin_addr), @@ -2354,8 +2410,22 @@ ret = bind(fd, (struct sockaddr *)mcastaddr, sizeof(*mcastaddr)); if (ret < 0) { - perror("bind"); - goto fail; + err = socket_error(); + if (err == EADDRNOTAVAIL) { + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = mcastaddr->sin_port; + addr.sin_addr.s_addr = INADDR_ANY; + + ret = bind(fd, (struct sockaddr *)&addr, sizeof(addr)); + if (ret < 0) { + perror("bind"); + goto fail; + } + } else { + perror("bind"); + goto fail; + } } /* Add host to multicast group */ @@ -2557,11 +2627,15 @@ return 0; } + static int net_socket_connect_init(VLANState *vlan, const char *host_str) { NetSocketState *s; int fd, connected, ret, err; struct sockaddr_in saddr; +#ifdef _WIN32 + WSAEVENT hEvent; +#endif if (parse_host_port(&saddr, host_str) < 0) return -1; @@ -2573,6 +2647,26 @@ } socket_set_nonblock(fd); +#ifdef _WIN32 + ret = socket_set_event(fd, &hEvent); + if (ret < 0) { + perror("connect: set_event"); + closesocket(fd); + return -1; + } + + connected = 0; + ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)); + + err = socket_wait_event(fd, &hEvent); + if (err > 0) { + connected = 1; + } else { + perror("connect"); + closesocket(fd); + return -1; + } +#else connected = 0; for(;;) { ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)); @@ -2591,6 +2685,8 @@ break; } } +#endif + s = net_socket_fd_init(vlan, fd, connected); if (!s) return -1; [-- Attachment #2: qemu-20060208-vlan-2.patch.gz --] [-- Type: application/x-gzip, Size: 1475 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel][PATCH] Tap and VLAN socket support for win32 2006-02-04 18:28 ` Fabrice Bellard 2006-02-09 2:29 ` Kazu @ 2006-02-09 14:00 ` Kazu 1 sibling, 0 replies; 12+ messages in thread From: Kazu @ 2006-02-09 14:00 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 1431 bytes --] Hi, I send this mail again because it doesn't reach qemu-devel list by unknown security reason. Sent: Sunday, February 05, 2006 3:28 AM Fabrice Bellard wrote: > Kazu wrote: >> Thursday, February 02, 2006 8:10 AM Fabrice Bellard wrote: >> >>> Hi, >>> >>> I merged your patches and I made important changes to simplify them. I >>> did not do any tests so tell me if you see problems. >>> >> >> -net socket,connect doesn't work. On Windows host, connect returns with err >> = WSAEWOULDBLOCK and second time err = WSAEINVAL. I think changing the >> place >> of EWOULDBLOCK would be good. On Linux host, EWOULDBLOCK is the same as >> EAGAIN but a patch works on both Linux and Windows. > > Unfortunately on Linux the correct return value we are expecting is > EINPROGRESS. EAGAIN means that the 'connect' was not initiated so it is > necessary to redo it. > There is not good way to detect a completion of asynchronous connect. So I used an event object to detect it. A patch is attached. >> >> For -net socket,mcast, bind have to be done by sin_addr.s_addr = >> INADDR_ANY. >> It seems that it works on Linux host. > > It works on Linux but it is not correct because it prevents from > listening to several multicast addresses at the same time. If doing the > same on Windows is not possible I agree to make a special case. > I couldn't find a way to set a multicast address. I made it a special case in the patch Regards, Kazu [-- Attachment #2: qemu-20060208-vlan-2.patch.gz --] [-- Type: application/x-gzip, Size: 1475 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel][PATCH] Tap and VLAN socket support for win32 2006-02-01 23:10 ` Fabrice Bellard 2006-02-02 10:03 ` Kazu @ 2006-02-05 4:05 ` Jim C. Brown 2006-02-07 21:18 ` Jim C. Brown 2 siblings, 0 replies; 12+ messages in thread From: Jim C. Brown @ 2006-02-05 4:05 UTC (permalink / raw) To: qemu-devel On Thu, Feb 02, 2006 at 12:10:36AM +0100, Fabrice Bellard wrote: > Hi, > > I merged your patches and I made important changes to simplify them. I > did not do any tests so tell me if you see problems. > > Regards, > > Fabrice. > Have you decided to accept the GPL license on it then? http://lists.gnu.org/archive/html/qemu-devel/2004-10/msg00217.html -- Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel][PATCH] Tap and VLAN socket support for win32 2006-02-01 23:10 ` Fabrice Bellard 2006-02-02 10:03 ` Kazu 2006-02-05 4:05 ` Jim C. Brown @ 2006-02-07 21:18 ` Jim C. Brown 2006-02-07 21:44 ` Fabrice Bellard 2 siblings, 1 reply; 12+ messages in thread From: Jim C. Brown @ 2006-02-07 21:18 UTC (permalink / raw) To: qemu-devel On Thu, Feb 02, 2006 at 12:10:36AM +0100, Fabrice Bellard wrote: > Hi, > > I merged your patches and I made important changes to simplify them. I > did not do any tests so tell me if you see problems. > > Regards, > > Fabrice. > Have you decided to accept the GPL license on it then? http://lists.gnu.org/archive/html/qemu-devel/2004-10/msg00217.html -- Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel][PATCH] Tap and VLAN socket support for win32 2006-02-07 21:18 ` Jim C. Brown @ 2006-02-07 21:44 ` Fabrice Bellard 2006-02-08 7:23 ` David Fraser 0 siblings, 1 reply; 12+ messages in thread From: Fabrice Bellard @ 2006-02-07 21:44 UTC (permalink / raw) To: qemu-devel Jim C. Brown wrote: > On Thu, Feb 02, 2006 at 12:10:36AM +0100, Fabrice Bellard wrote: > >>Hi, >> >>I merged your patches and I made important changes to simplify them. I >>did not do any tests so tell me if you see problems. >> >>Regards, >> >>Fabrice. >> > > > Have you decided to accept the GPL license on it then? > > http://lists.gnu.org/archive/html/qemu-devel/2004-10/msg00217.html Yes because the features are packed in a single file which can be removed if needed. Fabrice. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel][PATCH] Tap and VLAN socket support for win32 2006-02-07 21:44 ` Fabrice Bellard @ 2006-02-08 7:23 ` David Fraser 2006-02-08 7:32 ` M. Warner Losh 0 siblings, 1 reply; 12+ messages in thread From: David Fraser @ 2006-02-08 7:23 UTC (permalink / raw) To: qemu-devel Fabrice Bellard wrote: > Jim C. Brown wrote: >> On Thu, Feb 02, 2006 at 12:10:36AM +0100, Fabrice Bellard wrote: >> >>> Hi, >>> >>> I merged your patches and I made important changes to simplify them. I >>> did not do any tests so tell me if you see problems. >>> >>> Regards, >>> >>> Fabrice. >>> >> >> >> Have you decided to accept the GPL license on it then? >> >> http://lists.gnu.org/archive/html/qemu-devel/2004-10/msg00217.html > > Yes because the features are packed in a single file which can be > removed if needed. Just checking, would that make it illegal to use this feature together with kqemu? David ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel][PATCH] Tap and VLAN socket support for win32 2006-02-08 7:23 ` David Fraser @ 2006-02-08 7:32 ` M. Warner Losh 0 siblings, 0 replies; 12+ messages in thread From: M. Warner Losh @ 2006-02-08 7:32 UTC (permalink / raw) To: qemu-devel, davidf In message: <43E99C81.6040302@sjsoft.com> David Fraser <davidf@sjsoft.com> writes: : Fabrice Bellard wrote: : > Jim C. Brown wrote: : >> On Thu, Feb 02, 2006 at 12:10:36AM +0100, Fabrice Bellard wrote: : >> : >>> Hi, : >>> : >>> I merged your patches and I made important changes to simplify them. I : >>> did not do any tests so tell me if you see problems. : >>> : >>> Regards, : >>> : >>> Fabrice. : >>> : >> : >> : >> Have you decided to accept the GPL license on it then? : >> : >> http://lists.gnu.org/archive/html/qemu-devel/2004-10/msg00217.html : > : > Yes because the features are packed in a single file which can be : > removed if needed. : Just checking, would that make it illegal to use this feature together : with kqemu? No. The GPL is about distribution, not use. It might make certain binary packages contrary to rights granted by the GPL. Warner ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2006-02-09 14:44 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-01-31 7:34 [Qemu-devel][PATCH] Tap and VLAN socket support for win32 Kazu 2006-01-31 16:00 ` André Braga 2006-02-01 23:10 ` Fabrice Bellard 2006-02-02 10:03 ` Kazu 2006-02-04 18:28 ` Fabrice Bellard 2006-02-09 2:29 ` Kazu 2006-02-09 14:00 ` Kazu 2006-02-05 4:05 ` Jim C. Brown 2006-02-07 21:18 ` Jim C. Brown 2006-02-07 21:44 ` Fabrice Bellard 2006-02-08 7:23 ` David Fraser 2006-02-08 7:32 ` M. Warner Losh
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).