Message ID | 1465580427-13596-5-git-send-email-drjones@redhat.com |
---|---|
State | New |
Headers | show |
On Fri, Jun 10, 2016 at 07:40:15PM +0200, Andrew Jones wrote: > From: Igor Mammedov <imammedo@redhat.com> > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > Signed-off-by: Andrew Jones <drjones@redhat.com> I think this needs some kind of rationale. Since with this patch it is called immediately before ->init, I'm not really seeing the point of this. > --- > hw/core/machine.c | 6 ++++++ > include/hw/boards.h | 1 + > vl.c | 1 + > 3 files changed, 8 insertions(+) > > diff --git a/hw/core/machine.c b/hw/core/machine.c > index ccdd5fa3e7728..3dce9020e510a 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -368,10 +368,16 @@ static void machine_init_notify(Notifier *notifier, void *data) > foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); > } > > +static void machine_pre_init(MachineState *ms) > +{ > +} > + > static void machine_class_init(ObjectClass *oc, void *data) > { > MachineClass *mc = MACHINE_CLASS(oc); > > + mc->pre_init = machine_pre_init; > + > /* Default 128 MB as guest ram size */ > mc->default_ram_size = 128 * M_BYTE; > mc->rom_file_has_mr = true; > diff --git a/include/hw/boards.h b/include/hw/boards.h > index d268bd00a9f7d..4e8dc68b07a24 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -92,6 +92,7 @@ struct MachineClass { > const char *alias; > const char *desc; > > + void (*pre_init)(MachineState *state); > void (*init)(MachineState *state); > void (*reset)(void); > void (*hot_add_cpu)(const int64_t id, Error **errp); > diff --git a/vl.c b/vl.c > index 8d482cb1bf020..4849dd465d667 100644 > --- a/vl.c > +++ b/vl.c > @@ -4500,6 +4500,7 @@ int main(int argc, char **argv, char **envp) > current_machine->boot_order = boot_order; > current_machine->cpu_model = cpu_model; > > + machine_class->pre_init(current_machine); > machine_class->init(current_machine); > > realtime_init();
On Tue, Jun 14, 2016 at 11:30:37AM +1000, David Gibson wrote: > On Fri, Jun 10, 2016 at 07:40:15PM +0200, Andrew Jones wrote: > > From: Igor Mammedov <imammedo@redhat.com> > > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > > Signed-off-by: Andrew Jones <drjones@redhat.com> > > I think this needs some kind of rationale. > > Since with this patch it is called immediately before ->init, I'm not > really seeing the point of this. Many machines already override ->init, so if we want to move code from vl.c into machine methods, but be sure that they run it now, then we have to invent a pre-init. I (or Igor) can add something like that to the commit message for the next round. Thanks, drew > > > --- > > hw/core/machine.c | 6 ++++++ > > include/hw/boards.h | 1 + > > vl.c | 1 + > > 3 files changed, 8 insertions(+) > > > > diff --git a/hw/core/machine.c b/hw/core/machine.c > > index ccdd5fa3e7728..3dce9020e510a 100644 > > --- a/hw/core/machine.c > > +++ b/hw/core/machine.c > > @@ -368,10 +368,16 @@ static void machine_init_notify(Notifier *notifier, void *data) > > foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); > > } > > > > +static void machine_pre_init(MachineState *ms) > > +{ > > +} > > + > > static void machine_class_init(ObjectClass *oc, void *data) > > { > > MachineClass *mc = MACHINE_CLASS(oc); > > > > + mc->pre_init = machine_pre_init; > > + > > /* Default 128 MB as guest ram size */ > > mc->default_ram_size = 128 * M_BYTE; > > mc->rom_file_has_mr = true; > > diff --git a/include/hw/boards.h b/include/hw/boards.h > > index d268bd00a9f7d..4e8dc68b07a24 100644 > > --- a/include/hw/boards.h > > +++ b/include/hw/boards.h > > @@ -92,6 +92,7 @@ struct MachineClass { > > const char *alias; > > const char *desc; > > > > + void (*pre_init)(MachineState *state); > > void (*init)(MachineState *state); > > void (*reset)(void); > > void (*hot_add_cpu)(const int64_t id, Error **errp); > > diff --git a/vl.c b/vl.c > > index 8d482cb1bf020..4849dd465d667 100644 > > --- a/vl.c > > +++ b/vl.c > > @@ -4500,6 +4500,7 @@ int main(int argc, char **argv, char **envp) > > current_machine->boot_order = boot_order; > > current_machine->cpu_model = cpu_model; > > > > + machine_class->pre_init(current_machine); > > machine_class->init(current_machine); > > > > realtime_init(); > > -- > 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
On Tue, Jun 14, 2016 at 07:58:56AM +0200, Andrew Jones wrote: > On Tue, Jun 14, 2016 at 11:30:37AM +1000, David Gibson wrote: > > On Fri, Jun 10, 2016 at 07:40:15PM +0200, Andrew Jones wrote: > > > From: Igor Mammedov <imammedo@redhat.com> > > > > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > > > Signed-off-by: Andrew Jones <drjones@redhat.com> > > > > I think this needs some kind of rationale. > > > > Since with this patch it is called immediately before ->init, I'm not > > really seeing the point of this. > > Many machines already override ->init, so if we want to move code > from vl.c into machine methods, but be sure that they run it now, > then we have to invent a pre-init. I (or Igor) can add something > like that to the commit message for the next round. If we just want to move vl.c code into machine, why not just create a simple machine_pre_init() function? We can add a virtual method that can be reimplemented by subclasses later, only when we really see the need for a subclass to override some behavior.
On Thu, Jul 14, 2016 at 05:10:47PM -0300, Eduardo Habkost wrote: > On Tue, Jun 14, 2016 at 07:58:56AM +0200, Andrew Jones wrote: > > On Tue, Jun 14, 2016 at 11:30:37AM +1000, David Gibson wrote: > > > On Fri, Jun 10, 2016 at 07:40:15PM +0200, Andrew Jones wrote: > > > > From: Igor Mammedov <imammedo@redhat.com> > > > > > > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > > > > Signed-off-by: Andrew Jones <drjones@redhat.com> > > > > > > I think this needs some kind of rationale. > > > > > > Since with this patch it is called immediately before ->init, I'm not > > > really seeing the point of this. > > > > Many machines already override ->init, so if we want to move code > > from vl.c into machine methods, but be sure that they run it now, > > then we have to invent a pre-init. I (or Igor) can add something > > like that to the commit message for the next round. > > If we just want to move vl.c code into machine, why not just > create a simple machine_pre_init() function? > > We can add a virtual method that can be reimplemented by > subclasses later, only when we really see the need for a subclass > to override some behavior. That's fine for this series. Of course one of the main motivators of this series is to be able to override the old parsing though, so I already see the need. I'll need to either add this method now, or later, when I add cpu topo support to the ARM mach-virt machine type. Thanks, drew > > -- > Eduardo >
diff --git a/hw/core/machine.c b/hw/core/machine.c index ccdd5fa3e7728..3dce9020e510a 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -368,10 +368,16 @@ static void machine_init_notify(Notifier *notifier, void *data) foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); } +static void machine_pre_init(MachineState *ms) +{ +} + static void machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); + mc->pre_init = machine_pre_init; + /* Default 128 MB as guest ram size */ mc->default_ram_size = 128 * M_BYTE; mc->rom_file_has_mr = true; diff --git a/include/hw/boards.h b/include/hw/boards.h index d268bd00a9f7d..4e8dc68b07a24 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -92,6 +92,7 @@ struct MachineClass { const char *alias; const char *desc; + void (*pre_init)(MachineState *state); void (*init)(MachineState *state); void (*reset)(void); void (*hot_add_cpu)(const int64_t id, Error **errp); diff --git a/vl.c b/vl.c index 8d482cb1bf020..4849dd465d667 100644 --- a/vl.c +++ b/vl.c @@ -4500,6 +4500,7 @@ int main(int argc, char **argv, char **envp) current_machine->boot_order = boot_order; current_machine->cpu_model = cpu_model; + machine_class->pre_init(current_machine); machine_class->init(current_machine); realtime_init();