[{"id":3679065,"web_url":"http://patchwork.ozlabs.org/comment/3679065/","msgid":"<10f96e1a-dcd9-49f4-aff2-1549f88e50a4@redhat.com>","list_archive_url":null,"date":"2026-04-19T08:43:05","subject":"Re: [PATCH] monitor: Add `clear` command","submitter":{"id":2701,"url":"http://patchwork.ozlabs.org/api/people/2701/","name":"Paolo Bonzini","email":"pbonzini@redhat.com"},"content":"On 4/18/26 19:23, Dr. David Alan Gilbert wrote:\n> * 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> \n> Does typing ctrl-l not do it for you in your terminal?\n\nYeah, we should add support for Ctrl-L to the non-terminal backends \nindependent of this.  However, backends such as socket do not use \nreadline so they also don't support it right now.\n\nPaolo\n\n> Dave\n> \n>> ---\n>>   hmp-commands.hx       | 14 ++++++++++++++\n>>   include/monitor/hmp.h |  1 +\n>>   monitor/hmp-cmds.c    |  5 +++++\n>>   3 files changed, 20 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..3e9485478e 100644\n>> --- a/monitor/hmp-cmds.c\n>> +++ b/monitor/hmp-cmds.c\n>> @@ -218,6 +218,11 @@ 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>> +    monitor_printf(mon, \"\\x1b[3J\\x1b[2J\\x1b[H\");\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 (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=H2zx6f5G;\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 4fz2GR51bDz1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 19 Apr 2026 18:43:58 +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 1wENkN-0001t5-Ib; Sun, 19 Apr 2026 04:43:19 -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 <pbonzini@redhat.com>)\n id 1wENkM-0001ss-04\n for qemu-devel@nongnu.org; Sun, 19 Apr 2026 04:43:18 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <pbonzini@redhat.com>)\n id 1wENkJ-000653-Qx\n for qemu-devel@nongnu.org; Sun, 19 Apr 2026 04:43:17 -0400","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-Ijxla7aaPj6iLmEV4XQnCQ-1; Sun,\n 19 Apr 2026 04:43:11 -0400","from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id BE963195608F; Sun, 19 Apr 2026 08:43:09 +0000 (UTC)","from [10.44.32.46] (unknown [10.44.32.46])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 92DB21801481; Sun, 19 Apr 2026 08:43:08 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776588192;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references:autocrypt:autocrypt;\n bh=qESMAqD1fY4qO7RbNG5Yb1Mbj+Ze/k8hXFw0imkmHcg=;\n b=H2zx6f5GFqcJMKaqrrKyrjCp1ycfCyl1bDzaUXWNVJxSmt9SKXktYS3Lpmp6aZwCKLaYXP\n RgNCDBqrEc1FU0LFZy5dFrCCUTbHxGz5Kh8FeKVJPwPJEs1rx8AeIJ22uLE/EYqgIE7AL3\n pJgVkHSnyAZ2PAd7QhEN4ZkNccoNcXs=","X-MC-Unique":"Ijxla7aaPj6iLmEV4XQnCQ-1","X-Mimecast-MFC-AGG-ID":"Ijxla7aaPj6iLmEV4XQnCQ_1776588190","Message-ID":"<10f96e1a-dcd9-49f4-aff2-1549f88e50a4@redhat.com>","Date":"Sun, 19 Apr 2026 09:43:05 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] monitor: Add `clear` command","To":"\"Dr. David Alan Gilbert\" <dave@treblig.org>, AlanoSong@163.com","Cc":"qemu-devel@nongnu.org","References":"<20260418133927.43012-1-AlanoSong@163.com>\n <aeO-IqKqBwtKfW8P@gallifrey>","From":"Paolo Bonzini <pbonzini@redhat.com>","Content-Language":"en-US","Autocrypt":"addr=pbonzini@redhat.com; keydata=\n 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","In-Reply-To":"<aeO-IqKqBwtKfW8P@gallifrey>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.93","Received-SPF":"pass client-ip=170.10.133.124;\n envelope-from=pbonzini@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-25","X-Spam_score":"-2.6","X-Spam_bar":"--","X-Spam_report":"(-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n SPF_HELO_PASS=-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":"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"}},{"id":3679078,"web_url":"http://patchwork.ozlabs.org/comment/3679078/","msgid":"<142c6c8b.11e3.19da4b172c4.Coremail.alanosong@163.com>","list_archive_url":null,"date":"2026-04-19T07:43:05","subject":"Re:Re: [PATCH] monitor: Add `clear` command","submitter":{"id":92155,"url":"http://patchwork.ozlabs.org/api/people/92155/","name":"Alano Song","email":"AlanoSong@163.com"},"content":"At 2026-04-19 01:23:46, \"Dr. David Alan Gilbert\" <dave@treblig.org> wrote:\n>* 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>\n>Does typing ctrl-l not do it for you in your terminal?\n>\n>Dave\n>\n\n\nYes, you are correct that ctrl-l provides basic screen clear,\nbut the new `clear` command clears both visible screen and\nscrollback buffer, just like `clear` command does on my Ubuntu terminal.\n\nI still believe that this patch is useful:\n1) Many linux users like me instinctively type `clear`\nwhen we want to tidy up the terminal.\n2) Not everyone is aware of or remembers the ctrl-l shortcut.\n   A typed command is more discoverable, especially for new users\n   or those who don't use terminal shortcuts regularly.\n\n\n>> ---\n>>  hmp-commands.hx       | 14 ++++++++++++++\n>>  include/monitor/hmp.h |  1 +\n>>  monitor/hmp-cmds.c    |  5 +++++\n>>  3 files changed, 20 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..3e9485478e 100644\n>> --- a/monitor/hmp-cmds.c\n>> +++ b/monitor/hmp-cmds.c\n>> @@ -218,6 +218,11 @@ 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>> +    monitor_printf(mon, \"\\x1b[3J\\x1b[2J\\x1b[H\");\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>> \n>-- \n> -----Open up your eyes, open up your mind, open up your code -------   \n>/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \\ \n>\\        dave @ treblig.org |                               | In Hex /\n> \\ _________________________|_____ http://www.treblig.org   |_______/","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 (1024-bit key;\n unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256\n header.s=s110527 header.b=nPS4LYO6;\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 4fz6WT2f1wz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 19 Apr 2026 21:55:31 +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 1wEQjl-0006bD-6c; Sun, 19 Apr 2026 07:54:53 -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 <alanosong@163.com>) id 1wEMoY-0001NK-Ft\n for qemu-devel@nongnu.org; Sun, 19 Apr 2026 03:43:35 -0400","from m16.mail.163.com ([117.135.210.2])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <alanosong@163.com>) id 1wEMoR-0000Ht-IE\n for qemu-devel@nongnu.org; Sun, 19 Apr 2026 03:43:34 -0400","from alanosong$163.com ( [240e:36f:15d3:7310:a0f7:6910:3839:955c]\n ) by ajax-webmail-wmsvr-40-131 (Coremail) ; Sun, 19 Apr 2026 15:43:05 +0800\n (CST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com;\n s=s110527; h=Date:From:To:Subject:Content-Type:MIME-Version:\n Message-ID; bh=Zvf9BfO2ErqP8tzNi8W/JsxtCxXdl6NBQd7Ak/jCYW0=; b=n\n PS4LYO6BPdCbjR9JrF93HAZNR/WLbnIbcp83weLFf75hQNXzDcV0ufCFFd+Jxv25\n bE7E67k7a7hZY52MNTVRvys9MEx0ZibGKteQ8a5lWL3bVNPKetRm2ig/WASgDoy1\n xWxxKlJ2ddXzgXtmoUDGbIpvkZ2OZ3UHq8/Oy61f8c=","X-Originating-IP":"[240e:36f:15d3:7310:a0f7:6910:3839:955c]","Date":"Sun, 19 Apr 2026 15:43:05 +0800 (CST)","From":"\"Alano Song\" <alanosong@163.com>","To":"\"Dr. David Alan Gilbert\" <dave@treblig.org>","Cc":"qemu-devel@nongnu.org, pbonzini@redhat.com","Subject":"Re:Re: [PATCH] monitor: Add `clear` command","X-Priority":"3","X-Mailer":"Coremail Webmail Server Version 2023.4-cmXT build\n 20260403(27802f6d) Copyright (c) 2002-2026 www.mailtech.cn 163com","In-Reply-To":"<aeO-IqKqBwtKfW8P@gallifrey>","References":"<20260418133927.43012-1-AlanoSong@163.com>\n <aeO-IqKqBwtKfW8P@gallifrey>","X-NTES-SC":"\n AL_Qu2cBPmTu00j4ymZZukcm0wQgOk5XsCwu/wk3YNec84FnjDB9hg4XFlsOXDN7P+tEC2JkwmeQAZ19sJFR6BHleV95QaRh0mL5K4/gAlBoA==","Content-Type":"multipart/alternative;\n boundary=\"----=_Part_18610_214560068.1776584585924\"","MIME-Version":"1.0","Message-ID":"<142c6c8b.11e3.19da4b172c4.Coremail.alanosong@163.com>","X-Coremail-Locale":"zh_CN","X-CM-TRANSID":"gygvCgD3n5WKh+Rp1tmRAA--.7017W","X-CM-SenderInfo":"xdod00pvrqwqqrwthudrp/xtbC1AqXq2nkh4r7XQAA3E","X-Coremail-Antispam":"1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU==","Received-SPF":"pass client-ip=117.135.210.2; envelope-from=alanosong@163.com;\n 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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n HTML_MESSAGE=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,\n RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-Mailman-Approved-At":"Sun, 19 Apr 2026 07:54:51 -0400","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"}},{"id":3679407,"web_url":"http://patchwork.ozlabs.org/comment/3679407/","msgid":"<3ece3e66.74c.19dab1a68c9.Coremail.alanosong@163.com>","list_archive_url":null,"date":"2026-04-20T13:35:27","subject":"Re: [PATCH] monitor: Add `clear` command","submitter":{"id":92155,"url":"http://patchwork.ozlabs.org/api/people/92155/","name":"Alano Song","email":"AlanoSong@163.com"},"content":"At 2026-04-19 01:23:46, \"Dr. David Alan Gilbert\" <dave@treblig.org> wrote:\n>* 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>\n>Does typing ctrl-l not do it for you in your terminal?\n>\n>Dave\n>\n\n\nYes, you are correct that ctrl-l provides basic screen clear,\nbut the new `clear` command clears both visible screen and\nscrollback buffer, just like `clear` command does on my Ubuntu terminal.\n\nI still believe that this patch is useful:\n1) Many linux users like me instinctively type `clear`,\nwhen we want to tidy up the terminal.\n2) Not everyone is aware of or remembers the ctrl-l shortcut.\n   A typed command is more discoverable, especially for new users\n   or those who don't use terminal shortcuts regularly.\n\nBest Regards,\nAlano.\n\n// Re-send, it seems that the previous reply email is not visible in the mail list.\n\n\n>> ---\n>>  hmp-commands.hx       | 14 ++++++++++++++\n>>  include/monitor/hmp.h |  1 +\n>>  monitor/hmp-cmds.c    |  5 +++++\n>>  3 files changed, 20 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..3e9485478e 100644\n>> --- a/monitor/hmp-cmds.c\n>> +++ b/monitor/hmp-cmds.c\n>> @@ -218,6 +218,11 @@ 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>> +    monitor_printf(mon, \"\\x1b[3J\\x1b[2J\\x1b[H\");\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>> \n>-- \n> -----Open up your eyes, open up your mind, open up your code -------   \n>/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \\ \n>\\        dave @ treblig.org |                               | In Hex /\n> \\ _________________________|_____ http://www.treblig.org   |_______/","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 (1024-bit key;\n unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256\n header.s=s110527 header.b=iF3bnPlW;\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 4fzmj717Tnz1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 20 Apr 2026 23:36:11 +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 1wEon1-0006Mx-L5; Mon, 20 Apr 2026 09:35:51 -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 <alanosong@163.com>) id 1wEomz-0006MW-D6\n for qemu-devel@nongnu.org; Mon, 20 Apr 2026 09:35:49 -0400","from m16.mail.163.com ([220.197.31.2])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <alanosong@163.com>) id 1wEomu-0001WM-Cw\n for qemu-devel@nongnu.org; Mon, 20 Apr 2026 09:35:49 -0400","from alanosong$163.com ( [171.83.94.98] ) by\n ajax-webmail-wmsvr-40-108 (Coremail) ; Mon, 20 Apr 2026 21:35:27 +0800\n (CST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com;\n s=s110527; h=Date:From:To:Subject:Content-Type:MIME-Version:\n Message-ID; bh=jvAVN2T0gPShfyu+VqGyG5sfZxfqR1vhQ9wgxQIAvfg=; b=i\n F3bnPlWMqpO1rVJFmRUcnuVnq3PQkm18sGsUSLRI/8gfe1Nv4hTqtXMGQ/RZX0B4\n 8XNt10bRIObXKGqXRaVsCO+0QudUVDahplK0O74J10VZWFdXQQ7P5BRwt4jED13K\n E0/pCs6xe5C+zjesc4vs5IyA/R0gftAEOJWJ+GfFEU=","X-Originating-IP":"[171.83.94.98]","Date":"Mon, 20 Apr 2026 21:35:27 +0800 (CST)","From":"\"Alano Song\" <alanosong@163.com>","To":"\"Dr. David Alan Gilbert\" <dave@treblig.org>","Cc":"qemu-devel@nongnu.org, pbonzini@redhat.com","Subject":"Re: [PATCH] monitor: Add `clear` command","X-Priority":"3","X-Mailer":"Coremail Webmail Server Version 2023.4-cmXT build\n 20260403(27802f6d) Copyright (c) 2002-2026 www.mailtech.cn 163com","In-Reply-To":"<aeO-IqKqBwtKfW8P@gallifrey>","References":"<20260418133927.43012-1-AlanoSong@163.com>\n <aeO-IqKqBwtKfW8P@gallifrey>","X-NTES-SC":"\n AL_Qu2cBPqSvUkp4SmbZOkcm0wQgOk5XsCwu/wk3YNec+MEijzd3DgnV3NnFlHc9vuvEyqqjh6+QCFs599dQo5XoSTTqO4BCwfxuX4XlwpC+A==","Content-Type":"multipart/alternative;\n boundary=\"----=_Part_7204_575024813.1776692127944\"","MIME-Version":"1.0","Message-ID":"<3ece3e66.74c.19dab1a68c9.Coremail.alanosong@163.com>","X-Coremail-Locale":"zh_CN","X-CM-TRANSID":"bCgvCgDHjGugK+ZpRKiSAA--.4412W","X-CM-SenderInfo":"xdod00pvrqwqqrwthudrp/xtbC0wAHG2nmK6AlNQAA3b","X-Coremail-Antispam":"1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU==","Received-SPF":"pass client-ip=220.197.31.2; envelope-from=alanosong@163.com;\n 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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001,\n RCVD_IN_MSPIKE_WL=0.001, 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"}},{"id":3680001,"web_url":"http://patchwork.ozlabs.org/comment/3680001/","msgid":"<aee5drWmWZ3Mnw3A@gallifrey>","list_archive_url":null,"date":"2026-04-21T17:52:54","subject":"Re: [PATCH] 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":"* Alano Song (alanosong@163.com) wrote:\n> At 2026-04-19 01:23:46, \"Dr. David Alan Gilbert\" <dave@treblig.org> wrote:\n> >* 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> >\n> >Does typing ctrl-l not do it for you in your terminal?\n> >\n> >Dave\n> >\n\nHi Alano,\n\n> Yes, you are correct that ctrl-l provides basic screen clear,\n> but the new `clear` command clears both visible screen and\n> scrollback buffer, just like `clear` command does on my Ubuntu terminal.\n\n> I still believe that this patch is useful:\n> 1) Many linux users like me instinctively type `clear`\n> when we want to tidy up the terminal.\n> 2) Not everyone is aware of or remembers the ctrl-l shortcut.\n>    A typed command is more discoverable, especially for new users\n>    or those who don't use terminal shortcuts regularly.\n\nOK, mainly because of the difference with the scrollback buffer which I\nsee is different. (Ctrl-l is a great one to know, it works in almost\neverything, not just qemu, it's a basic ASCII control code going\nback about 60 years)\n\nNow to get to the magic line:\n\n> >> +void hmp_clear(Monitor *mon, const QDict *qdict)\n> >> +{\n> >> +    monitor_printf(mon, \"\\x1b[3J\\x1b[2J\\x1b[H\");\n\nFirstly it would be great to comment this; as I read it,\nthis is:\n   clear scrollback\n   clear screen\n   cursor back to top-left\n\nBut, this has a problem - for me on both mate-terminal and\nterminator (but not konsole), this doesn't completely clear\nthe scrollback; it clears most of the scrollback, but leaves\nabout one page; my guess is what happens here is you clear\nthe scrollback, but then the current screen goes into it\nafter/when you clear it.\n\nLooking at the output of the ncurses 'clear' command:\n\ndg@dalek:~$ clear|xxd -g 1\n00000000: 1b 5b 48 1b 5b 32 4a 1b 5b 33 4a                 .[H.[2J.[3J\n\nit's got them in the opposite order, cursor, clear screen, clear scrollback\nand that's fine in both mate-terminal/terminator & konsole.\n(This is Fedora 44 with vte291-0.84.0-1.fc44.x86_64 being used by mate-terminal).\n[I can't tell you if that's a bug in one or both of the terminals]\n\nSo please, flip the output around, and add a comment.\n\nThanks,\n\nDave\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> >> \n> >-- \n> > -----Open up your eyes, open up your mind, open up your code -------   \n> >/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \\ \n> >\\        dave @ treblig.org |                               | In Hex /\n> > \\ _________________________|_____ http://www.treblig.org   |_______/","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=phGVos0o;\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 4g0VN74jRCz1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 03:53:58 +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 1wFFHn-0004o2-8K; Tue, 21 Apr 2026 13:53:23 -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 1wFFHZ-0004kv-0O\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 13:53:09 -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 1wFFHU-0005t0-CM\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 13:53:06 -0400","from dg by mx.treblig.org with local (Exim 4.98.2)\n (envelope-from <dg@treblig.org>) id 1wFFHK-00000009mM7-1ivs;\n Tue, 21 Apr 2026 17:52:54 +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=TW5jHW/KOJebUl7hjW49Ydia9tEBvWCgVMPDUCI1vCg=; b=phGVos0owXA3ZD7S\n 6kOAtJ5rSoEQHE5OBZND2nxNeEfUm/X8PZwnz9WqtE381iZxuJk8QYxJeaOXPwu7z1SGxX+Gzociq\n hSKqZvSmh/6ghHNpx1eFzBAzm9bgCvUH8peLQbmAhs8M1fmr273A6lN37yNjHALNSr3AJVlZyoK0B\n 4mRJq5DwCS8lrXmDNEUqgceCmrZORYECLdf+FWuIHl1V00IvnCJZwfambqjpOttxccIBrbTFSfG1S\n C5ALfz9DqyAKQZuaXnrRJ4DDbrOZrpQXEbl/HnwtCKU+jiVHJ445ioS4TMgGctIYSMECiOgT8yJwV\n vWOrT0oD5AaE2KltRw==;","Date":"Tue, 21 Apr 2026 17:52:54 +0000","From":"\"Dr. David Alan Gilbert\" <dave@treblig.org>","To":"Alano Song <alanosong@163.com>","Cc":"qemu-devel@nongnu.org, pbonzini@redhat.com","Subject":"Re: [PATCH] monitor: Add `clear` command","Message-ID":"<aee5drWmWZ3Mnw3A@gallifrey>","References":"<20260418133927.43012-1-AlanoSong@163.com>\n <aeO-IqKqBwtKfW8P@gallifrey>\n <142c6c8b.11e3.19da4b172c4.Coremail.alanosong@163.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","In-Reply-To":"<142c6c8b.11e3.19da4b172c4.Coremail.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":"17:37:01 up 39 days, 18:50,  3 users,  load average: 0.09, 0.03,\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"}},{"id":3680638,"web_url":"http://patchwork.ozlabs.org/comment/3680638/","msgid":"<342571e6.a253.19db56f6cb9.Coremail.alanosong@163.com>","list_archive_url":null,"date":"2026-04-22T13:44:31","subject":"Re: [PATCH] monitor: Add `clear` command","submitter":{"id":92155,"url":"http://patchwork.ozlabs.org/api/people/92155/","name":"Alano Song","email":"AlanoSong@163.com"},"content":"At 2026-04-22 01:52:54, \"Dr. David Alan Gilbert\" <dave@treblig.org> wrote:\n>* Alano Song (alanosong@163.com) wrote:\n>> At 2026-04-19 01:23:46, \"Dr. David Alan Gilbert\" <dave@treblig.org> wrote:\n>> >* 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>> >\n>> >Does typing ctrl-l not do it for you in your terminal?\n>> >\n>> >Dave\n>> >\n>\n>Hi Alano,\n>\n>> Yes, you are correct that ctrl-l provides basic screen clear,\n>> but the new `clear` command clears both visible screen and\n>> scrollback buffer, just like `clear` command does on my Ubuntu terminal.\n>\n>> I still believe that this patch is useful:\n>> 1) Many linux users like me instinctively type `clear`\n>> when we want to tidy up the terminal.\n>> 2) Not everyone is aware of or remembers the ctrl-l shortcut.\n>>    A typed command is more discoverable, especially for new users\n>>    or those who don't use terminal shortcuts regularly.\n>\n>OK, mainly because of the difference with the scrollback buffer which I\n>see is different. (Ctrl-l is a great one to know, it works in almost\n>everything, not just qemu, it's a basic ASCII control code going\n>back about 60 years)\n>\n\n\nHi, Dr.Gilbert,\nThanks for sharing that, got it :)\n\n\n>Now to get to the magic line:\n>\n>> >> +void hmp_clear(Monitor *mon, const QDict *qdict)\n>> >> +{\n>> >> +    monitor_printf(mon, \"\\x1b[3J\\x1b[2J\\x1b[H\");\n>\n>Firstly it would be great to comment this; as I read it,\n>this is:\n>   clear scrollback\n>   clear screen\n>   cursor back to top-left\n>\n>But, this has a problem - for me on both mate-terminal and\n>terminator (but not konsole), this doesn't completely clear\n>the scrollback; it clears most of the scrollback, but leaves\n>about one page; my guess is what happens here is you clear\n>the scrollback, but then the current screen goes into it\n>after/when you clear it.\n>\n>Looking at the output of the ncurses 'clear' command:\n>\n>dg@dalek:~$ clear|xxd -g 1\n>00000000: 1b 5b 48 1b 5b 32 4a 1b 5b 33 4a                 .[H.[2J.[3J\n\n>\n\n\nYou are right, the command order on my ubuntu24.04 is the same with you:\nalano@alano:~/code$ clear | xxd -g 1\n00000000: 1b 5b 48 1b 5b 32 4a 1b 5b 33 4a                 .[H.[2J.[3J\n\nSo I will correct the command order sent in patch :)\n\n\n>it's got them in the opposite order, cursor, clear screen, clear scrollback\n>and that's fine in both mate-terminal/terminator & konsole.\n>(This is Fedora 44 with vte291-0.84.0-1.fc44.x86_64 being used by mate-terminal).\n>[I can't tell you if that's a bug in one or both of the terminals]\n>\n>So please, flip the output around, and add a comment.\n>\n>Thanks,\n>\n\n>Dave\n\n\nI will add comment in code and help info in v2 patch.\n\nBest Regards,\nAlano.\n\n\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>> >> \n>> >-- \n>> > -----Open up your eyes, open up your mind, open up your code -------   \n>> >/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \\ \n>> >\\        dave @ treblig.org |                               | In Hex /\n>> > \\ _________________________|_____ http://www.treblig.org   |_______/\n>-- \n> -----Open up your eyes, open up your mind, open up your code -------   \n>/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \\ \n>\\        dave @ treblig.org |                               | In Hex /\n> \\ _________________________|_____ http://www.treblig.org   |_______/","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 (1024-bit key;\n unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256\n header.s=s110527 header.b=cy3m9lZB;\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 4g10px1tq5z1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 23:45:27 +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 1wFXsq-0001IZ-Dx; Wed, 22 Apr 2026 09:44:52 -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 <alanosong@163.com>) id 1wFXso-0001Ht-4P\n for qemu-devel@nongnu.org; Wed, 22 Apr 2026 09:44:50 -0400","from m16.mail.163.com ([220.197.31.2])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <alanosong@163.com>) id 1wFXsl-0003aq-1l\n for qemu-devel@nongnu.org; Wed, 22 Apr 2026 09:44:49 -0400","from alanosong$163.com ( [171.83.94.98] ) by\n ajax-webmail-wmsvr-40-132 (Coremail) ; Wed, 22 Apr 2026 21:44:31 +0800\n (CST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com;\n s=s110527; h=Date:From:To:Subject:Content-Type:MIME-Version:\n Message-ID; bh=AdoYFSMlVP6prkQCfVaHoU1VmUhVUGos2w8vIKmRv8M=; b=c\n y3m9lZBTszy0LZ8bb79XnUpuqwg8JgitCgvalDoNbTW0j2H2Sf7B8lKUgwUudPju\n U0DxV8HD+4mveqiqYGqykoabiJN298Ea7GIpNkGsM5O4jq7FQsKD8H9iF2Ahy8Ze\n c1MtrgIvw1JHsN0e0ooDEMuIrh68N7r/4U9Chfp65U=","X-Originating-IP":"[171.83.94.98]","Date":"Wed, 22 Apr 2026 21:44:31 +0800 (CST)","From":"\"Alano Song\" <alanosong@163.com>","To":"\"Dr. David Alan Gilbert\" <dave@treblig.org>","Cc":"qemu-devel@nongnu.org, pbonzini@redhat.com","Subject":"Re: [PATCH] monitor: Add `clear` command","X-Priority":"3","X-Mailer":"Coremail Webmail Server Version 2023.4-cmXT build\n 20260403(27802f6d) Copyright (c) 2002-2026 www.mailtech.cn 163com","In-Reply-To":"<aee5drWmWZ3Mnw3A@gallifrey>","References":"<20260418133927.43012-1-AlanoSong@163.com>\n <aeO-IqKqBwtKfW8P@gallifrey>\n <142c6c8b.11e3.19da4b172c4.Coremail.alanosong@163.com>\n <aee5drWmWZ3Mnw3A@gallifrey>","X-NTES-SC":"\n AL_Qu2cBPSdukws5yadbekcm0wQgOk5XsCwu/wk3YNec8IFkgLu3AUlcV59MWPV9sSWLTCGmxy9WwlMwMtKeZFgLmov3fN4J9TPnKzOZnqUcQ==","Content-Type":"multipart/alternative;\n boundary=\"----=_Part_156069_94634200.1776865471673\"","MIME-Version":"1.0","Message-ID":"<342571e6.a253.19db56f6cb9.Coremail.alanosong@163.com>","X-Coremail-Locale":"zh_CN","X-CM-TRANSID":"hCgvCgDnB2jA0OhpJnWUAA--.42085W","X-CM-SenderInfo":"xdod00pvrqwqqrwthudrp/xtbC1B-3DGno0L8i7QAA3R","X-Coremail-Antispam":"1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU==","Received-SPF":"pass client-ip=220.197.31.2; envelope-from=alanosong@163.com;\n 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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001,\n RCVD_IN_MSPIKE_WL=0.001, 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"}}]