From nobody Sun Sep 28 15:25:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1758797519; cv=none; d=zohomail.com; s=zohoarc; b=F8StVdKTwxCgyCpxFaaz7Zwn4LHu7onP6s6xmXJebuuGwBlZlx7FBHnP5K8l62oXBI8m4CIQTAv030oISdeUOzGrMZK57bZ4WEz54i3bwcY8/e4/PhcQp6McWlNLys8HQ8Ye8Isiyg3ettci7hZ188TKX2n1FmoO0Vh8UrLIFnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758797519; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=vW6Zcy8SEi94ilhlXlW2XDXvc9roCnjBwhekfmMa7Ms=; b=Xo8lil26wv2B7h7fIzEkFt4f0zTIuo8uXrqWccJSnfzZHaDRycQFYNcIJCaWyQHGK+rgQQEPVk9ucFgGzCLd24GhSwbCRtv8UDvCcGVe0MSILqjyUNidMeqpY2de7sDSwvWfBm7nqQ/MXbggrW+BwgEUAKbfZBDJQiHbElHZ3a8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1758797519534333.0149551395449; Thu, 25 Sep 2025 03:51:59 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id A27FC41882; Thu, 25 Sep 2025 06:51:58 -0400 (EDT) Received: from [172.19.199.14] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id F2829443AC; Thu, 25 Sep 2025 05:49:54 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 5565E43F59; Thu, 25 Sep 2025 05:48:32 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0369B43ECC for ; Thu, 25 Sep 2025 05:46:16 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-270-T6SAToMtM8K9tF8vIO7RwA-1; Thu, 25 Sep 2025 05:46:12 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2234C18002C4; Thu, 25 Sep 2025 09:46:11 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.163]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F21B9300021A; Thu, 25 Sep 2025 09:46:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758793576; 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=vW6Zcy8SEi94ilhlXlW2XDXvc9roCnjBwhekfmMa7Ms=; b=AGWTtLwYjg43yPbrHtCYV/z5ZAapD0odfoS3oFdQ+AqzCaX2z2UUG+GhNie7wCB9gkzgB/ SWuDoLM79w7pTwBQQ4Xv/zyHEf9kiLOI46vpUf95yJ7JnO6Tpc5FGG1R7wJuWvDe6IcB7R qYrT82g1o70KPZpOoQ1PkiA5uGslhHY= X-MC-Unique: T6SAToMtM8K9tF8vIO7RwA-1 X-Mimecast-MFC-AGG-ID: T6SAToMtM8K9tF8vIO7RwA_1758793571 To: qemu-devel@nongnu.org Subject: [PATCH v4 14/23] monitor: introduce monitor_cur_is_hmp() helper Date: Thu, 25 Sep 2025 10:44:32 +0100 Message-ID: <20250925094441.1651372-15-berrange@redhat.com> In-Reply-To: <20250925094441.1651372-1-berrange@redhat.com> References: <20250925094441.1651372-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Message-ID-Hash: V5YBGJU7IL4NMJOECKMKQBBI253PEKZ3 X-Message-ID-Hash: V5YBGJU7IL4NMJOECKMKQBBI253PEKZ3 X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Hanna Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Kevin Wolf , qemu-rust@nongnu.org, Richard Henderson , Markus Armbruster , Christian Schoenebeck , qemu-block@nongnu.org, Stefan Weil , "Dr. David Alan Gilbert" , Manos Pitsidianakis , Gerd Hoffmann , devel@lists.libvirt.org, Paolo Bonzini X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9_via_Devel?= Reply-To: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1758797520435116600 Note that this is not simply the inverse of monitor_cur_is_qmp(), as both helpers require that monitor_cur() is first non-NULL. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Richard Henderson --- include/monitor/monitor.h | 1 + monitor/monitor.c | 10 ++++++++++ stubs/monitor-core.c | 6 ++++++ tests/unit/test-util-sockets.c | 1 + 4 files changed, 18 insertions(+) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 296690e1f1..9c71e6cf3c 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -16,6 +16,7 @@ extern QemuOptsList qemu_mon_opts; Monitor *monitor_cur(void); Monitor *monitor_set_cur(Coroutine *co, Monitor *mon); bool monitor_cur_is_qmp(void); +bool monitor_cur_is_hmp(void); =20 void monitor_init_globals(void); void monitor_init_globals_core(void); diff --git a/monitor/monitor.c b/monitor/monitor.c index e1e5dbfcbe..27be5d7c73 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -116,6 +116,16 @@ bool monitor_cur_is_qmp(void) return cur_mon && monitor_is_qmp(cur_mon); } =20 +/** + * Is the current monitor, if any, a HMP monitor? + */ +bool monitor_cur_is_hmp(void) +{ + Monitor *cur_mon =3D monitor_cur(); + + return cur_mon && !monitor_is_qmp(cur_mon); +} + /** * Is @mon is using readline? * Note: not all HMP monitors use readline, e.g., gdbserver has a diff --git a/stubs/monitor-core.c b/stubs/monitor-core.c index a7c32297c9..674211f48f 100644 --- a/stubs/monitor-core.c +++ b/stubs/monitor-core.c @@ -7,6 +7,12 @@ Monitor *monitor_cur(void) return NULL; } =20 +bool monitor_cur_is_hmp(void) +{ + /* since monitor_cur() above returns NULL, this can't be true */ + return false; +} + Monitor *monitor_set_cur(Coroutine *co, Monitor *mon) { return NULL; diff --git a/tests/unit/test-util-sockets.c b/tests/unit/test-util-sockets.c index ee66d727c3..4b7f408902 100644 --- a/tests/unit/test-util-sockets.c +++ b/tests/unit/test-util-sockets.c @@ -74,6 +74,7 @@ int monitor_get_fd(Monitor *mon, const char *fdname, Erro= r **errp) Monitor *monitor_cur(void) { return cur_mon; } Monitor *monitor_set_cur(Coroutine *co, Monitor *mon) { abort(); } int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { abort(); } +bool monitor_cur_is_hmp(void) { return false; } =20 #ifndef _WIN32 static void test_socket_fd_pass_name_good(void) --=20 2.50.1