On Tue, Mar 15, 2011 at 09:29:14AM +0100, Matthias Bolte wrote:
Commit 2ed6cc7bec41dd344d41ea1531f6760c93099128 "Expose event
loop
implementation as a public API" turned a failure to initialize the
default event loop into a fatal error in virsh on Windows. Before that
commit such a failure was ignored.
virEventRegisterDefaultImpl calls virEventPollInit that calls
virSetNonBlock that calls ioctl that is replaced by gnulib and calls
ioctlsocket. ioctlsocket fails because the given FD is a pipe but
ioctlsocket expects a socket.
Hmm, isn't this actually a bug in gnulib's ioctl replacement then ?
The goal of gnulib is that you never use a SOCKET in any of the
POSIX APIs it wraps. It hides the WinSock horribleness so that you
can just use normal FDs everywhere.
A version that works on pipes on Windows looks like this. Although
the
pipe is actually not a named pipe the call to SetNamedPipeHandleState
doesn't fail at least.
int
virSetPipeNonBlock(int fd)
{
DWORD mode = PIPE_NOWAIT;
HANDLE handle = _get_osfhandle(fd)
BOOL result = SetNamedPipeHandleState(handle, &mode, NULL, NULL);
return result ? 0 : -1;
}
So, is the event loop stuff supposed to work on Windows at all and we
should get it fixed? Or do we just put an #ifndef WIN32 around
virEventRegisterDefaultImpl in virsh, because the only event loop user
in virsh is the console command that is disabled on Windows anyway?
There were several reasons the console stuff used to be disabled
- It relied on opening /dev/pts/XXX which obviously only
makes sense for local connection, not remote ones.
- It uses the terminal attribute APIs to put the console
into raw mode.
The event loop is intended to be portable, and certainly, now it is
a public API we should make it work. The opening of /dev/pts/XXX is
no longer a blocker for virsh console on Win32, since we access the
console via the streams APIs. So if we can figure out what todo with
the terminal attribute APIs, virsh console should work on Win32 (or
any other platform). This is one of the nice benefits of the streams
API
Regards,
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|