From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20270C07E96 for ; Thu, 8 Jul 2021 14:00:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73E6D61451 for ; Thu, 8 Jul 2021 14:00:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73E6D61451 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1UZQ-0000vt-A0 for qemu-devel@archiver.kernel.org; Thu, 08 Jul 2021 10:00:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1UYA-0008UF-KH for qemu-devel@nongnu.org; Thu, 08 Jul 2021 09:58:49 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]:33415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m1UY4-0006XT-2u for qemu-devel@nongnu.org; Thu, 08 Jul 2021 09:58:46 -0400 Received: by mail-ej1-x632.google.com with SMTP id bu12so9870779ejb.0 for ; Thu, 08 Jul 2021 06:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2p9o/LX1RsV0JGVGoUNq4L4r84vauhZdn01KvOQrA3k=; b=XUeCLT8kZwaeiAUSYLd4aBRuhTgEruEQSp6nQbT8asxkLaNsNC5XzuIxD1sYFpDnJW svPESCow+d0CK8ZXN73gfk4UUl7mUvgexC1FzqgOUd+wWlkbtg8n3MhBOJpziCacWnKS 2sVjIrXSUZJzHLeLjYURaUG5ZhqEesP/17XDsVf2/bGH1qWA6no9y/zg43a35jP33TAm ldjn5AiyWMMQ5/9qQi/6wHv9q8Uv+wB1FVI422I7N0nEtvQ6pN/D2kv1BplMK1RCYf1d UNwLz/1VgFnvrc2BQ9yal3byC+rf5ZqyvEd0Cv8V9el/p+ciqbwa9Kn77BRnjPCdg0pn 3Wlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2p9o/LX1RsV0JGVGoUNq4L4r84vauhZdn01KvOQrA3k=; b=b7eUuzJiX30yntR8UEjdiGi1jlL+lWegk23TQ6CzF6qfU16mzfvmNBKKN9uesFeVfY gaEzvMqxpYvltg3GKSPZ54Al6BGtAyxPuz81gMsHsHqVgw00Nu97fN75hHRZ1KGcO1iM ohtApztdICK+oeYH3My1OjaPgRp6sKMY7dieyqslo7l3Mb99ijSIgKYMP0/EJdLXNmc+ OivZcXhajKOmpYy6IZ1X7+vgw7e3I7TJozTVePkNx+3THV1HgezOx9Ul8mswF7FsVczM XCnnjORcgffYBEBtmuLLb6Jf+ObLEp2CTwmRbZbpt5JW7fQnpuFrKz5bNi5D/+ZgMTyS loOA== X-Gm-Message-State: AOAM533pO3oW/FkFXd4P1Dlysdekp+ON5Ez1fcAvnQ19g5XaBRJDZriU DeKgqMjiwOffgqd86sckFqQTP95FA/GFZYMO6po= X-Google-Smtp-Source: ABdhPJw1EBX0ZWtliPT8f5SWcNX3efE1/X0hzqN6ciTH5OVlVLTx8mRt33zI7hLf3ZueLUGzYT8JeLf+445L80sP6T8= X-Received: by 2002:a17:906:39c3:: with SMTP id i3mr30933744eje.527.1625752717949; Thu, 08 Jul 2021 06:58:37 -0700 (PDT) MIME-Version: 1.0 References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> <1625678434-240960-7-git-send-email-steven.sistare@oracle.com> In-Reply-To: <1625678434-240960-7-git-send-email-steven.sistare@oracle.com> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Thu, 8 Jul 2021 17:58:26 +0400 Message-ID: Subject: Re: [PATCH V5 06/25] oslib: qemu_clr_cloexec To: Steve Sistare Content-Type: multipart/alternative; boundary="0000000000003efeed05c69d0d5d" Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=marcandre.lureau@gmail.com; helo=mail-ej1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, 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-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Zeng , Juan Quintela , Eric Blake , "Michael S. Tsirkin" , QEMU , "Dr. David Alan Gilbert" , Alex Williamson , Stefan Hajnoczi , Paolo Bonzini , "Daniel P. Berrange" , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , =?UTF-8?B?QWxleCBCZW5uw6ll?= , Markus Armbruster Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --0000000000003efeed05c69d0d5d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi On Wed, Jul 7, 2021 at 9:33 PM Steve Sistare wrote: > Define qemu_clr_cloexec, analogous to qemu_set_cloexec. > > Reviewed-by: Dr. David Alan Gilbert > Signed-off-by: Steve Sistare > --- > include/qemu/osdep.h | 1 + > util/oslib-posix.c | 9 +++++++++ > util/oslib-win32.c | 4 ++++ > 3 files changed, 14 insertions(+) > > diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h > index c91a78b..3d6a6ca 100644 > --- a/include/qemu/osdep.h > +++ b/include/qemu/osdep.h > @@ -637,6 +637,7 @@ static inline void qemu_timersub(const struct timeval > *val1, > #endif > > void qemu_set_cloexec(int fd); > +void qemu_clr_cloexec(int fd); > I wish we would have a single function to set or unset, tbh. (as _clr_ isn't as readable to me) /* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default > * instead of QEMU_VERSION, so setting hw_version on MachineClass > diff --git a/util/oslib-posix.c b/util/oslib-posix.c > index e8bdb02..97577f1 100644 > --- a/util/oslib-posix.c > +++ b/util/oslib-posix.c > @@ -309,6 +309,15 @@ void qemu_set_cloexec(int fd) > assert(f !=3D -1); > } > > +void qemu_clr_cloexec(int fd) > +{ > + int f; > + f =3D fcntl(fd, F_GETFD); > + assert(f !=3D -1); > + f =3D fcntl(fd, F_SETFD, f & ~FD_CLOEXEC); > + assert(f !=3D -1); > +} > (asserting() may not be very judicious for calls that we intend to make during running time, but that's the way it is so far) + > /* > * Creates a pipe with FD_CLOEXEC set on both file descriptors > */ > diff --git a/util/oslib-win32.c b/util/oslib-win32.c > index af559ef..46e94d9 100644 > --- a/util/oslib-win32.c > +++ b/util/oslib-win32.c > @@ -265,6 +265,10 @@ void qemu_set_cloexec(int fd) > { > } > > +void qemu_clr_cloexec(int fd) > +{ > +} > + > /* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */ > #define _W32_FT_OFFSET (116444736000000000ULL) > > -- > 1.8.3.1 > > > --=20 Marc-Andr=C3=A9 Lureau --0000000000003efeed05c69d0d5d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

On Wed, Jul 7, 2021 at 9:33 PM Stev= e Sistare <steven.sistare@o= racle.com> wrote:
Define qemu_clr_cloexec, analogous to qemu_set_cloexec.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
=C2=A0include/qemu/osdep.h | 1 +
=C2=A0util/oslib-posix.c=C2=A0 =C2=A0| 9 +++++++++
=C2=A0util/oslib-win32.c=C2=A0 =C2=A0| 4 ++++
=C2=A03 files changed, 14 insertions(+)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index c91a78b..3d6a6ca 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -637,6 +637,7 @@ static inline void qemu_timersub(const struct timeval *= val1,
=C2=A0#endif

=C2=A0void qemu_set_cloexec(int fd);
+void qemu_clr_cloexec(int fd);

I wish = we would have a single function to set or unset, tbh. (as _clr_ isn't a= s readable to me)

=C2=A0/* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" b= y default
=C2=A0 * instead of QEMU_VERSION, so setting hw_version on MachineClass
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index e8bdb02..97577f1 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -309,6 +309,15 @@ void qemu_set_cloexec(int fd)
=C2=A0 =C2=A0 =C2=A0assert(f !=3D -1);
=C2=A0}

+void qemu_clr_cloexec(int fd)
+{
+=C2=A0 =C2=A0 int f;
+=C2=A0 =C2=A0 f =3D fcntl(fd, F_GETFD);
+=C2=A0 =C2=A0 assert(f !=3D -1);
+=C2=A0 =C2=A0 f =3D fcntl(fd, F_SETFD, f & ~FD_CLOEXEC);
+=C2=A0 =C2=A0 assert(f !=3D -1);
+}

(asserting() may not be very judicio= us for calls that we intend to make during running time, but that's the= way it is so far)

+
=C2=A0/*
=C2=A0 * Creates a pipe with FD_CLOEXEC set on both file descriptors
=C2=A0 */
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index af559ef..46e94d9 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -265,6 +265,10 @@ void qemu_set_cloexec(int fd)
=C2=A0{
=C2=A0}

+void qemu_clr_cloexec(int fd)
+{
+}
+
=C2=A0/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
=C2=A0#define _W32_FT_OFFSET (116444736000000000ULL)

--
1.8.3.1




--
Marc-Andr=C3=A9 Lureau
--0000000000003efeed05c69d0d5d--