Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E5457C43334 for ; Thu, 16 Jun 2022 16:16:06 +0000 (UTC) Received: from localhost ([::1]:41722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1sAA-0007q0-2N for qemu-devel@archiver.kernel.org; Thu, 16 Jun 2022 12:16:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1s1u-0000sg-CX for qemu-devel@nongnu.org; Thu, 16 Jun 2022 12:07:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60012) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1s1r-0007xW-Cl for qemu-devel@nongnu.org; Thu, 16 Jun 2022 12:07:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655395649; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=bgm+hPYLbuBRmvvYAE+dkR5eLB0vYZyD3B5tLR6Q28Q=; b=ED81n6ia4wZemayM/y5/7CtkbEjVOCU0DRVRMbQtPQpJ8rGt1VJfc64I817zm6MKS5cnCs raZW34uWA0v/y76XXQvaMiQijQTsDUYt52aKH5Wra8s5CHp/wyoReSIW6osEzg0lSUa7h5 KxBxpizjxGP/+GG4kJR8Vy84JqrXRbA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-205-IjoyBVpuMmubrVD0_QSzig-1; Thu, 16 Jun 2022 12:07:26 -0400 X-MC-Unique: IjoyBVpuMmubrVD0_QSzig-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C46FF398CA6B; Thu, 16 Jun 2022 16:07:25 +0000 (UTC) Received: from redhat.com (unknown [10.33.36.111]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E03B71415107; Thu, 16 Jun 2022 16:07:21 +0000 (UTC) Date: Thu, 16 Jun 2022 17:07:19 +0100 From: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= To: Steve Sistare Cc: qemu-devel@nongnu.org, Paolo Bonzini , Stefan Hajnoczi , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Alex =?utf-8?Q?Benn=C3=A9e?= , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , Juan Quintela , Markus Armbruster , Eric Blake , Jason Zeng , Zheng Chuan , Mark Kanda , Guoyi Tu , Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Igor Mammedov , David Hildenbrand , John Snow Subject: Re: [PATCH V8 13/39] oslib: qemu_clear_cloexec Message-ID: References: <1655304746-102776-1-git-send-email-steven.sistare@oracle.com> <1655304746-102776-14-git-send-email-steven.sistare@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1655304746-102776-14-git-send-email-steven.sistare@oracle.com> User-Agent: Mutt/2.2.1 (2022-02-19) X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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: , Reply-To: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Wed, Jun 15, 2022 at 07:52:00AM -0700, Steve Sistare wrote: > Define qemu_clear_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 b1c161c..e916f3b 100644 > --- a/include/qemu/osdep.h > +++ b/include/qemu/osdep.h > @@ -548,6 +548,7 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count) > G_GNUC_WARN_UNUSED_RESULT; > > void qemu_set_cloexec(int fd); > +void qemu_clear_cloexec(int fd); I'm a little wary of adding this helper without any accompanying comment. It is almost never correct to use this new method in a threaded program like QEMU, unless you have strong confidence that all the other threads are idle and not liable to perform a fork+exec for any other reason. IIUC, this can be satisfied by the CPR code because it will be used only immediately before exec'ing the updated QEMU binary, and it has suspended any other CPUs and not other monitor commands are concurrently running. IOW, I just ask that you put a comment with a big warning that essentially no one should use this method, except CPR code. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|