From nobody Tue May 13 11:59:57 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=1675414316; cv=none; d=zohomail.com; s=zohoarc; b=hHCJzICnkUK+irI5IgUjiLcVyN3+srp3JZWUsDvsju0N2rG+WJsn4X2Z36ZLbpCRhx1l80uKM/3KCyBAWwIVzBVf08guCy/IiEUDSZe44ujwOuvCPs9mw/dGi4Z2VF+ld9DupK2baYITDRkGHdR2Sr1zmvvcDzoE/8olBglM7/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675414316; 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=orXptK2B42fK7gOw25mpVx5CGtUb1E1ea5zMtLjqD10=; b=flNUPBob45W25JcT0epxCBdqehFXgZ5xOs3zXU6/hWTSClkdKM2qbm7+u/UpK/fxAW7PWke+JuJnY5xLuAYByCXIUKjg/oQJjYLxDJkIkv+wJVRYiKVgZCJ7wXk5QvjV1UJIRZz1O+DO+vGa/zzLqdbaEYkBl3RAvce9rbO/yOM= 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 1675414316507700.857498225795; Fri, 3 Feb 2023 00:51:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNriE-00005v-7b; Fri, 03 Feb 2023 03:46:26 -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 1pNrht-0008Mv-20 for qemu-devel@nongnu.org; Fri, 03 Feb 2023 03:46:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNrhl-0007UK-U3 for qemu-devel@nongnu.org; Fri, 03 Feb 2023 03:46:04 -0500 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-544-9yeWwwWePnyWQoZ2OCWYNg-1; Fri, 03 Feb 2023 03:45:52 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 753233C1016C; Fri, 3 Feb 2023 08:45:52 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 516CF40168BF; Fri, 3 Feb 2023 08:45:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BF2DE21E6A26; Fri, 3 Feb 2023 09:45:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675413956; 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=orXptK2B42fK7gOw25mpVx5CGtUb1E1ea5zMtLjqD10=; b=Tdgkkgpcp9OV0ralGkxshjwODvNeO/GYYxl3xWKqj4C3laqRxwxqOOqminh8EsiyaoakMJ HZeU8S44m5zxmnpk+RueK9z/quSRljBtff2wflbccAs9QKUjZX9yd0tM/uexEWU/nAJZoy /DiQ6P3xmVbzsHBTBJIbo1CEmK1Cp2U= X-MC-Unique: 9yeWwwWePnyWQoZ2OCWYNg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PULL 07/35] char: Factor out qmp_add_client() parts and move to chardev/ Date: Fri, 3 Feb 2023 09:45:21 +0100 Message-Id: <20230203084549.2622302-8-armbru@redhat.com> In-Reply-To: <20230203084549.2622302-1-armbru@redhat.com> References: <20230203084549.2622302-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675414317467100003 Content-Type: text/plain; charset="utf-8" Code moves from MAINTAINERS section "QMP" to "Character device backends". Signed-off-by: Markus Armbruster Message-Id: <20230124121946.1139465-5-armbru@redhat.com> --- include/monitor/qmp-helpers.h | 3 +++ chardev/char.c | 20 ++++++++++++++++++++ monitor/qmp-cmds.c | 13 ++----------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/include/monitor/qmp-helpers.h b/include/monitor/qmp-helpers.h index 4718c63c73..318c3357a2 100644 --- a/include/monitor/qmp-helpers.h +++ b/include/monitor/qmp-helpers.h @@ -22,5 +22,8 @@ bool qmp_add_client_vnc(int fd, bool has_skipauth, bool s= kipauth, bool qmp_add_client_dbus_display(int fd, bool has_skipauth, bool skipauth, bool has_tls, bool tls, Error **errp); #endif +bool qmp_add_client_char(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, const char *protocol, + Error **errp); =20 #endif diff --git a/chardev/char.c b/chardev/char.c index 87ab6efbcc..11eab7764c 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" #include "monitor/monitor.h" +#include "monitor/qmp-helpers.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "qemu/qemu-print.h" @@ -1166,6 +1167,25 @@ void qmp_chardev_send_break(const char *id, Error **= errp) qemu_chr_be_event(chr, CHR_EVENT_BREAK); } =20 +bool qmp_add_client_char(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, const char *protocol, + Error **errp) +{ + Chardev *s =3D qemu_chr_find(protocol); + + if (!s) { + error_setg(errp, "protocol '%s' is invalid", protocol); + close(fd); + return false; + } + if (qemu_chr_add_client(s, fd) < 0) { + error_setg(errp, "failed to add client"); + close(fd); + return false; + } + return true; +} + /* * Add a timeout callback for the chardev (in milliseconds), return * the GSource object created. Please use this to add timeout hook for diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 743849c0b5..e5ab77f6c6 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -17,7 +17,6 @@ #include "monitor/monitor.h" #include "monitor/qmp-helpers.h" #include "sysemu/sysemu.h" -#include "chardev/char.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h" #include "sysemu/runstate-action.h" @@ -174,7 +173,6 @@ void qmp_add_client(const char *protocol, const char *f= dname, { "@dbus-display", qmp_add_client_dbus_display }, #endif }; - Chardev *s; int fd, i; =20 fd =3D monitor_get_fd(monitor_cur(), fdname, errp); @@ -192,16 +190,9 @@ void qmp_add_client(const char *protocol, const char *= fdname, } } =20 - s =3D qemu_chr_find(protocol); - if (!s) { - error_setg(errp, "protocol '%s' is invalid", protocol); + if (!qmp_add_client_char(fd, has_skipauth, skipauth, has_tls, tls, + protocol, errp)) { close(fd); - return; - } - if (qemu_chr_add_client(s, fd) < 0) { - error_setg(errp, "failed to add client"); - close(fd); - return; } } =20 --=20 2.39.0