On Mon, 15 Apr 2013 17:38:51 +0200 Andreas Färber <afaer...@suse.de> wrote:
> Am 11.04.2013 16:51, schrieb Igor Mammedov: > > ... during startup, so it would be possible to uplug it later > > unplug? CPU won't be unplug-able if it's not on ICC bus. > > > and set bus_type to TYPE_ICC_BUS for X86CPU type to make device_add > > attach hotplugged CPU to ICC bus. > > > > Signed-off-by: Igor Mammedov <imamm...@redhat.com> > > --- > > target-i386/cpu.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > > index 4ddc18a..2bb38d6 100644 > > --- a/target-i386/cpu.c > > +++ b/target-i386/cpu.c > > @@ -41,6 +41,7 @@ > > #endif > > > > #include "sysemu/sysemu.h" > > +#include "hw/i386/icc_bus.h" > > #ifndef CONFIG_USER_ONLY > > #include "hw/xen/xen.h" > > #include "hw/sysbus.h" > > @@ -1610,6 +1611,7 @@ X86CPU *cpu_x86_create(const char *cpu_model, Error > > **errp) gchar **model_pieces; > > char *name, *features; > > Error *error = NULL; > > + Object *icc_bus = object_resolve_path_type("icc-bus", TYPE_ICC_BUS, > > NULL); > > model_pieces = g_strsplit(cpu_model, ",", 2); > > if (!model_pieces[0]) { > > @@ -1620,6 +1622,10 @@ X86CPU *cpu_x86_create(const char *cpu_model, > > Error **errp) features = model_pieces[1]; > > > > cpu = X86_CPU(object_new(TYPE_X86_CPU)); > > + if (icc_bus) { > > + qdev_set_parent_bus(DEVICE(cpu), BUS(icc_bus)); > > + object_unref(OBJECT(cpu)); > > Why are you unref'ing here? (Paolo?) To leave only one reference to it since qdev_set_parent_bus() just incremented it. Like it's done in qdev_try_create(). > > > + } > > env = &cpu->env; > > env->cpu_model_str = cpu_model; > > > > > @@ -2330,6 +2336,7 @@ static void x86_cpu_common_class_init(ObjectClass > > *oc, void *data) > > xcc->parent_realize = dc->realize; > > dc->realize = x86_cpu_realizefn; > > + dc->bus_type = TYPE_ICC_BUS; > > > > xcc->parent_reset = cc->reset; > > cc->reset = x86_cpu_reset; > > I was relieved when I recently saw this was all the magic required to > put it onto the new ICC bus. I thought we'd need to mess with ICCDevice > base classes, but that seems to be used for APIC and IOAPIC only. > > Andreas >