From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJN1L-0001Mw-8R for qemu-devel@nongnu.org; Tue, 10 Sep 2013 08:26:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJN1G-0002Kj-5y for qemu-devel@nongnu.org; Tue, 10 Sep 2013 08:26:15 -0400 Received: from cantor2.suse.de ([195.135.220.15]:37030 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJN1F-0002Kb-Q2 for qemu-devel@nongnu.org; Tue, 10 Sep 2013 08:26:10 -0400 Message-ID: <522F0FDD.9030103@suse.de> Date: Tue, 10 Sep 2013 14:26:05 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC qom-cpu v2 2/8] x86: add x86_cpu_unrealizefn() for cpu apic remove List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chen Fan Cc: Igor Mammedov , qemu-devel@nongnu.org Am 10.09.2013 11:43, schrieb Chen Fan: > Implement x86_cpu_unrealizefn() for corresponding x86_cpu_realizefn(), > which is mostly used to clear the apic related information at here. >=20 > Signed-off-by: Chen Fan > --- > hw/cpu/icc_bus.c | 11 +++++++++++ > hw/i386/kvm/apic.c | 6 ++++++ > hw/intc/apic.c | 7 +++++++ > hw/intc/apic_common.c | 11 +++++++++++ > include/hw/cpu/icc_bus.h | 1 + > include/hw/i386/apic_internal.h | 1 + > target-i386/cpu-qom.h | 1 + > target-i386/cpu.c | 35 +++++++++++++++++++++++++++++++++= ++ > 8 files changed, 73 insertions(+) Some nitpicks below, mostly about adopting the latest concepts. > diff --git a/hw/cpu/icc_bus.c b/hw/cpu/icc_bus.c > index 8748cc5..45e87d1 100644 > --- a/hw/cpu/icc_bus.c > +++ b/hw/cpu/icc_bus.c > @@ -54,11 +54,22 @@ static void icc_device_realize(DeviceState *dev, Er= ror **errp) > } > } > =20 > +static void icc_device_unrealize(DeviceState *dev, Error **errp) > +{ > + ICCDevice *id =3D ICC_DEVICE(dev); > + ICCDeviceClass *idc =3D ICC_DEVICE_GET_CLASS(id); > + > + if (idc->exit) { > + idc->exit(id); ->unrealize > + } > +} > + > static void icc_device_class_init(ObjectClass *oc, void *data) > { > DeviceClass *dc =3D DEVICE_CLASS(oc); > =20 > dc->realize =3D icc_device_realize; > + dc->unrealize =3D icc_device_unrealize; > dc->bus_type =3D TYPE_ICC_BUS; > } > =20 > diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c > index 5609063..8f028a1 100644 > --- a/hw/i386/kvm/apic.c > +++ b/hw/i386/kvm/apic.c > @@ -181,11 +181,17 @@ static void kvm_apic_init(APICCommonState *s) > } > } > =20 > +static void kvm_apic_exit(APICCommonState *s) kvm_apic_unrealize > +{ > + memory_region_destroy(&s->io_memory); > +} > + > static void kvm_apic_class_init(ObjectClass *klass, void *data) > { > APICCommonClass *k =3D APIC_COMMON_CLASS(klass); > =20 > k->init =3D kvm_apic_init; > + k->exit =3D kvm_apic_exit; > k->set_base =3D kvm_apic_set_base; > k->set_tpr =3D kvm_apic_set_tpr; > k->get_tpr =3D kvm_apic_get_tpr; > diff --git a/hw/intc/apic.c b/hw/intc/apic.c > index a913186..23488b4 100644 > --- a/hw/intc/apic.c > +++ b/hw/intc/apic.c > @@ -882,11 +882,18 @@ static void apic_init(APICCommonState *s) > msi_supported =3D true; > } > =20 > +static void apic_uninit(APICCommonState *s) apic_unrealize > +{ > + memory_region_destroy(&s->io_memory); > + local_apics[s->idx] =3D NULL; > +} > + > static void apic_class_init(ObjectClass *klass, void *data) > { > APICCommonClass *k =3D APIC_COMMON_CLASS(klass); > =20 > k->init =3D apic_init; > + k->exit =3D apic_uninit; > k->set_base =3D apic_set_base; > k->set_tpr =3D apic_set_tpr; > k->get_tpr =3D apic_get_tpr; > diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c > index 5568621..32c2f74 100644 > --- a/hw/intc/apic_common.c > +++ b/hw/intc/apic_common.c > @@ -316,6 +316,16 @@ static int apic_init_common(ICCDevice *dev) > return 0; > } > =20 > +static void apic_exit_common(ICCDevice *dev) > +{ > + APICCommonState *s =3D APIC_COMMON(dev); > + APICCommonClass *info; acc please > + > + info =3D APIC_COMMON_GET_CLASS(s); > + if (info->exit) > + info->exit(s); Braces missing -> checkpatch.pl > +} > + > static void apic_dispatch_pre_save(void *opaque) > { > APICCommonState *s =3D APIC_COMMON(opaque); > @@ -387,6 +397,7 @@ static void apic_common_class_init(ObjectClass *kla= ss, void *data) > dc->no_user =3D 1; > dc->props =3D apic_properties_common; > idc->init =3D apic_init_common; > + idc->exit =3D apic_exit_common; > } > =20 > static const TypeInfo apic_common_type =3D { > diff --git a/include/hw/cpu/icc_bus.h b/include/hw/cpu/icc_bus.h > index b550070..15d5374 100644 > --- a/include/hw/cpu/icc_bus.h > +++ b/include/hw/cpu/icc_bus.h > @@ -67,6 +67,7 @@ typedef struct ICCDeviceClass { > /*< public >*/ > =20 > int (*init)(ICCDevice *dev); /* TODO replace with QOM realize */ > + void (*exit)(ICCDevice *dev); DeviceUnrealize unrealize; > } ICCDeviceClass; > =20 > #define TYPE_ICC_DEVICE "icc-device" > diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_int= ernal.h > index 1b0a7fb..87d5248 100644 > --- a/include/hw/i386/apic_internal.h > +++ b/include/hw/i386/apic_internal.h > @@ -81,6 +81,7 @@ typedef struct APICCommonClass > ICCDeviceClass parent_class; > =20 > void (*init)(APICCommonState *s); > + void (*exit)(APICCommonState *s); DeviceUnrealize unrealize; > void (*set_base)(APICCommonState *s, uint64_t val); > void (*set_tpr)(APICCommonState *s, uint8_t val); > uint8_t (*get_tpr)(APICCommonState *s); > diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h > index c4447c2..1e520be 100644 > --- a/target-i386/cpu-qom.h > +++ b/target-i386/cpu-qom.h > @@ -50,6 +50,7 @@ typedef struct X86CPUClass { > /*< public >*/ > =20 > DeviceRealize parent_realize; > + DeviceUnrealize parent_unrealize; > void (*parent_reset)(CPUState *cpu); > } X86CPUClass; > =20 > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index 2b99683..6f9154d 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -2339,10 +2339,31 @@ static void x86_cpu_apic_realize(X86CPU *cpu, E= rror **errp) > return; > } > } > + > +static void x86_cpu_apic_unrealize(X86CPU *cpu, Error **errp) > +{ > + CPUX86State *env =3D &cpu->env; > + Error *local_err =3D NULL; > + > + if (env->apic_state =3D=3D NULL) { > + return; > + } > + > + object_property_set_bool(OBJECT(env->apic_state), false, "realized= ", &local_err); > + if (local_err !=3D NULL) { > + error_propagate(errp, local_err); > + return; > + } > + > + qdev_free(env->apic_state); > +} > #else > static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp) > { > } > +static void x86_cpu_apic_unrealize(X86CPU *cpu, Error **errp) > +{ > +} > #endif > =20 > static void x86_cpu_realizefn(DeviceState *dev, Error **errp) > @@ -2418,6 +2439,18 @@ out: > } > } > =20 > +static void x86_cpu_unrealizefn(DeviceState *dev, Error **errp) > +{ > + X86CPU *cpu =3D X86_CPU(dev); > + Error *local_err =3D NULL; > + > + x86_cpu_apic_unrealize(cpu, &local_err); > + if (local_err !=3D NULL) { > + error_propagate(errp, local_err); > + return; > + } > +} > + > /* Enables contiguous-apic-ID mode, for compatibility */ > static bool compat_apic_id_mode; > =20 > @@ -2549,7 +2582,9 @@ static void x86_cpu_common_class_init(ObjectClass= *oc, void *data) > DeviceClass *dc =3D DEVICE_CLASS(oc); > =20 > xcc->parent_realize =3D dc->realize; > + xcc->parent_unrealize =3D dc->unrealize; > dc->realize =3D x86_cpu_realizefn; > + dc->unrealize =3D x86_cpu_unrealizefn; > dc->bus_type =3D TYPE_ICC_BUS; > dc->props =3D x86_cpu_properties; > =20 Regards, Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg