From nobody Sun Nov 24 13:33:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.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=linbit.com ARC-Seal: i=1; a=rsa-sha256; t=1722433551; cv=none; d=zohomail.com; s=zohoarc; b=l+DWji0Sj88XGRD9bSaawQvK3HWmva1vV/07x0bVsGrucyHFeaouOh3cybPkOj7qDc1dq7IpT3hxt/OMRANuSW/Sxw4lKLWUgYPwC46rhDyz0UKPsGfHndq+RYwqDxxWcHwtb/EqMe2RPv5g2K7fo+SNhL/YsluBa892ltPr7Xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722433551; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dxALnPUmyRoYA7morwgIVajtl32kZIWfqqOlhO4AnjU=; b=NE/ygDenUbIdJH1mvfx7O9BKTFuq9B6rkv1YD0glO2egVIK2+hH98uLtRPBNNTC+qnl5ZSsoBjP0Ih4K0LrbE445JnzOpQWNY9bnxIHlbnRWjbTywXxxAoKTtvomncLweqTC0CmCg0ocgSyYY09GAoMeIAifVcqsLiAkTEyYLj8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722433551437766.3672256666991; Wed, 31 Jul 2024 06:45:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ9dk-0000YC-02; Wed, 31 Jul 2024 09:45:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZ9Ks-0002m5-7n for qemu-devel@nongnu.org; Wed, 31 Jul 2024 09:25:46 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZ9Kp-00057w-HZ for qemu-devel@nongnu.org; Wed, 31 Jul 2024 09:25:45 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a7a9a7af0d0so750202466b.3 for ; Wed, 31 Jul 2024 06:25:42 -0700 (PDT) Received: from ryzen9.home (193-80-247-151.adsl.highway.telekom.at. [193.80.247.151]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad4aaa3sm772603866b.138.2024.07.31.06.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 06:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linbit-com.20230601.gappssmtp.com; s=20230601; t=1722432341; x=1723037141; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dxALnPUmyRoYA7morwgIVajtl32kZIWfqqOlhO4AnjU=; b=wZ9Xe6eYmS+ygi4B1BPD/lGJoSri2rgONANkNFy0hExzjtWngVXAY57XAheYcwHD9v BAelyCjfmqP91klwy6lsA40SeAcPC4F32bUozJJJ8o/ZHyn8+McNgZo7fcedoJRwLNM/ PASi+OM+OY7s/RWfNpT1wL17+b5c3AshufIKQNnhrTQHb4bcsLGoU8Sm1wYBUkx9cdPl W0fB6iRwJc2E/JWp31MAtN52yhkn3WUPuzN73Jp5Ivrfcc8oTkWvcOPux+vJZYMhr+Q3 nWoejpl5jpNjqyyQ+k6seldxKzpRpcOfZ3KHEIwrDvBO2SRVT/VD51NmDcncb9PPEOaz oskg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722432341; x=1723037141; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dxALnPUmyRoYA7morwgIVajtl32kZIWfqqOlhO4AnjU=; b=YAdVlU5MkeL/c8Up83WT/e6I64D1ltW8Z+/4kkueoapyJXRperX4Rrx57zCBpYccJ9 7HeRD4w5zJJyCTWyc6i48Sul9Bcno+qurOpGLD5rC7TJ18kka2VmDCnVra+Z4RKl+ySE d0NWJzUzUDxNaKEOPQeRX+lJqw2wpMLHlcldxxjCQyTT+acrJkjwOFfruLuForDgQFGo GXyVjy8Hr/FUfZi4vyoswsgsf8g8Vtw7waGhy6yIRXSTvO5bD+7XI+2czi1zNv9+xmH8 p5j4dH0idihvTMqeYe+LBlltYks/sHExH0enrtwqvUpEL9p562/CuEstv7emduWNhhxZ PWrw== X-Gm-Message-State: AOJu0YzYnTdmWZC/uj2iH5EU130EVG+UoA2GXer5czz8KsvCAI3qo91F IXNDrWushvLyh6FxfrzkthHsNmlZUPl1zCm/5qN+G7KJRdYs1iV3eqni9pKDvt4TWUPBn8T0TsO X X-Google-Smtp-Source: AGHT+IF9wofbJ3/NgqqRuSMYl/jlVE/7xRp+MUHKtRVKoBPdC39XL3cBiO/2e9Rhc2q3iMJtuMsW1g== X-Received: by 2002:a17:907:86a2:b0:a7a:d093:f843 with SMTP id a640c23a62f3a-a7d401605afmr953963566b.63.1722432340910; Wed, 31 Jul 2024 06:25:40 -0700 (PDT) From: Philipp Reisner To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , Paolo Bonzini , David Hildenbrand , Philipp Reisner Subject: [PATCH] util: retry open() when it gets interrupted by a signal Date: Wed, 31 Jul 2024 15:25:24 +0200 Message-ID: <20240731132524.308273-1-philipp.reisner@linbit.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=philipp.reisner@linbit.com; helo=mail-ej1-x634.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 31 Jul 2024 09:45:07 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linbit-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722433552530116600 Content-Type: text/plain; charset="utf-8" As with many syscalls, open() might be interrupted by a signal. The experienced logfile entry is: qemu-system-x86_64: -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x7,drive=3Dl= ibvirt-2-format,id=3Dvirtio-disk0,bootindex=3D2,write-cache=3Don,serial=3D1= b990c4d13b74a4e90ea: Could not open '/dev/drbd1003': Interrupted system call Retry it until it is not interrupted by a signal. FYI, dd has the same kind of loop aroud open(). https://github.com/coreutils/coreutils/blob/1ae98dbda7322427e8226356fd110d2= 553f5fac9/src/dd.c#L1294-L1299 Signed-off-by: Philipp Reisner Reviewed-by: David Hildenbrand --- util/osdep.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/util/osdep.c b/util/osdep.c index 770369831b..a1269d9345 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -294,14 +294,17 @@ bool qemu_has_direct_io(void) static int qemu_open_cloexec(const char *name, int flags, mode_t mode) { int ret; + do { #ifdef O_CLOEXEC - ret =3D open(name, flags | O_CLOEXEC, mode); + ret =3D open(name, flags | O_CLOEXEC, mode); #else - ret =3D open(name, flags, mode); - if (ret >=3D 0) { - qemu_set_cloexec(ret); - } + ret =3D open(name, flags, mode); + if (ret >=3D 0) { + qemu_set_cloexec(ret); + } #endif + } while (ret =3D=3D -1 && errno =3D=3D EINTR); + return ret; } =20 --=20 2.45.2