On 05/23/2012 05:07 AM, Andreas Färber wrote:
Needed for converting cpu_is_bsp().

Signed-off-by: Andreas Färber <afaer...@suse.de>
Cc: Paolo Bonzini <pbonz...@redhat.com>
---
...
@@ -899,7 +900,13 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)
      }

      qdev_prop_set_uint8(dev, "id", apic_id);
-    qdev_prop_set_ptr(dev, "cpu_env", env);
+    object_property_set_link(OBJECT(dev), OBJECT(ENV_GET_CPU(env)), "cpu",
+                             &error);

Setting back-link should be done before or inside of x86_cpu_realize(),
i.e. no CPU internals outside of CPU object.
But that depends on CPU becoming a child of something between 
object_new(TYPE_X86_CPU)
and x86_cpu_realize(), otherwise it would crash in object_property_set_link ().

Currently it could be done in target-i386/helper.c:cpu_x86_init()but not in
hw/pc.c:pc_new_cpu() because cpu_x86_init() returns realized CPU.

Perhaps we should wait with this and previous patch till APIC is moved inside 
of CPU.

As a way to avoid back-link issue we could make CPU a child of /machine in
cpu_x86_init() before callling x86_cpu_realize(). Yes, it won't be at board 
level but it won't
hurt *-user target and might be acceptable sacrifice for i386-softmmu in effort 
of QOMifing
x86cpu and converting from qdev_prop_set_ptr() to object_property_set_link().

--
-----
 Igor



Reply via email to