From nobody Sat May 18 07:48:52 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1675796612; cv=none; d=zohomail.com; s=zohoarc; b=aCPsPJnbj3oII/CjPUt+PP+MIkbPO7NvQYE3eoA9dxIqZLVhE4aQyFfw26Y9r507dckIDy6HbRRrZ0EZMaa9z4AcPUpKHXDcAJWbAICmFVu3EYcZ9JWnIe+W6lJp4QCblSmdKnOWsGFiFVK1VeS+jkPKm67IjdfvSDz048YYdcs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675796612; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=kjBjnDqSkYVbHcwSwp8V4xHT4+l3M7hain+6n1dCOPQ=; b=ByIKLsK84snf39+B0tFgcTAA/arp2BRtT9O/RgVmOcFgOV8RYWwf7yHXFK2Vm6u7iF1UuqRj0TJPAl8wh6CoWT6CITgAmtdv/NpkO8UK7NoVqAvdQQulIrSm6SHWaQwaUcpWG8BgNb6Gv+lc+vLB4BEZKogSQzVcM/USYQhOq5g= 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 1675796612817790.4651286357931; Tue, 7 Feb 2023 11:03:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPTFQ-0006pR-6c; Tue, 07 Feb 2023 14:03:20 -0500 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 1pPTFL-0006fd-NZ for qemu-devel@nongnu.org; Tue, 07 Feb 2023 14:03:16 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPTFK-0003l5-02 for qemu-devel@nongnu.org; Tue, 07 Feb 2023 14:03:15 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 317Ix2W6002206; Tue, 7 Feb 2023 19:03:12 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhdy16ea1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Feb 2023 19:03:12 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 317HvcqQ012355; Tue, 7 Feb 2023 19:03:10 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdtckyu2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Feb 2023 19:03:10 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 317J3A6x007752; Tue, 7 Feb 2023 19:03:10 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3nhdtckyt0-1; Tue, 07 Feb 2023 19:03:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=corp-2022-7-12; bh=kjBjnDqSkYVbHcwSwp8V4xHT4+l3M7hain+6n1dCOPQ=; b=O86oskV3Z1joEdRE/rrjJKXy5GyXnwJecInwxyqDhNeHimr+OyBrm9KOyPNE6HB3JYId zvPG8O0m1hGMbEzKDOP0BK+o/8mCQivoX+pE4x/6DDj53165OMlZvfCycyQbARj1lIw0 AiVeU3GAW2tbY8br0Q1Fw6Shp54/oyuqx/azbe4a8HhHI9ADyRM5FfDYtl2Orqe181Gp VMEFdPI7k9J4k0SUu9K2lmcqqvtw6eVtQcap4RIfbsr/rQ+2G/ESuMOi2gQ1mSam+6Jz R+u0ge2euGgQu3IxaDKc87cf5arb4vvVBAcURrd7US1/nsBEET9WMRP/bTF7BTK6h4Tj Kw== From: Steve Sistare To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" , "Daniel P. Berrange" , Paolo Bonzini , Steve Sistare Subject: [PATCH V2] oslib: qemu_clear_cloexec Date: Tue, 7 Feb 2023 11:03:08 -0800 Message-Id: <1675796588-235506-1-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-07_11,2023-02-06_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302070170 X-Proofpoint-GUID: 7wV5yC6xNzRDnRmQBJ1Bmi0d9EgDqdrd X-Proofpoint-ORIG-GUID: 7wV5yC6xNzRDnRmQBJ1Bmi0d9EgDqdrd 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=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.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 @oracle.com) X-ZM-MESSAGEID: 1675796614611100003 Define qemu_clear_cloexec, analogous to qemu_set_cloexec. This will be used to preserve selected descriptors during cpr. Signed-off-by: Steve Sistare Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/qemu/osdep.h | 9 +++++++++ util/oslib-posix.c | 9 +++++++++ util/oslib-win32.c | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 88c9fac..9c8c536 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -618,6 +618,15 @@ ssize_t qemu_write_full(int fd, const void *buf, size_= t count) =20 void qemu_set_cloexec(int fd); =20 +/* + * Clear FD_CLOEXEC for a descriptor. + * + * The caller must guarantee that no other fork+exec's occur before the + * exec that is intended to inherit this descriptor, eg by suspending CPUs + * and blocking monitor commands. + */ +void qemu_clear_cloexec(int fd); + /* Return a dynamically allocated directory path that is appropriate for s= toring * local state. * diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 59a891b..a8cc3d0 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -273,6 +273,15 @@ int qemu_socketpair(int domain, int type, int protocol= , int sv[2]) return ret; } =20 +void qemu_clear_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); +} + char * qemu_get_local_state_dir(void) { diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 07ade41..756bee3 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -222,6 +222,10 @@ void qemu_set_cloexec(int fd) { } =20 +void qemu_clear_cloexec(int fd) +{ +} + int qemu_get_thread_id(void) { return GetCurrentThreadId(); --=20 1.8.3.1