Message ID | 20190307142822.8531-2-philmd@redhat.com |
---|---|
State | New |
Headers | show |
Series | OpenBSD: Let QEMU 4.0 be usable from OpenBSD 6.0 and onwards | expand |
diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 37c5854b9c..326d92dcd2 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -244,7 +244,19 @@ void qemu_set_nonblock(int fd) f = fcntl(fd, F_GETFL); assert(f != -1); f = fcntl(fd, F_SETFL, f | O_NONBLOCK); +#ifdef __OpenBSD__ + if (f == -1) { + /* + * Previous to OpenBSD 6.3, fcntl(F_SETFL) is not permitted on + * memory devices and sets errno to ENODEV. + * It's OK if we fail to set O_NONBLOCK on devices like /dev/null, + * because they will never block anyway. + */ + assert(errno == ENODEV); + } +#else assert(f != -1); +#endif } int socket_set_fast_reuse(int fd)