From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:35703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0y41-00032I-Qm for qemu-devel@nongnu.org; Tue, 06 Sep 2011 11:59:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0y3s-00082T-5X for qemu-devel@nongnu.org; Tue, 06 Sep 2011 11:59:53 -0400 Received: from mail-yi0-f45.google.com ([209.85.218.45]:62587) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0y3r-00082N-TG for qemu-devel@nongnu.org; Tue, 06 Sep 2011 11:59:44 -0400 Received: by yih10 with SMTP id 10so4588020yih.4 for ; Tue, 06 Sep 2011 08:59:43 -0700 (PDT) Message-ID: <4E66436D.6020507@codemonkey.ws> Date: Tue, 06 Sep 2011 10:59:41 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1314018774-27482-1-git-send-email-aliguori@us.ibm.com> <1314018774-27482-2-git-send-email-aliguori@us.ibm.com> <4E525C5A.8000208@redhat.com> <4E525D87.8010400@codemonkey.ws> <4E525E09.2000107@redhat.com> <4E662EC3.4070603@redhat.com> In-Reply-To: <4E662EC3.4070603@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] main: switch qemu_set_fd_handler to g_io_add_watch List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Blue Swirl , Anthony Liguori , qemu-devel@nongnu.org On 09/06/2011 09:31 AM, Paolo Bonzini wrote: > On 08/22/2011 03:47 PM, Paolo Bonzini wrote: >> On 08/22/2011 03:45 PM, Anthony Liguori wrote: >>>> >>>> Almost: in Win32 you need to use g_io_channel_win32_new_socket. But >>>> indeed on Windows you can only use qemu_set_fd_handler for sockets too. >>> >>> I think that's really only for read/write though. If you're just >>> polling on I/O, it shouldn't matter IIUC. >>> >>> If someone has a Windows box, they can confirm/deny by using qemu >>> -monitor tcp:localhost:1024,socket,nowait with this patch. >> >> Actually you're right, it works automagically: >> >> * On Win32, this can be used either for files opened with the MSVCRT >> * (the Microsoft run-time C library) _open() or _pipe, including file >> * descriptors 0, 1 and 2 (corresponding to stdin, stdout and stderr), >> * or for Winsock SOCKETs. If the parameter is a legal file >> * descriptor, it is assumed to be such, otherwise it should be a >> * SOCKET. This relies on SOCKETs and file descriptors not >> * overlapping. If you want to be certain, call either >> * g_io_channel_win32_new_fd() or g_io_channel_win32_new_socket() >> * instead as appropriate. >> >> So this patch would even let interested people enable exec migration on >> Windows. > > Hmmm, after reading documentation better, this unfortunately is > completely broken under Windows, for two reasons: > > 1) in patch 1/2 you're using the glib pollfds and passing them to > select(). Unfortunately under Windows they are special and can only be > passed to g_poll(). Unfortunately, this can be fixed by changing the > QEMU main loop to use poll() instead of select()... Hrm, okay. > 2) ... because glib IO channels cannot be used just for watches under > Windows: > > /* Create an IO channel for C runtime (emulated Unix-like) file > * descriptors. After calling g_io_add_watch() on a IO channel > * returned by this function, you shouldn't call read() on the file > * descriptor. This is because adding polling for a file descriptor is > * implemented on Win32 by starting a thread that sits blocked in a > * read() from the file descriptor most of the time. All reads from > * the file descriptor should be done by this internal GLib > * thread. Your code should call only g_io_channel_read(). > */ > > So, I believe the right solution would be to drop this patch for now and > make 1/2 conditional on !_WIN32. So it should be possible to add a new Source type that just selects on a file descriptor and avoid GIOChannels? Regards, Anthony Liguori > > Paolo