From nobody Thu May 2 07:48:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1605237344; cv=none; d=zohomail.com; s=zohoarc; b=RIS7YDH5JWNMvTdTrEEUN2PJ29O150fKmlKfUmx3TzBsGqoFNOV6tgdHJjVA3TNfCkRvNeN1gQzr7/YweDNI5epLKYEtxhPap62xRVrP1IEF6yhBja0yIFHJ5J5MG15FrPTR8jSr5960HYP4eWOQ8KV+bqXFGoiJCGcViwDVhik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605237344; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=BPNcx/BW6kiVYwjIm1umJ6kEZR4iMH2XydAeu/5+KAA=; b=Iu9Ckq8RLo4M2bfPNGQr1uxDIb/z+/T44WQdYTlk+LmDkuNMqdGcd8+3hrTVHYFRnnJngcwDVACI3VBYLKYcvapSTYon7KclZfEndw9c29WRV13WykyxxAlCxQRITDuqgbHUacCqppEtJycZBIKSELHEGFrs7SpyMwzvo/j+XgQ= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605237344187799.2432543676657; Thu, 12 Nov 2020 19:15:44 -0800 (PST) Received: from localhost ([::1]:41184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdPYt-00019B-3i for importer@patchew.org; Thu, 12 Nov 2020 22:15:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdPXO-0000Fk-IV for qemu-devel@nongnu.org; Thu, 12 Nov 2020 22:14:10 -0500 Received: from [240e:678:8c0:5::c0a8:3a62] (port=32584 helo=FZEX3.ruijie.com.cn) by eggs.gnu.org with esmtps (TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kdPXJ-0000Lj-3h for qemu-devel@nongnu.org; Thu, 12 Nov 2020 22:14:08 -0500 Received: from centos.localdomain (172.20.101.108) by FZEX3.ruijie.com.cn (192.168.58.89) with Microsoft SMTP Server id 14.3.123.3; Fri, 13 Nov 2020 11:13:52 +0800 From: lichun To: Subject: [PATCH] hmp: Update current monitor acts on the entire handle_hmp_command() Date: Fri, 13 Nov 2020 19:13:40 +0800 Message-ID: <1605266020-51470-1-git-send-email-lichun@ruijie.com.cn> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [172.20.101.108] X-Host-Lookup-Failed: Reverse DNS lookup failed for 240e:678:8c0:5::c0a8:3a62 (failed) 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=lists.gnu.org; Received-SPF: permerror client-ip=240e:678:8c0:5::c0a8:3a62; envelope-from=lichun@ruijie.com.cn; helo=FZEX3.ruijie.com.cn X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 9 X-Spam_score: 0.9 X-Spam_bar: / X-Spam_report: (0.9 / 5.0 requ) BAYES_00=-1.9, DATE_IN_FUTURE_06_12=1.947, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lichun , dgilbert@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" monitor_parse_arguments() also need to known the current monitoar: (gdb) bt #0 0x0000555555ac6a6d in mon_get_cpu_sync (mon=3D0x0, synchronize=3Dsynch= ronize@entry=3Dtrue) at ../monitor/misc.c:270 #1 0x0000555555ac6b4a in mon_get_cpu () at ../monitor/misc.c:294 #2 0x0000555555ac80fd in get_monitor_def (pval=3Dpval@entry=3D0x7fffffffc= c78, name=3Dname@entry=3D0x7fffffffcc80 "pc") at ../monitor/misc.c:1669 #3 0x000055555583fa8a in expr_unary (mon=3Dmon@entry=3D0x5555568a75a0) at= ../monitor/hmp.c:387 #4 0x000055555583fb32 in expr_prod (mon=3Dmon@entry=3D0x5555568a75a0) at = ../monitor/hmp.c:421 #5 0x000055555583fbcc in expr_logic (mon=3Dmon@entry=3D0x5555568a75a0) at= ../monitor/hmp.c:455 #6 0x000055555583f82c in expr_sum (mon=3Dmon@entry=3D0x5555568a75a0) at .= ./monitor/hmp.c:484 #7 0x000055555583fc97 in get_expr (mon=3Dmon@entry=3D0x5555568a75a0, pval= =3Dpval@entry=3D0x7fffffffce18, pp=3Dpp@entry=3D0x7fffffffce08) at ../monit= or/hmp.c:511 #8 0x00005555558409b1 in monitor_parse_arguments (mon=3Dmon@entry=3D0x555= 5568a75a0, cmd=3D0x555556561e40 , cmd=3D0x555556561e40 , endp=3D0x7fffffffd288) at ../monitor/hmp.c:876 #9 0x0000555555841796 in handle_hmp_command (mon=3Dmon@entry=3D0x5555568a= 75a0, cmdline=3D0x5555568b12b3 "$pc", cmdline@entry=3D0x5555568b12b0 "xp $p= c") at ../monitor/hmp.c:1073 Therefore update current monitor as soon as possible to avoid hmp/xp command failure. Fixes: ff04108a0e36 ("hmp: Update current monitor only in handle_hmp_comman= d()") Signed-off-by: lichun --- monitor/hmp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/monitor/hmp.c b/monitor/hmp.c index c5cd9d3..ee5413e 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1072,52 +1072,52 @@ static void handle_hmp_command_co(void *opaque) } =20 void handle_hmp_command(MonitorHMP *mon, const char *cmdline) { QDict *qdict; const HMPCommand *cmd; const char *cmd_start =3D cmdline; =20 trace_handle_hmp_command(mon, cmdline); =20 + /* old_mon is non-NULL when called from qmp_human_monitor_command() */ + Monitor *old_mon =3D monitor_set_cur(qemu_coroutine_self(), &mon->comm= on); + cmd =3D monitor_parse_command(mon, cmdline, &cmdline, hmp_cmds); if (!cmd) { return; } =20 qdict =3D monitor_parse_arguments(&mon->common, &cmdline, cmd); if (!qdict) { while (cmdline > cmd_start && qemu_isspace(cmdline[-1])) { cmdline--; } monitor_printf(&mon->common, "Try \"help %.*s\" for more informati= on\n", (int)(cmdline - cmd_start), cmd_start); return; } =20 if (!cmd->coroutine) { - /* old_mon is non-NULL when called from qmp_human_monitor_command(= ) */ - Monitor *old_mon =3D monitor_set_cur(qemu_coroutine_self(), &mon->= common); cmd->cmd(&mon->common, qdict); - monitor_set_cur(qemu_coroutine_self(), old_mon); } else { HandleHmpCommandCo data =3D { .mon =3D &mon->common, .cmd =3D cmd, .qdict =3D qdict, .done =3D false, }; Coroutine *co =3D qemu_coroutine_create(handle_hmp_command_co, &da= ta); - monitor_set_cur(co, &mon->common); aio_co_enter(qemu_get_aio_context(), co); AIO_WAIT_WHILE(qemu_get_aio_context(), !data.done); } + monitor_set_cur(qemu_coroutine_self(), old_mon); =20 qobject_unref(qdict); } =20 static void cmd_completion(MonitorHMP *mon, const char *name, const char *= list) { const char *p, *pstart; char cmd[128]; int len; =20 --=20 1.8.3.1