From patchwork Wed Feb 22 18:04:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 731260 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vT5021c3Qz9s7d for ; Thu, 23 Feb 2017 05:06:10 +1100 (AEDT) Received: from localhost ([::1]:54524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgbIl-0003Cp-M1 for incoming@patchwork.ozlabs.org; Wed, 22 Feb 2017 13:06:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgbHK-00028X-Cz for qemu-devel@nongnu.org; Wed, 22 Feb 2017 13:04:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgbHJ-0006Ew-ET for qemu-devel@nongnu.org; Wed, 22 Feb 2017 13:04:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgbHJ-0006EW-8s for qemu-devel@nongnu.org; Wed, 22 Feb 2017 13:04:37 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 604DA6AAEB for ; Wed, 22 Feb 2017 18:04:37 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-116-160.ams2.redhat.com [10.36.116.160]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MI4OAh032732; Wed, 22 Feb 2017 13:04:34 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 19:04:22 +0100 Message-Id: <20170222180423.26571-3-pbonzini@redhat.com> In-Reply-To: <20170222180423.26571-1-pbonzini@redhat.com> References: <20170222180423.26571-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 22 Feb 2017 18:04:37 +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] [PATCH 2/3] cpu: implement get_crash_info through QOM properties 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: , Cc: marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Provide a generic implementation for all CPU subclasses. Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- include/qom/cpu.h | 1 - qom/cpu.c | 11 ++++------- target/i386/cpu.c | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 1bc3ad2..04d3a2c 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -158,7 +158,6 @@ typedef struct CPUClass { uint8_t *buf, int len, bool is_write); void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags); - GuestPanicInformation* (*get_crash_info)(CPUState *cpu); void (*dump_statistics)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags); int64_t (*get_arch_id)(CPUState *cpu); diff --git a/qom/cpu.c b/qom/cpu.c index 7e005af..a9482ce 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -22,6 +22,8 @@ #include "qapi/error.h" #include "qemu-common.h" #include "qom/cpu.h" +#include "qom/qom-qobject.h" +#include "qapi-visit.h" #include "sysemu/hw_accel.h" #include "qemu/notify.h" #include "qemu/log.h" @@ -220,13 +222,8 @@ static bool cpu_common_exec_interrupt(CPUState *cpu, int int_req) GuestPanicInformation *cpu_get_crash_info(CPUState *cpu) { - CPUClass *cc = CPU_GET_CLASS(cpu); - GuestPanicInformation *res = NULL; - - if (cc->get_crash_info) { - res = cc->get_crash_info(cpu); - } - return res; + return OBJECT_PROPERTY_GET_PTR(OBJECT(cpu), "crash-information", + GuestPanicInformation, NULL); } void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 63be816..3071769 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3516,6 +3516,7 @@ static GuestPanicInformation *x86_cpu_get_crash_info(CPUState *cs) return panic_info; } + static void x86_cpu_get_crash_info_qom(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -3731,7 +3732,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->do_interrupt = x86_cpu_do_interrupt; cc->cpu_exec_interrupt = x86_cpu_exec_interrupt; cc->dump_state = x86_cpu_dump_state; - cc->get_crash_info = x86_cpu_get_crash_info; cc->set_pc = x86_cpu_set_pc; cc->synchronize_from_tb = x86_cpu_synchronize_from_tb; cc->gdb_read_register = x86_cpu_gdb_read_register;