From nobody Sun Apr 28 21:02:52 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15093951688261017.5708893934752; Mon, 30 Oct 2017 13:26:08 -0700 (PDT) Received: from localhost ([::1]:42411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9Gd1-0000M9-6g for importer@patchew.org; Mon, 30 Oct 2017 16:25:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9GbK-0007tN-E5 for qemu-devel@nongnu.org; Mon, 30 Oct 2017 16:24:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9GbI-0006Hk-Bi for qemu-devel@nongnu.org; Mon, 30 Oct 2017 16:24:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47720) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e9GbI-0006HS-2a for qemu-devel@nongnu.org; Mon, 30 Oct 2017 16:24:00 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2EF8983F44; Mon, 30 Oct 2017 20:23:59 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-209.ams2.redhat.com [10.36.117.209]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5771F600C2; Mon, 30 Oct 2017 20:23:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2EF8983F44 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dgilbert@redhat.com From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, groug@kaod.org, lu.zhipeng@zte.com.cn Date: Mon, 30 Oct 2017 20:23:55 +0000 Message-Id: <20171030202356.11047-2-dgilbert@redhat.com> In-Reply-To: <20171030202356.11047-1-dgilbert@redhat.com> References: <20171030202356.11047-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 30 Oct 2017 20:23:59 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/2] hmp: Replace error_report_err X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: ZhiPeng Lu Use hmp_handle_error instend of error_report_err to set error. Signed-off-by: ZhiPeng Lu Reviewed-by: Jiyun Fan Message-Id: <1508411793-22868-1-git-send-email-lu.zhipeng@zte.com.cn> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Dr. David Alan Gilbert --- hmp.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/hmp.c b/hmp.c index a01be50daa..35a7041824 100644 --- a/hmp.c +++ b/hmp.c @@ -670,7 +670,7 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict) =20 info2l =3D qmp_query_vnc_servers(&err); if (err) { - error_report_err(err); + hmp_handle_error(mon, &err); return; } if (!info2l) { @@ -785,7 +785,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict) =20 info =3D qmp_query_balloon(&err); if (err) { - error_report_err(err); + hmp_handle_error(mon, &err); return; } =20 @@ -1128,7 +1128,7 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdic= t) =20 data =3D qmp_ringbuf_read(chardev, size, false, 0, &err); if (err) { - error_report_err(err); + hmp_handle_error(mon, &err); return; } =20 @@ -1195,9 +1195,7 @@ void hmp_balloon(Monitor *mon, const QDict *qdict) Error *err =3D NULL; =20 qmp_balloon(value, &err); - if (err) { - error_report_err(err); - } + hmp_handle_error(mon, &err); } =20 void hmp_block_resize(Monitor *mon, const QDict *qdict) @@ -1534,10 +1532,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, const = QDict *qdict) Error *err =3D NULL; =20 qmp_migrate_set_cache_size(value, &err); - if (err) { - error_report_err(err); - return; - } + hmp_handle_error(mon, &err); } =20 /* Kept for backwards compatibility */ @@ -1568,10 +1563,7 @@ void hmp_migrate_set_capability(Monitor *mon, const = QDict *qdict) =20 end: qapi_free_MigrationCapabilityStatusList(caps); - - if (err) { - error_report_err(err); - } + hmp_handle_error(mon, &err); } =20 void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) @@ -1680,9 +1672,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QD= ict *qdict) cleanup: qapi_free_MigrateSetParameters(p); visit_free(v); - if (err) { - error_report_err(err); - } + hmp_handle_error(mon, &err); } =20 void hmp_client_migrate_info(Monitor *mon, const QDict *qdict) @@ -1936,7 +1926,7 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) =20 qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false, &err); if (err) { - error_report_err(err); + hmp_handle_error(mon, &err); return; } =20 --=20 2.14.3 From nobody Sun Apr 28 21:02:52 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509395163746560.1148062711476; Mon, 30 Oct 2017 13:26:03 -0700 (PDT) Received: from localhost ([::1]:42413 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9Gd4-0000R1-S9 for importer@patchew.org; Mon, 30 Oct 2017 16:25:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9GbK-0007tP-EQ for qemu-devel@nongnu.org; Mon, 30 Oct 2017 16:24:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9GbJ-0006IB-Fs for qemu-devel@nongnu.org; Mon, 30 Oct 2017 16:24:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35810) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e9GbJ-0006Hs-7Q for qemu-devel@nongnu.org; Mon, 30 Oct 2017 16:24:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51EECC0587E4; Mon, 30 Oct 2017 20:24:00 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-209.ams2.redhat.com [10.36.117.209]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78E01600C2; Mon, 30 Oct 2017 20:23:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51EECC0587E4 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dgilbert@redhat.com From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, groug@kaod.org, lu.zhipeng@zte.com.cn Date: Mon, 30 Oct 2017 20:23:56 +0000 Message-Id: <20171030202356.11047-3-dgilbert@redhat.com> In-Reply-To: <20171030202356.11047-1-dgilbert@redhat.com> References: <20171030202356.11047-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 30 Oct 2017 20:24:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/2] monitor: fix dangling CPU pointer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz If a CPU selected with the "cpu" command is hot-unplugged then "info cpus" causes QEMU to exit: (qemu) device_del cpu1 (qemu) info cpus qemu:qemu_cpu_kick_thread: No such process This happens because "cpu" stores the pointer to the selected CPU into the monitor structure. When the CPU is hot-unplugged, we end up with a dangling pointer. The "info cpus" command then does: hmp_info_cpus() monitor_get_cpu_index() mon_get_cpu() cpu_synchronize_state() <--- called with dangling pointer This could cause a QEMU crash as well. This patch switches the monitor to store the QOM path instead of a pointer to the current CPU. The path is then resolved when needed. If the resolution fails, we assume that the CPU was removed and the path is resetted to the default (ie, path of first_cpu). Reported-by: Satheesh Rajendran Suggested-by: Igor Mammedov Signed-off-by: Greg Kurz Message-Id: <150822818243.26242.12993827911736928961.stgit@bahia.lan> Reviewed-by: Igor Mammedov Signed-off-by: Dr. David Alan Gilbert --- monitor.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/monitor.c b/monitor.c index 7a802a345e..e36fb5308d 100644 --- a/monitor.c +++ b/monitor.c @@ -200,7 +200,7 @@ struct Monitor { =20 ReadLineState *rs; MonitorQMP qmp; - CPUState *mon_cpu; + gchar *mon_cpu_path; BlockCompletionFunc *password_completion_cb; void *password_opaque; mon_cmd_t *cmd_table; @@ -579,6 +579,7 @@ static void monitor_data_init(Monitor *mon) =20 static void monitor_data_destroy(Monitor *mon) { + g_free(mon->mon_cpu_path); qemu_chr_fe_deinit(&mon->chr, false); if (monitor_is_qmp(mon)) { json_message_parser_destroy(&mon->qmp.parser); @@ -1047,20 +1048,32 @@ int monitor_set_cpu(int cpu_index) if (cpu =3D=3D NULL) { return -1; } - cur_mon->mon_cpu =3D cpu; + g_free(cur_mon->mon_cpu_path); + cur_mon->mon_cpu_path =3D object_get_canonical_path(OBJECT(cpu)); return 0; } =20 CPUState *mon_get_cpu(void) { - if (!cur_mon->mon_cpu) { + CPUState *cpu; + + if (cur_mon->mon_cpu_path) { + cpu =3D (CPUState *) object_resolve_path_type(cur_mon->mon_cpu_pat= h, + TYPE_CPU, NULL); + if (!cpu) { + g_free(cur_mon->mon_cpu_path); + cur_mon->mon_cpu_path =3D NULL; + } + } + if (!cur_mon->mon_cpu_path) { if (!first_cpu) { return NULL; } monitor_set_cpu(first_cpu->cpu_index); + cpu =3D first_cpu; } - cpu_synchronize_state(cur_mon->mon_cpu); - return cur_mon->mon_cpu; + cpu_synchronize_state(cpu); + return cpu; } =20 CPUArchState *mon_get_cpu_env(void) --=20 2.14.3