[{"id":3682281,"web_url":"http://patchwork.ozlabs.org/comment/3682281/","msgid":"<aezBuTRxnq90ClOg@gallifrey>","list_archive_url":null,"date":"2026-04-25T13:29:29","subject":"Re: [PATCH v2 1/1] monitor: Add `clear` command","submitter":{"id":86099,"url":"http://patchwork.ozlabs.org/api/people/86099/","name":"Dr. David Alan Gilbert","email":"dave@treblig.org"},"content":"* AlanoSong@163.com (AlanoSong@163.com) wrote:\n> The monitor screen can be cluttered after executing commands\n> like `info qtree`. It is useful to have a command to clear\n> current screen, just like linux `clear` command do.\n> \n> This patch has been tested under monitors using stdio, vc,\n> tcp socket, unix socket and serial interfaces.\n> \n> Signed-off-by: Alano Song <AlanoSong@163.com>\n\nThanks for fixing that.\n\n\nReviewed-by: Dr. David Alan Gilbert <dave@treblig.org>\n\n> ---\n>  hmp-commands.hx       | 14 ++++++++++++++\n>  include/monitor/hmp.h |  1 +\n>  monitor/hmp-cmds.c    | 11 +++++++++++\n>  3 files changed, 26 insertions(+)\n> \n> diff --git a/hmp-commands.hx b/hmp-commands.hx\n> index 5cc4788f12..95f9166732 100644\n> --- a/hmp-commands.hx\n> +++ b/hmp-commands.hx\n> @@ -20,6 +20,20 @@ SRST\n>    Show the help for all commands or just for command *cmd*.\n>  ERST\n>  \n> +    {\n> +        .name       = \"clear\",\n> +        .args_type  = \"\",\n> +        .params     = \"\",\n> +        .help       = \"clear the monitor screen\",\n> +        .cmd        = hmp_clear,\n> +        .flags      = \"p\",\n> +    },\n> +\n> +SRST\n> +``clear``\n> +  Clear the monitor screen.\n> +ERST\n> +\n>      {\n>          .name       = \"commit\",\n>          .args_type  = \"device:B\",\n> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h\n> index e222bea60c..9b66458d21 100644\n> --- a/include/monitor/hmp.h\n> +++ b/include/monitor/hmp.h\n> @@ -165,6 +165,7 @@ void hmp_trace_event(Monitor *mon, const QDict *qdict);\n>  void hmp_trace_file(Monitor *mon, const QDict *qdict);\n>  void hmp_info_trace_events(Monitor *mon, const QDict *qdict);\n>  void hmp_help(Monitor *mon, const QDict *qdict);\n> +void hmp_clear(Monitor *mon, const QDict *qdict);\n>  void hmp_info_help(Monitor *mon, const QDict *qdict);\n>  void hmp_info_sync_profile(Monitor *mon, const QDict *qdict);\n>  void hmp_info_history(Monitor *mon, const QDict *qdict);\n> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c\n> index bc26b39d70..608a208c6e 100644\n> --- a/monitor/hmp-cmds.c\n> +++ b/monitor/hmp-cmds.c\n> @@ -218,6 +218,17 @@ void hmp_help(Monitor *mon, const QDict *qdict)\n>      hmp_help_cmd(mon, qdict_get_try_str(qdict, \"name\"));\n>  }\n>  \n> +void hmp_clear(Monitor *mon, const QDict *qdict)\n> +{\n> +    /*\n> +     * Send an ANSI escape sequence:\n> +     * \"\\x1b[H\" - move cursor to top-left\n> +     * \"\\x1b[2J\" - clear visible screen\n> +     * \"\\x1b[3J\" - clear scrollback\n> +     */\n> +    monitor_printf(mon, \"\\x1b[H\\x1b[2J\\x1b[3J\");\n> +}\n> +\n>  void hmp_info_help(Monitor *mon, const QDict *qdict)\n>  {\n>      hmp_help_cmd(mon, \"info\");\n> -- \n> 2.43.0\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=treblig.org header.i=@treblig.org header.a=rsa-sha256\n header.s=bytemarkmx header.b=hL9lyOd8;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g2rLM0pZsz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 25 Apr 2026 23:30:33 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wGd4s-0006JP-H8; Sat, 25 Apr 2026 09:29:46 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <dg@treblig.org>) id 1wGd4j-0006J9-LK\n for qemu-devel@nongnu.org; Sat, 25 Apr 2026 09:29:39 -0400","from mx.treblig.org ([2a00:1098:5b::1])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <dg@treblig.org>) id 1wGd4h-0003lT-QA\n for qemu-devel@nongnu.org; Sat, 25 Apr 2026 09:29:37 -0400","from dg by mx.treblig.org with local (Exim 4.98.2)\n (envelope-from <dg@treblig.org>) id 1wGd4b-0000000AiUt-3ziF;\n Sat, 25 Apr 2026 13:29:29 +0000"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=treblig.org\n ; s=bytemarkmx;\n h=Content-Type:MIME-Version:Message-ID:Subject:From:Date:From\n :Subject; bh=pbB/29eORXBUy7oT1d4HmyVaXCPX+4ZkEIWYyYq8G8Q=; b=hL9lyOd8w1jSpAhE\n ypzW2yqM7+mNhL8gd2W9fy8aPQmbVySS6ITFoJNTut2bScbIdFRR9yaGjrcWgduwUcePRoQvPfv/c\n NaVtbIwHLtIFfXuR/lB8D2k4rwnHJdnhYd2klFjhG5tgXx4ohMw+dPYVqqgrUHekojEbrxRDgPAYG\n c8smsUbutOoiaFaRhr5PiePhL8iS7hW4saMEJPrxlXxn9MBd2sYeGXxlM7YxM9BY+sdfXroaekIs/\n xh6ySeNUM/M8W9hhBORYB8iY5swd/dd5IEPy2Gn8Eo6bK998cXMlXt66Bops+6WfNoZVl4sdpZaX0\n 6DgT9LjSeNlqmpppBg==;","Date":"Sat, 25 Apr 2026 13:29:29 +0000","From":"\"Dr. David Alan Gilbert\" <dave@treblig.org>","To":"AlanoSong@163.com","Cc":"qemu-devel@nongnu.org, pbonzini@redhat.com","Subject":"Re: [PATCH v2 1/1] monitor: Add `clear` command","Message-ID":"<aezBuTRxnq90ClOg@gallifrey>","References":"<20260425125113.37341-1-AlanoSong@163.com>\n <20260425125113.37341-2-AlanoSong@163.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","In-Reply-To":"<20260425125113.37341-2-AlanoSong@163.com>","X-Chocolate":"70 percent or better cocoa solids preferably","X-Operating-System":"Linux/6.12.74+deb13+1-amd64 (x86_64)","X-Uptime":"13:29:19 up 43 days, 14:42,  2 users,  load average: 0.02, 0.02,\n 0.00","User-Agent":"Mutt/2.2.13 (2024-03-09)","Received-SPF":"pass client-ip=2a00:1098:5b::1; envelope-from=dg@treblig.org;\n helo=mx.treblig.org","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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,\n 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":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"}}]