From nobody Tue Apr 21 14:38:13 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=163.com ARC-Seal: i=1; a=rsa-sha256; t=1776543874; cv=none; d=zohomail.com; s=zohoarc; b=CwlOgqVlCxvbdid1f1XQVJGj9+SflwM8We07lZfmJP0u/hP4guwq/H529WLgs7fWyd+FzDCa5+shRCoA+szzZ6Zs0bzyD/IPWPILrVSFOu81Yy2ynoTTmTjvf/KWQ0pvcQYUdvnYqGvL0wnYzn0qVF8uHIolwgqZYC98o3WfIm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776543874; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=S+1HLW44bNI9f/DBkTRy2j11jyEQ6a4jbbdW2UT62Bc=; b=SG/yflhnhmqMR30WbpKxPafOlr/qHPACJ2zJQlIHUn45LFPt6TsTFGMQ9EeEixXwoIIkbc1jM0MXpyh3SdOySYirFlJ0ZBAC4ORO651Z4o5VMzjxG81dK/EFLJ/Jy1qMOD5Y8e5atLiJw8dm7aM7GuRjKC6bwniDs4NjL9nkqoY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776543874251752.5118451273152; Sat, 18 Apr 2026 13:24:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wECCS-00018s-9I; Sat, 18 Apr 2026 16:23:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wE5tt-0008OU-Jn for qemu-devel@nongnu.org; Sat, 18 Apr 2026 09:39:58 -0400 Received: from m16.mail.163.com ([117.135.210.4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wE5tl-00015p-Sj for qemu-devel@nongnu.org; Sat, 18 Apr 2026 09:39:57 -0400 Received: from alano.. (unknown []) by gzga-smtp-mtada-g1-1 (Coremail) with SMTP id _____wAnbwyRieNpZgJ8AQ--.38013S2; Sat, 18 Apr 2026 21:39:29 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=S+ 1HLW44bNI9f/DBkTRy2j11jyEQ6a4jbbdW2UT62Bc=; b=ZngS70lRconlWRP7vF 5J95qJi/YBVpXD3gjR207brwPRu5Yb527LrX8bhbM0/580Q1pWNDiyvs1Aaoa0ed UJKkf8jERbzQjS1kKzCD1dJRDYwNxbpSN2k5UsNsVUajrLHllxbqZkTGVLElaYFf UtYbL5h7YgaUnoGsFY3yCUWbo= From: AlanoSong@163.com To: qemu-devel@nongnu.org Cc: dave@treblig.org, pbonzini@redhat.com, Alano Song Subject: [PATCH] monitor: Add `clear` command Date: Sat, 18 Apr 2026 21:39:27 +0800 Message-ID: <20260418133927.43012-1-AlanoSong@163.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wAnbwyRieNpZgJ8AQ--.38013S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7CFy8KFyfKrWUuw4rWr4xtFb_yoW8uryDpr s3trWrK3y8J3W3ur18Jr9xXF15CrZ7uFZFkFn8Z3s8AF98Jw1Iva1DKr1jk3ZxZrWxKFyS vFy2qrWDGa9Fqr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pR_9NcUUUUU= X-Originating-IP: [240e:36f:15d3:7310:8613:2c33:e4f6:6535] X-CM-SenderInfo: xdod00pvrqwqqrwthudrp/xtbC9RLZ7WnjiZJ71QAA3s 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=lists1p.gnu.org; Received-SPF: pass client-ip=117.135.210.4; envelope-from=alanosong@163.com; helo=m16.mail.163.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 18 Apr 2026 16:23:25 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @163.com) X-ZM-MESSAGEID: 1776543876584158500 Content-Type: text/plain; charset="utf-8" The monitor screen can be cluttered after executing commands like `info qtree`. It is useful to have a command to clear current screen, just like linux `clear` command do. This patch has been tested under monitors using stdio, vc, tcp socket, unix socket and serial interfaces. Signed-off-by: Alano Song --- hmp-commands.hx | 14 ++++++++++++++ include/monitor/hmp.h | 1 + monitor/hmp-cmds.c | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 5cc4788f12..95f9166732 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -20,6 +20,20 @@ SRST Show the help for all commands or just for command *cmd*. ERST =20 + { + .name =3D "clear", + .args_type =3D "", + .params =3D "", + .help =3D "clear the monitor screen", + .cmd =3D hmp_clear, + .flags =3D "p", + }, + +SRST +``clear`` + Clear the monitor screen. +ERST + { .name =3D "commit", .args_type =3D "device:B", diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index e222bea60c..9b66458d21 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -165,6 +165,7 @@ void hmp_trace_event(Monitor *mon, const QDict *qdict); void hmp_trace_file(Monitor *mon, const QDict *qdict); void hmp_info_trace_events(Monitor *mon, const QDict *qdict); void hmp_help(Monitor *mon, const QDict *qdict); +void hmp_clear(Monitor *mon, const QDict *qdict); void hmp_info_help(Monitor *mon, const QDict *qdict); void hmp_info_sync_profile(Monitor *mon, const QDict *qdict); void hmp_info_history(Monitor *mon, const QDict *qdict); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index bc26b39d70..3e9485478e 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -218,6 +218,11 @@ void hmp_help(Monitor *mon, const QDict *qdict) hmp_help_cmd(mon, qdict_get_try_str(qdict, "name")); } =20 +void hmp_clear(Monitor *mon, const QDict *qdict) +{ + monitor_printf(mon, "\x1b[3J\x1b[2J\x1b[H"); +} + void hmp_info_help(Monitor *mon, const QDict *qdict) { hmp_help_cmd(mon, "info"); --=20 2.43.0