From nobody Thu Jan 9 22:32:05 2025 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653490737; cv=none; d=zohomail.com; s=zohoarc; b=JKhXsFHH3cI+YluA9fMsHL5XwK8NP0/h9dq/f8xHk6GZS7yFDz3fVjOPLG+Lg9VNhZl1928oN6buO87CcF+J8n/Yqwe2iE5vQl8eTojZhn9enRc1h1Be9hGvqZi9CP99vu1e89am0HFX97+6DL/cSNsa7r6d0UpGENj78CFQn00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653490737; 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=2txoi8kzLWAOR77xToALWlamClGyip6/Kibhx/lHuiE=; b=ImqnG86gj2xhrAPeNue2X4OIC1kGiIE7rkpfMSxvfH2MPbN3o1IPK7TUDyZvF3VK5REbX8dJACk7HxFzSoWvERBT6HR9ZXgSRDeQULlrhFMHjN7/HRESXhg62k9nQ0ak74QrthOplrDOsm469pWMCOHQe/OD+iieyFOINZxXlRg= 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+importer2=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 1653490737111467.3252740051331; Wed, 25 May 2022 07:58:57 -0700 (PDT) Received: from localhost ([::1]:59368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntsTQ-00028I-2g for importer2@patchew.org; Wed, 25 May 2022 10:58:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntsGn-0003Ex-Rb for qemu-devel@nongnu.org; Wed, 25 May 2022 10:45:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25323) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntsCz-00065X-8g for qemu-devel@nongnu.org; Wed, 25 May 2022 10:41:58 -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-346-XQhbvHz_PsGXPzv5R8tOZQ-1; Wed, 25 May 2022 10:41:55 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2EDB9811E7A for ; Wed, 25 May 2022 14:41:55 +0000 (UTC) Received: from localhost (unknown [10.39.192.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5718400F36; Wed, 25 May 2022 14:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653489716; 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=2txoi8kzLWAOR77xToALWlamClGyip6/Kibhx/lHuiE=; b=D+QObjo/TCb2c0pylIAUdkTfSskDPa1X8jcfuQl4r8Lwlp3V6jJHrFQ6xEVwCr2GE/ZJLM 5mzOfxu9HZTgdO+koiGCnqb+OYNjTX/0vfcGNSgtH8Ia+mdaCy7K607Ee3rSszuo9H2leP i1/usiXBUUqGjIIhyINL6Fn7o6zjfkM= X-MC-Unique: XQhbvHz_PsGXPzv5R8tOZQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v5 08/15] qga: replace qemu_open_old() with qga_open_cloexec() Date: Wed, 25 May 2022 16:41:33 +0200 Message-Id: <20220525144140.591926-9-marcandre.lureau@redhat.com> In-Reply-To: <20220525144140.591926-1-marcandre.lureau@redhat.com> References: <20220525144140.591926-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.10 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+importer2=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: -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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653490738947100003 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 --- 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 88ccbf2fdf..ff2d21d394 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