[Qemu-devel] [PATCH v2 5/5] ppc/xics: rework the ICS classes inheritance tree

Cédric Le Goater posted 5 patches 7 years, 4 months ago
[Qemu-devel] [PATCH v2 5/5] ppc/xics: rework the ICS classes inheritance tree
Posted by Cédric Le Goater 7 years, 4 months ago
With the previous changes, we can now let the ICS_KVM class inherit
directly from ICS_BASE class and not from the intermediate ICS_SIMPLE.
It makes the class hierarchy much cleaner.

What is left in the top classes is the low level interface to access
the KVM XICS device in ICS_KVM and the XICS emulating handlers in
ICS_SIMPLE.

This should not break migration compatibility.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/intc/xics_kvm.c | 12 +++++-------
 hw/ppc/spapr.c     |  2 +-
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index b314eb7d1607..30c3769a2084 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -359,12 +359,10 @@ static void ics_kvm_class_init(ObjectClass *klass, void *data)
     ICSStateClass *icsc = ICS_BASE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    /*
-     * Use device_class_set_parent_realize() when ics-kvm inherits
-     * directly from ics-base and not from ics-simple anymore.
-     */
-    dc->realize = ics_kvm_realize;
-    dc->reset = ics_kvm_reset;
+    device_class_set_parent_realize(dc, ics_kvm_realize,
+                                    &icsc->parent_realize);
+    device_class_set_parent_reset(dc, ics_kvm_reset,
+                                  &icsc->parent_reset);
 
     icsc->pre_save = ics_get_kvm_state;
     icsc->post_load = ics_set_kvm_state;
@@ -373,7 +371,7 @@ static void ics_kvm_class_init(ObjectClass *klass, void *data)
 
 static const TypeInfo ics_kvm_info = {
     .name = TYPE_ICS_KVM,
-    .parent = TYPE_ICS_SIMPLE,
+    .parent = TYPE_ICS_BASE,
     .instance_size = sizeof(ICSState),
     .class_init = ics_kvm_class_init,
 };
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0d032a1ad03c..8cc996d0b822 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -137,7 +137,7 @@ static ICSState *spapr_ics_create(sPAPRMachineState *spapr,
         goto error;
     }
 
-    return ICS_SIMPLE(obj);
+    return ICS_BASE(obj);
 
 error:
     error_propagate(errp, local_err);
-- 
2.13.6


Re: [Qemu-devel] [PATCH v2 5/5] ppc/xics: rework the ICS classes inheritance tree
Posted by David Gibson 7 years, 4 months ago
On Mon, Jun 25, 2018 at 11:17:18AM +0200, Cédric Le Goater wrote:
> With the previous changes, we can now let the ICS_KVM class inherit
> directly from ICS_BASE class and not from the intermediate ICS_SIMPLE.
> It makes the class hierarchy much cleaner.
> 
> What is left in the top classes is the low level interface to access
> the KVM XICS device in ICS_KVM and the XICS emulating handlers in
> ICS_SIMPLE.
> 
> This should not break migration compatibility.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Applied, thanks.

> ---
>  hw/intc/xics_kvm.c | 12 +++++-------
>  hw/ppc/spapr.c     |  2 +-
>  2 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
> index b314eb7d1607..30c3769a2084 100644
> --- a/hw/intc/xics_kvm.c
> +++ b/hw/intc/xics_kvm.c
> @@ -359,12 +359,10 @@ static void ics_kvm_class_init(ObjectClass *klass, void *data)
>      ICSStateClass *icsc = ICS_BASE_CLASS(klass);
>      DeviceClass *dc = DEVICE_CLASS(klass);
>  
> -    /*
> -     * Use device_class_set_parent_realize() when ics-kvm inherits
> -     * directly from ics-base and not from ics-simple anymore.
> -     */
> -    dc->realize = ics_kvm_realize;
> -    dc->reset = ics_kvm_reset;
> +    device_class_set_parent_realize(dc, ics_kvm_realize,
> +                                    &icsc->parent_realize);
> +    device_class_set_parent_reset(dc, ics_kvm_reset,
> +                                  &icsc->parent_reset);
>  
>      icsc->pre_save = ics_get_kvm_state;
>      icsc->post_load = ics_set_kvm_state;
> @@ -373,7 +371,7 @@ static void ics_kvm_class_init(ObjectClass *klass, void *data)
>  
>  static const TypeInfo ics_kvm_info = {
>      .name = TYPE_ICS_KVM,
> -    .parent = TYPE_ICS_SIMPLE,
> +    .parent = TYPE_ICS_BASE,
>      .instance_size = sizeof(ICSState),
>      .class_init = ics_kvm_class_init,
>  };
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 0d032a1ad03c..8cc996d0b822 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -137,7 +137,7 @@ static ICSState *spapr_ics_create(sPAPRMachineState *spapr,
>          goto error;
>      }
>  
> -    return ICS_SIMPLE(obj);
> +    return ICS_BASE(obj);
>  
>  error:
>      error_propagate(errp, local_err);

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson