From nobody Tue Feb 10 05:14:31 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=1653660379; cv=none; d=zohomail.com; s=zohoarc; b=CNADKNr789JzLhxS3ZERTXogim6SiqmFOACFua1qA/q1fpFhO6vLR+7qxrUT8xtncx3xVzGnbQdV25QNf2sX8Z+eRrdl8Y2374skBMFj/k1bRTPDFeFmUInwR7f7ba2Ux6lBcZ+teqAuC5C3kJow/k+bJI+aCbaDD0sKiiAP5Bk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653660379; 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=3pMrhehUASX5vta19nQ9AuSJLJ81Nu2JOoMvD0sI/6c=; b=KRy3BQqULduZsEDKpWZcxN5AnnbKdmedUMMHD/KcUd2577mrUOBWDrLOqcPY5mYtjFIVok1IbJriIIdRn8fr+9xY5oGbSPOvcDJMAdReC5FFVFmaU428uv70hr8pJjM5u+QxP238OcSNQQSK8CnExkNUHPhpNYsRAhT+KwWbu5Y= 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 1653660379809963.6209002392154; Fri, 27 May 2022 07:06:19 -0700 (PDT) Received: from localhost ([::1]:39348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuaba-0000OT-FJ for importer@patchew.org; Fri, 27 May 2022 10:06:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuaR4-00022S-Bh for qemu-devel@nongnu.org; Fri, 27 May 2022 09:55:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuaR2-0000aS-DA for qemu-devel@nongnu.org; Fri, 27 May 2022 09:55:26 -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-623-teUQvAKcO4WPPuSsnqPawg-1; Fri, 27 May 2022 09:55:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 40EB6101AA45; Fri, 27 May 2022 13:55:15 +0000 (UTC) Received: from localhost (unknown [10.39.192.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2D0D2026D64; Fri, 27 May 2022 13:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653659720; 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=3pMrhehUASX5vta19nQ9AuSJLJ81Nu2JOoMvD0sI/6c=; b=P16g/39KclBSNy3agxJHrMyYQ6vX6+vUocLO/5OM3tVUfN0xWBimnUFs6pV+RpfPe9WiiJ a+GR0U9/wDDEB7UmjGWON+v0dq15EsuzNWUbdQO9A98Dlv0JTpsDpx1bBG1XFiwYlBKSRs pykuwxMOQ5VH/KUag1jugEJijm8uNw4= X-MC-Unique: teUQvAKcO4WPPuSsnqPawg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, Michael Roth , peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 08/15] qga: replace qemu_open_old() with qga_open_cloexec() Date: Fri, 27 May 2022 15:54:52 +0200 Message-Id: <20220527135459.117877-9-marcandre.lureau@redhat.com> In-Reply-To: <20220527135459.117877-1-marcandre.lureau@redhat.com> References: <20220527135459.117877-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.78 on 10.11.54.4 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.129.124; envelope-from=marcandre.lureau@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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653660380336100001 From: Marc-Andr=C3=A9 Lureau qemu_open_old() uses qemu_open_internal() which handles special "/dev/fdset/" path for monitor fd sets, set CLOEXEC, and uses Error reporting (and some O_DIRECT special error casing). The monitor fdset handling is unnecessary for qga, use qga_open_cloexec() instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk Message-Id: <20220525144140.591926-9-marcandre.lureau@redhat.com> --- qga/channel-posix.c | 13 +++++++++---- qga/commands-posix.c | 8 ++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 25fcc5cb1a..6796a02cff 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -1,8 +1,10 @@ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include #include "qapi/error.h" #include "qemu/sockets.h" #include "channel.h" +#include "cutils.h" =20 #ifdef CONFIG_SOLARIS #include @@ -127,11 +129,14 @@ static gboolean ga_channel_open(GAChannel *c, const g= char *path, switch (c->method) { case GA_CHANNEL_VIRTIO_SERIAL: { assert(fd < 0); - fd =3D qemu_open_old(path, O_RDWR | O_NONBLOCK + fd =3D qga_open_cloexec( + path, #ifndef CONFIG_SOLARIS - | O_ASYNC + O_ASYNC | #endif - ); + O_RDWR | O_NONBLOCK, + 0 + ); if (fd =3D=3D -1) { error_setg_errno(errp, errno, "error opening channel"); return false; @@ -156,7 +161,7 @@ static gboolean ga_channel_open(GAChannel *c, const gch= ar *path, struct termios tio; =20 assert(fd < 0); - fd =3D qemu_open_old(path, O_RDWR | O_NOCTTY | O_NONBLOCK); + fd =3D qga_open_cloexec(path, O_RDWR | O_NOCTTY | O_NONBLOCK, 0); if (fd =3D=3D -1) { error_setg_errno(errp, errno, "error opening channel"); return false; diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 2ecc43eca9..0047245273 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1406,7 +1406,7 @@ static void get_nvme_smart(GuestDiskInfo *disk) | (((sizeof(log) >> 2) - 1) << 16) }; =20 - fd =3D qemu_open_old(disk->name, O_RDONLY); + fd =3D qga_open_cloexec(disk->name, O_RDONLY, 0); if (fd =3D=3D -1) { g_debug("Failed to open device: %s: %s", disk->name, g_strerror(er= rno)); return; @@ -1739,7 +1739,7 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mount= points, } } =20 - fd =3D qemu_open_old(mount->dirname, O_RDONLY); + fd =3D qga_open_cloexec(mount->dirname, O_RDONLY, 0); if (fd =3D=3D -1) { error_setg_errno(errp, errno, "failed to open %s", mount->dirn= ame); goto error; @@ -1806,7 +1806,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **errp) =20 QTAILQ_FOREACH(mount, &mounts, next) { logged =3D false; - fd =3D qemu_open_old(mount->dirname, O_RDONLY); + fd =3D qga_open_cloexec(mount->dirname, O_RDONLY, 0); if (fd =3D=3D -1) { continue; } @@ -1892,7 +1892,7 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, E= rror **errp) =20 QAPI_LIST_PREPEND(response->paths, result); =20 - fd =3D qemu_open_old(mount->dirname, O_RDONLY); + fd =3D qga_open_cloexec(mount->dirname, O_RDONLY, 0); if (fd =3D=3D -1) { result->error =3D g_strdup_printf("failed to open: %s", strerror(errno)); --=20 2.36.1