[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v1 17/21] osdep: add wrappers for socket functio
From: |
Daniel P. Berrange |
Subject: |
Re: [Qemu-devel] [PATCH v1 17/21] osdep: add wrappers for socket functions |
Date: |
Thu, 10 Mar 2016 14:52:42 +0000 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Wed, Mar 09, 2016 at 07:04:53PM +0100, Paolo Bonzini wrote:
>
>
> On 09/03/2016 18:28, Daniel P. Berrange wrote:
> > +static bool qemu_is_socket(int fd)
> > +{
> > + int optval = 0;
> > + socklen_t optlen;
> > + optlen = sizeof(optval);
> > + return getsockopt(fd, SOL_SOCKET, SO_TYPE,
> > + (char *)&optval, &optlen) == 0;
>
> I think it's possible for a socket (which is actually a HANDLE) and a
> file descriptor with the same numeric value to exist at the same time.
> It's unlikely but it cannot be ruled out.
Aieee, nice one realizing that problem !
> gnulib does this getsockopt (or at least could plausibly do it, I didn't
> check :)) because it opens a libc file descriptor for every socket.
> However, this only breaks ioctl and close and patch 18; neither ioctl
> nor close's errors are ever checked in QEMU.
> Doing the libc file descriptor in wrapping makes the select and poll
> wrappers much more complex. gnulib in fact even makes them work on
> files, consoles, etc. besides pipes to provide a fuller POSIX layer. In
> my opinion this is beyond QEMU's scope and not really in line with
> QEMU's attempts to use Win32 natively whenever applicable (e.g. in
> qemu-char.c and block/raw-win32.c).
>
> However, I'm okay with the other wrapping that you do in this patch.
> Being able to drop socket_error() is a big improvement.
Yep, so I've removed the wrapping of close/ioctl, and in their place
I'm wrapping closesocket/ioctlsocket to address errno/socket_error
handling in those.
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 :|
- Re: [Qemu-devel] [PATCH v1 12/21] io: implement socket watch for win32 using WSAEventSelect+select, (continued)
- [Qemu-devel] [PATCH v1 14/21] char: remove qemu_chr_finish_socket_connection method, Daniel P. Berrange, 2016/03/09
- [Qemu-devel] [PATCH v1 13/21] char: ensure listener socket is in blocking mode when waiting, Daniel P. Berrange, 2016/03/09
- [Qemu-devel] [PATCH v1 15/21] char: remove socket_try_connect method, Daniel P. Berrange, 2016/03/09
- [Qemu-devel] [PATCH v1 17/21] osdep: add wrappers for socket functions, Daniel P. Berrange, 2016/03/09
- [Qemu-devel] [PATCH v1 16/21] char: remove qemu_chr_open_socket_fd method, Daniel P. Berrange, 2016/03/09
- [Qemu-devel] [PATCH v1 19/21] osdep: remove use of socket_error() from all code, Daniel P. Berrange, 2016/03/09
- [Qemu-devel] [PATCH v1 18/21] osdep: remove use of Win32 specific closesocket/ioctlsocket, Daniel P. Berrange, 2016/03/09
- [Qemu-devel] [PATCH v1 20/21] osdep: remove direct use of qemu_socket & qemu_accept, Daniel P. Berrange, 2016/03/09
- [Qemu-devel] [PATCH v1 21/21] error: ensure errno detail is printed with error_abort, Daniel P. Berrange, 2016/03/09