tests/qdev-global-props: fixes due to machine conversion to QOM
cover tests/qdev-global-props: fixes due to machine conversion to QOM
To be applied on top of:
hw/boards: converted current_machine to be an instance of MachineClass
Rebased for qom-next branch of Andrea's QOM tree.
Patch 1: allows to assign QEMUMachine "automatically",
and not only in vl.c (we need this in tests)
Patch 2: converts "none-machine" to QOM
Patch 3: Fixes qdev-global-props by adding the "none-machine"
to the tree.
Marcel Apfelbaum (3):
hw/machine: move QEMUMachine assignment into the core machine hw/null-machine: Convert null machine to QOM tests/qdev-global-props: Manually add an instance of a QOM machine
hw/core/machine.c | 8 ++++++++ hw/core/null-machine.c | 13 +++++++++---- tests/Makefile | 2 +- tests/test-qdev-global-props.c | 3 +++ vl.c | 8 -------- 5 files changed, 21 insertions(+), 13 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/3 hw/machine: move QEMUMachine assignment into the core machine
The QemuMachine assignment into the QOM machine it is common to all machines until the conversion is over. It is not specific to vl.c .
--- hw/core/machine.c | 8 ++++++++ vl.c | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-)
hw/core/machine.c +8 -0
@@ -12,12 +12,20 @@#include "hw/boards.h" +static void machine_base_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + + mc->qemu_machine = data; +} +static const TypeInfo machine_info = { .name =TYPE_MACHINE , .parent =TYPE_OBJECT , .abstract = true, .class_size =sizeof (MachineClass), .instance_size =sizeof (MachineState), + .class_base_init = machine_base_class_init, };static void machine_register_types (void )
vl.c +0 -8
@@ -1531,19 +1531,11 @@ void pcmcia_info(Monitor *mon, const QDict *qdict)MachineState *current_machine; -static void machine_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); - - mc->qemu_machine = data; -} -int qemu_register_machine (QEMUMachine *m) {TypeInfo ti = { .name =g_strconcat (m->name,TYPE_MACHINE_SUFFIX ,NULL ), .parent =TYPE_MACHINE , - .class_init = machine_class_init, .class_data = (void *)m, };
Signature · 1 line
1.8.3.1
PATCH 3/3 tests/qdev-global-props: Manually add an instance of a QOM machine
In reply to Marcel ApfelbaumThe machine is no longer a container. Add null-machine to the QOM tree.
--- tests/Makefile | 2 +- tests/test-qdev-global-props.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
tests/Makefile +1 -1
@@ -182,7 +182,7 @@ tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o tests/test-int128$(EXESUF): tests/test-int128.o tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\ - hw/core/irq.o \ + hw/core/irq.o hw/core/machine.o hw/core/null-machine.o \ $(qom-core-obj) \ $(test-qapi-obj-y) \ libqemuutil.a libqemustub.a
tests/test-qdev-global-props.c +3 -0
@@ -170,6 +170,9 @@ int main(int argc, char **argv)type_register_static (&static_prop_type);type_register_static (&dynamic_prop_type); +object_property_add_child (object_get_root (),"machine" , +object_new ("none-machine" ), &error_abort); +g_test_add_func ("/qdev/properties/static/default" , test_static_prop);g_test_add_func ("/qdev/properties/static/global" , test_static_globalprop);g_test_add_func ("/qdev/properties/dynamic/global" , test_dynamic_globalprop);
Signature · 1 line
1.8.3.1
PATCH 2/3 hw/null-machine: Convert null machine to QOM
In reply to Marcel ApfelbaumNeeded by some tests.
--- hw/core/null-machine.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
hw/core/null-machine.c +9 -4
@@ -26,10 +26,15 @@ static QEMUMachine machine_none = { .max_cpus = 0, }; -static void register_machines (void ) +static const TypeInfo none_machine_type_info = { + .name ="none-machine" , + .parent =TYPE_MACHINE , + .class_data = (void *)&machine_none +}; + +static void none_machine_register_type (void ) { -qemu_register_machine (&machine_none); +type_register_static (&none_machine_type_info); } -machine_init (register_machines); - +type_init (none_machine_register_type)
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 2/3] hw/null-machine: Convert null machine to QOM
hw/core/null-machine.c static QEMUMachine machine_none = { · line 32
Quoted 13 lines · Marcel Apfelbaum
Needed by some tests.
Signed-off-by Marcel Apfelbaum <[email protected]>--- hw/core/null-machine.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)hw/core/null-machine.c +4
-1-static void register_machines (void ) +static const TypeInfo none_machine_type_info = { + .name ="none-machine" , + .parent =TYPE_MACHINE , + .class_data = (void *)&machine_none
Why do you need a cast to (void*) in C?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 2/3] hw/null-machine: Convert null machine to QOM
Quoted 9 lines · Eric Blake
Quoted 7 lines · Marcel Apfelbaum
Needed by some tests.
Signed-off-by Marcel Apfelbaum <[email protected]>--- hw/core/null-machine.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
Quoted 7 lines
hw/core/null-machine.c static QEMUMachine machine_none = { · line 32
Quoted 5 lines
hw/core/null-machine.c +4
-1-static void register_machines (void ) +static const TypeInfo none_machine_type_info = { + .name ="none-machine" , + .parent =TYPE_MACHINE , + .class_data = (void *)&machine_noneWhy do you need a cast to (void*) in C?
I'll take care of this, thanks!
Marcel
Quoted 1 line
Re: [Qemu-devel] [PATCH 1/3] hw/machine: move QEMUMachine assignment into the core machine
In reply to Marcel ApfelbaumQuoted 3 lines · Marcel Apfelbaum
The QemuMachine assignment into the QOM machine it is common to all machines until the conversion is over. It is not specific to
vl.c.
This also helps with the conversion of the machines to QOM:
No need to register the machines with 'machine_init()'.
Thanks,
Marcel
Quoted 45 lines
Signed-off-by Marcel Apfelbaum <[email protected]>--- hw/core/machine.c | 8 ++++++++ vl.c | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-)hw/core/machine.c +8
-0@@ -12,12 +12,20 @@#include "hw/boards.h" +static void machine_base_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + + mc->qemu_machine = data; +} +static const TypeInfo machine_info = { .name =TYPE_MACHINE , .parent =TYPE_OBJECT , .abstract = true, .class_size =sizeof (MachineClass), .instance_size =sizeof (MachineState), + .class_base_init = machine_base_class_init, };static void machine_register_types (void )vl.c +0
-5@@ -1531,19 +1531,11 @@ void pcmcia_info(Monitor *mon, const QDict *qdict)MachineState *current_machine; -static void machine_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); - - mc->qemu_machine = data;
vl.c void pcmcia_info(Monitor *mon, const QDict *qdict) · line 1540
Quoted 10 lines
vl.c +0
-3-} -int qemu_register_machine (QEMUMachine *m) {TypeInfo ti = { .name =g_strconcat (m->name,TYPE_MACHINE_SUFFIX ,NULL ), .parent =TYPE_MACHINE , - .class_init = machine_class_init, .class_data = (void *)m, };
I'll remove the casting to void* here, thanks Eric! Marcel
Quoted 1 line
Hi Marcel,
Am 11.03.2014 16:35, schrieb Marcel Apfelbaum:
Quoted 10 lines
To be applied on top of:
hw/boards: convertedcurrent_machineto be an instance of MachineClass
Rebased for qom-next branch of Andrea's QOM tree.Patch 1: allows to assign QEMUMachine "automatically",
and not only invl.c(we need this in tests)
Patch 2: converts "none-machine" to QOM
Patch 3: Fixes qdev-global-props by adding the "none-machine"
to the tree.
Quoted 6 lines
Cc Andreas Färber <[email protected]>Marcel Apfelbaum (3):
hw/machine: move QEMUMachine assignment into the core machine hw/null-machine: Convert null machine to QOM tests/qdev-global-props: Manually add an instance of a QOM machine
It seems I am to blame for most of the problems you are working around now, so let's not be too shy to correct myself and make things easier on us. ;)
I'd rather not take the class_base_init patch - for one class_init would be more correct, but for another I generally don't like putting such requirements onto use of a base class. The null machine seems indeed low hanging fruit for further cleanups - but can't we start by making MachineClass used instead of QEMUMachine? Then we won't need to assign mc->qemu_machine any more and can start dropping machine_none.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Quoted 15 lines · Andreas Färber
Hi Marcel,
Am 11.03.2014 16:35, schrieb Marcel Apfelbaum:
Quoted 12 lines
To be applied on top of:
hw/boards: convertedcurrent_machineto be an instance of MachineClass
Rebased for qom-next branch of Andrea's QOM tree.Patch 1: allows to assign QEMUMachine "automatically",
and not only invl.c(we need this in tests)
Patch 2: converts "none-machine" to QOM
Patch 3: Fixes qdev-global-props by adding the "none-machine"
to the tree.Cc Andreas Färber <[email protected]>
Quoted 8 lines
Quoted 4 lines
Marcel Apfelbaum (3):
hw/machine: move QEMUMachine assignment into the core machine hw/null-machine: Convert null machine to QOM tests/qdev-global-props: Manually add an instance of a QOM machineIt seems I am to blame for most of the problems you are working around now, so let's not be too shy to correct myself and make things easier on us. ;)
Well, I am on the "follow the rules" and not on "make the rules" stage yet, so I am trying to adapt... :)
Quoted 3 lines
I'd rather not take the
class_base_initpatch - for oneclass_initwould be more correct,
Yes, it would be, I tried it, but it didn't work :(
The code does not allow the derived class to use base's class_init function. This is the only reason I chose base_class_init.
Do you know any other way to do it? (for my personal knowledge - it seems a very handy tool)
Quoted 5 lines
but for another I generally don't like putting such requirements onto use of a base class. The null machine seems indeed low hanging fruit for further cleanups - but can't we start by making MachineClass used instead of QEMUMachine? Then we won't need to assign
mc->qemu_machineany more and can start droppingmachine_none.
This is indeed my next step after eliminating QemuOpts usage and replace it with QOM machine queries
(should be quick, the patches were reviewed once already).
Thanks,
Marcel
Quoted 4 lines
Regards,
Andreas