From nobody Sun Nov 9 22:57:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552118419531960.6294622429051; Sat, 9 Mar 2019 00:00:19 -0800 (PST) Received: from localhost ([127.0.0.1]:55400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Wtz-0004hG-Gb for importer@patchew.org; Sat, 09 Mar 2019 03:00:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Wik-0003wK-9a for qemu-devel@nongnu.org; Sat, 09 Mar 2019 02:48:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Wij-0000af-Bn for qemu-devel@nongnu.org; Sat, 09 Mar 2019 02:48:38 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:41598) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2Wij-0000Zs-4e for qemu-devel@nongnu.org; Sat, 09 Mar 2019 02:48:37 -0500 Received: by mail-wr1-x433.google.com with SMTP id n2so23650011wrw.8 for ; Fri, 08 Mar 2019 23:48:37 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id 11sm5252294wmg.27.2019.03.08.23.48.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 23:48:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iD7mIAMgyrJupzYWncjcIj7c+SmiAknzmsni0tOtG/c=; b=SBK6HBTU4bpGnUPvXmK1wZpMiGGxgyEKKv22OrO9r34bT3LSu4B6cpZqiKnIli+Ehv GuVfLYNV6osIoi2NEsitg5OhqmNm3jmtHla35E9wLquRnMiA/RLWPXndaZvYOF76lXZt 4k3ePf9NIEbs9XV9SC5IPnxcUCvu65sSMDOockpLryvteDGNvKBxNUoyd7xpKuppe+o4 Jza1gfWWbWyuQYv8bySRXvVPx3sAxMcgYmsnOlW/ga6ooevu7FseTD34Jz0z7jES08zQ enBepV3LEJRMzHB18MfFzYmUp9pX7NQyHZC8V+Z4sYYZh8cyDvZk/EioBEVnz0JfXlZI pmeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=iD7mIAMgyrJupzYWncjcIj7c+SmiAknzmsni0tOtG/c=; b=jY3OZUol2q5Bq/3b1aXrgIDFh64/+zGs9+C6Ji/idPJta19ziL1uOE4rgTBoFcz3tD 1b6Bku4ycagfDHzP+Ze2ExrFCyxmWminLuxb+nZoC4IXa2d0JFEXPffYGV7kIFOYC+nM c+4nxxW2AymyGjNwsyrW8P1BBj052j29oAsgGG2yFCEGa0jeQ8Gx5MR4uOzh4/mUasCN DGz87OsoNrG0cKgcyW5HDpcIiB8++FhWOBgV8KoPyb644RrkbWW4IBsXioi4IPIXXx5L HjnCE5rocnkB7saz6OmS+gswwPb2CKHp+47bj1Puv63ji3WDkwijwho1XE10uIe2DxFu sAKQ== X-Gm-Message-State: APjAAAXTDjI9kL1N4CMQ1oPbBOphkQC++QiAJYfeaAY6FGejJaOYvFmu 9netfOYwnJl5NNJh7WTmIs/9zsDi X-Google-Smtp-Source: APXvYqw100GfeDHm4KbkHPy4/x4Gy9BgDMT1S7KgytDW33LY8RybC4gCuesRE7HLzsBonpEM7mGZ8Q== X-Received: by 2002:adf:dfca:: with SMTP id q10mr13962412wrn.45.1552117715831; Fri, 08 Mar 2019 23:48:35 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 9 Mar 2019 08:48:10 +0100 Message-Id: <1552117698-12355-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1552117698-12355-1-git-send-email-pbonzini@redhat.com> References: <1552117698-12355-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 Subject: [Qemu-devel] [PULL 17/25] oslib-posix: Ignore fcntl("/dev/null", F_SETFL, O_NONBLOCK) failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 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 !=3D -1" failed: file "util/oslib-posix.c", line 247, functi= on "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 Reviewed-by: Michael S. Tsirkin Signed-off-by: Philippe Mathieu-Daud=C3=83=C2=A9 Message-Id: <20190307142822.8531-2-philmd@redhat.com> Signed-off-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D fcntl(fd, F_GETFL); assert(f !=3D -1); f =3D fcntl(fd, F_SETFL, f | O_NONBLOCK); +#ifdef __OpenBSD__ + if (f =3D=3D -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 =3D=3D ENODEV); + } +#else assert(f !=3D -1); +#endif } =20 int socket_set_fast_reuse(int fd) --=20 1.8.3.1