From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl3NK-0005HH-I3 for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tl3NH-0000cg-1y for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34947) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl3NG-0000c7-PI for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:46 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBIK2kZH019518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Dec 2012 15:02:46 -0500 Received: from blackpad.lan.raisama.net (vpn1-6-125.gru2.redhat.com [10.97.6.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBIK2jaT002271 for ; Tue, 18 Dec 2012 15:02:45 -0500 From: Eduardo Habkost Date: Tue, 18 Dec 2012 18:04:02 -0200 Message-Id: <1355861053-11460-10-git-send-email-ehabkost@redhat.com> In-Reply-To: <1355861053-11460-1-git-send-email-ehabkost@redhat.com> References: <1355861053-11460-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [RFC 09/20] cpu: introduce cpu_realize() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is just for testing/demonstration purposes. Probably this will be replaced by the more generic DeviceState realize() method, later. Signed-off-by: Eduardo Habkost --- include/qemu/cpu.h | 13 +++++++++++++ qom/cpu.c | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h index b27b353..90bb27d 100644 --- a/include/qemu/cpu.h +++ b/include/qemu/cpu.h @@ -20,6 +20,7 @@ #ifndef QEMU_CPU_H #define QEMU_CPU_H +#include "error.h" #include "qemu/object.h" #include "qemu-thread.h" @@ -41,6 +42,7 @@ typedef struct CPUState CPUState; /** * CPUClass: * @reset: Callback to reset the #CPUState to its initial state. + * @realize: Realize function to finish CPU initialization. * * Represents a CPU family or model. */ @@ -50,6 +52,7 @@ typedef struct CPUClass { /*< public >*/ void (*reset)(CPUState *cpu); + void (*realize)(CPUState *cpu, Error **errp); } CPUClass; /** @@ -88,6 +91,16 @@ struct CPUState { */ void cpu_reset(CPUState *cpu); + +/** + * cpu_realize: + * @cpu: The CPU that is going to be "realized". + * + * Finishes initialization of the CPU object, after properties have been + * set. + */ +void cpu_realize(CPUState *cpu, Error **errp); + /** * qemu_cpu_has_work: * @cpu: The vCPU to check. diff --git a/qom/cpu.c b/qom/cpu.c index 5b36046..a96f6ee 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -30,6 +30,16 @@ void cpu_reset(CPUState *cpu) } } +void cpu_realize(CPUState *cpu, Error **errp) +{ + CPUClass *klass = CPU_GET_CLASS(cpu); + + if (klass->realize) { + (*klass->realize)(cpu, errp); + } +} + + static void cpu_common_reset(CPUState *cpu) { } -- 1.7.11.7