[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 19/31] oslib-posix: Ignore fcntl("/dev/null", F_SE
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL v2 19/31] oslib-posix: Ignore fcntl("/dev/null", F_SETFL, O_NONBLOCK) failure |
Date: |
Mon, 11 Mar 2019 17:55:23 +0100 |
From: Philippe Mathieu-Daudé <address@hidden>
Previous to OpenBSD 6.3 [1], fcntl(F_SETFL) is not permitted on
memory devices.
Trying this call sets errno to ENODEV ("not a memory device"):
19 ENODEV Operation not supported by device.
An attempt was made to apply an inappropriate function to a device,
for example, trying to read a write-only device such as a printer.
Do not assert fcntl failures in this specific case (errno set to ENODEV)
on OpenBSD. This fixes:
$ lm32-softmmu/qemu-system-lm32
assertion "f != -1" failed: file "util/oslib-posix.c", line 247, function
"qemu_set_nonblock"
Abort trap (core dumped)
[1] The fix seems https://github.com/openbsd/src/commit/c2a35b387f9d3c
"fcntl(F_SETFL) invokes the FIONBIO and FIOASYNC ioctls internally, so
the memory devices (/dev/null, /dev/zero, etc) need to permit them."
Reviewed-by: Peter Maydell <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
util/oslib-posix.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 37c5854..326d92d 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)
--
1.8.3.1
- [Qemu-devel] [PULL v2 08/31] configure: Enable werror for git worktrees, (continued)
- [Qemu-devel] [PULL v2 08/31] configure: Enable werror for git worktrees, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 10/31] i386: extended the cpuid_level when Intel PT is enabled, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 11/31] virtio-scsi: Fix build with gcc 9, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 15/31] build: get rid of target-obj-y, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 12/31] lsi: implement basic SBCL functionality, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 09/31] target-i386: add kvm stubs to user-mode emulators, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 13/31] lsi: check if SIGP bit is already set in Wait reselect, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 14/31] update copyright notice, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 16/31] build: remove unnecessary assignments from Makefile.target, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 17/31] build: clean trace/generated-helpers.c, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 19/31] oslib-posix: Ignore fcntl("/dev/null", F_SETFL, O_NONBLOCK) failure,
Paolo Bonzini <=
- [Qemu-devel] [PULL v2 18/31] accel: Allow to build QEMU without TCG or KVM support, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 21/31] scsi-disk: Fix crash if request is invaild or disk is no medium, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 22/31] lsi: use ldn_le_p()/stn_le_p(), Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 25/31] lsi: use SCSI phase names instead of numbers in trace, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 20/31] configure: Disable W^X on OpenBSD, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 23/31] lsi: use enum type for s->waiting, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 24/31] lsi: use enum type for s->msg_action, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 26/31] lsi: return dfifo value, Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 28/31] exec.c: refactor function flatview_add_to_dispatch(), Paolo Bonzini, 2019/03/11
- [Qemu-devel] [PULL v2 31/31] qemugdb: fix licensing, Paolo Bonzini, 2019/03/11