[libvirt] [PATCH] virsh: fix mingw failure on creating nonblocking pipe

* .gnulib: Update to latest, for nonblocking module. * bootstrap.conf (gnulib_modules): Add nonblocking. * src/util/util.c (virSetBlocking): Defer to gnulib. --- Matthias, does this work for you on your mingw build? So far, I have only tested that it cross-compiles, and that the new gnulib module passes its self-test when run in isolation on mingw. .gnulib | 2 +- bootstrap.conf | 1 + src/util/util.c | 22 ++-------------------- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/.gnulib b/.gnulib index 790645d..dec3475 160000 --- a/.gnulib +++ b/.gnulib @@ -1 +1 @@ -Subproject commit 790645d837f8084991421107fba639b110d58335 +Subproject commit dec3475763be252103922a887920012eeb32dc26 diff --git a/bootstrap.conf b/bootstrap.conf index 733c354..ca0c3de 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -49,6 +49,7 @@ mkstemp mkstemps mktempd netdb +nonblocking perror physmem pipe-posix diff --git a/src/util/util.c b/src/util/util.c index 035036b..e54b02b 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -77,6 +77,7 @@ #include "verify.h" #include "files.h" #include "command.h" +#include "nonblocking.h" #ifndef NSIG # define NSIG 32 @@ -246,26 +247,7 @@ virArgvToString(const char *const *argv) } int virSetBlocking(int fd, bool blocking) { -#ifndef WIN32 - int flags; - if ((flags = fcntl(fd, F_GETFL)) < 0) - return -1; - if (blocking) - flags &= ~O_NONBLOCK; - else - flags |= O_NONBLOCK; - if ((fcntl(fd, F_SETFL, flags)) < 0) - return -1; -#else - unsigned long flag = blocking ? 0 : 1; - - /* This is actually Gnulib's replacement rpl_ioctl function. - * We can't call ioctlsocket directly in any case. - */ - if (ioctl (fd, FIONBIO, (void *) &flag) == -1) - return -1; -#endif - return 0; + return set_nonblocking_flag (fd, blocking); } int virSetNonBlock(int fd) { -- 1.7.4

On 03/31/2011 04:03 PM, Eric Blake wrote:
* .gnulib: Update to latest, for nonblocking module. * bootstrap.conf (gnulib_modules): Add nonblocking. * src/util/util.c (virSetBlocking): Defer to gnulib. ---
Matthias, does this work for you on your mingw build? So far, I have only tested that it cross-compiles, and that the new gnulib module passes its self-test when run in isolation on mingw.
int virSetBlocking(int fd, bool blocking) {
- if (blocking) - flags &= ~O_NONBLOCK;
+ return set_nonblocking_flag (fd, blocking);
Oops - that _can't_ work. s/blocking/!blocking/ in that return statement. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Thu, Mar 31, 2011 at 04:12:09PM -0600, Eric Blake wrote:
On 03/31/2011 04:03 PM, Eric Blake wrote:
* .gnulib: Update to latest, for nonblocking module. * bootstrap.conf (gnulib_modules): Add nonblocking. * src/util/util.c (virSetBlocking): Defer to gnulib. ---
Matthias, does this work for you on your mingw build? So far, I have only tested that it cross-compiles, and that the new gnulib module passes its self-test when run in isolation on mingw.
int virSetBlocking(int fd, bool blocking) {
- if (blocking) - flags &= ~O_NONBLOCK;
+ return set_nonblocking_flag (fd, blocking);
Oops - that _can't_ work. s/blocking/!blocking/ in that return statement.
ACK with that fix :-) 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 :|

On 04/01/2011 03:44 AM, Daniel P. Berrange wrote:
On Thu, Mar 31, 2011 at 04:12:09PM -0600, Eric Blake wrote:
On 03/31/2011 04:03 PM, Eric Blake wrote:
* .gnulib: Update to latest, for nonblocking module. * bootstrap.conf (gnulib_modules): Add nonblocking. * src/util/util.c (virSetBlocking): Defer to gnulib. ---
Matthias, does this work for you on your mingw build? So far, I have only tested that it cross-compiles, and that the new gnulib module passes its self-test when run in isolation on mingw.
int virSetBlocking(int fd, bool blocking) {
- if (blocking) - flags &= ~O_NONBLOCK;
+ return set_nonblocking_flag (fd, blocking);
Oops - that _can't_ work. s/blocking/!blocking/ in that return statement.
ACK with that fix :-)
I ran a sanity check that the corrected version could still start and stop qemu guests on Linux, then pushed the corrected version. For the record, the gnulib patches include: * .gnulib 790645d...dec3475 (5):
nonblocking: fix mingw test failures Fix bug with gl_WARN_ON_USE_PREPARE, introduced on 2011-01-23. nonblocking: Tweak comment. nonblocking: new module Fix recent ChangeLog entries.
-- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Daniel P. Berrange
-
Eric Blake