From nobody Tue Feb 10 20:48:10 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651685593; cv=none; d=zohomail.com; s=zohoarc; b=AL/4NHxDG3i+Xe3T62XsfJtETW/yTjU+zx4b/XcMSFUHb4GSKMYFG3GXm2fl4BUJuHURivpsM9oCqND5kswcr8HuzxBU0+2H4yC08C5PNB33+kyCP9RJIHtxYbB1r2ZCS3xQT5wYBWVZtSobtkciImCWALRWA2d4AZu+ZrkV4aI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651685593; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KlsHIrWV+HO7aeZTRbvh+8pSkcJ71kOwRP1Qu6+MR7M=; b=T+WKVo+CZSRCGB2JM1Rt7jMCcWj4hIMX1Lx9s61FUUXcxuwnGSjZF/RBf8Orusn/6YOmmsD0I8j+njEe1aaJBkE2VnB6/95B6WEW5gM5fvJ57cUJMQqA5NxuAiAoIyBoJ8+4LqEBgAlMaO1p4LLhEuNcPkCe62AUDuFAqCbHw1Y= 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=pass 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 1651685593546213.52734453646576; Wed, 4 May 2022 10:33:13 -0700 (PDT) Received: from localhost ([::1]:43292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmIsC-0001gE-Gh for importer@patchew.org; Wed, 04 May 2022 13:33:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmIqn-0007E0-7k for qemu-devel@nongnu.org; Wed, 04 May 2022 13:31:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42418) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmIql-0003nR-J5 for qemu-devel@nongnu.org; Wed, 04 May 2022 13:31:44 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-376-Ddscnnk6Nw2-9O4u3TzSMA-1; Wed, 04 May 2022 13:31:39 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A9698811E76; Wed, 4 May 2022 17:31:38 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2C2C4643CE; Wed, 4 May 2022 17:31:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651685502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KlsHIrWV+HO7aeZTRbvh+8pSkcJ71kOwRP1Qu6+MR7M=; b=FXzspmYFX7nNoN1uNSgJyFA8NISFMw/YdDibXdM31BDzn4C2uyjbjstyX4nijLqY0krwZ+ JJc4Ys456/lZSYYMTRFPRJjRGD2WPO6bp6C6zxc+j6LNqya+lwgkYjWb9G2Bc6O29GjYAF aB1ZzoEB/mDFCFXetfQ3fRVM8udpAPY= X-MC-Unique: Ddscnnk6Nw2-9O4u3TzSMA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Stefan Weil , Qiuhao Li , Laurent Vivier , Stefan Hajnoczi , Hanna Reitz , Kevin Wolf , Markus Armbruster , qemu-block@nongnu.org, Konstantin Kostiuk , Bandan Das , Michael Roth , Darren Kenny , Alexander Bulekov , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 08/16] osdep: export qemu_open_cloexec() Date: Wed, 4 May 2022 21:30:17 +0400 Message-Id: <20220504173025.650167-9-marcandre.lureau@redhat.com> In-Reply-To: <20220504173025.650167-1-marcandre.lureau@redhat.com> References: <20220504173025.650167-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651685594739100001 From: Marc-Andr=C3=A9 Lureau Used in the next patch, to simplify qga code. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qemu/osdep.h | 1 + util/osdep.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 67cc4654166b..64f51cfb7a62 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -489,6 +489,7 @@ void sigaction_invoke(struct sigaction *action, */ int qemu_open_old(const char *name, int flags, ...); int qemu_open(const char *name, int flags, Error **errp); +int qemu_open_cloexec(const char *name, int flags, mode_t mode, Error **er= rp); int qemu_create(const char *name, int flags, mode_t mode, Error **errp); int qemu_close(int fd); int qemu_unlink(const char *name); diff --git a/util/osdep.c b/util/osdep.c index 60fcbbaebe72..67541b7654ef 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -279,9 +279,11 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t l= en, bool exclusive) } #endif =20 -static int qemu_open_cloexec(const char *name, int flags, mode_t mode) +int qemu_open_cloexec(const char *name, int flags, mode_t mode, Error **er= rp) { + ERRP_GUARD(); int ret; + #ifdef O_CLOEXEC ret =3D open(name, flags | O_CLOEXEC, mode); #else @@ -290,6 +292,10 @@ static int qemu_open_cloexec(const char *name, int fla= gs, mode_t mode) qemu_set_cloexec(ret); } #endif + if (ret =3D=3D -1) { + error_setg_errno(errp, errno, "Could not open '%s'", name); + } + return ret; } =20 @@ -327,7 +333,7 @@ qemu_open_internal(const char *name, int flags, mode_t = mode, Error **errp) } #endif =20 - ret =3D qemu_open_cloexec(name, flags, mode); + ret =3D qemu_open_cloexec(name, flags, mode, NULL); =20 if (ret =3D=3D -1) { const char *action =3D flags & O_CREAT ? "create" : "open"; --=20 2.36.0.44.g0f828332d5ac