qemu-machine as a QOM object
v3 cover qemu-machine as a QOM object
RFC V2 -> V3
Split the series into two parts, because the first part can be submitted as was already accepted (after this review).
- The second part involves the replacement of machine opts queries with QOM queries and I will resend it separately.
Addressed Andreas Färber's comments:
- Dropped the Qemu prefix everywhere
- Coding style issues (I really hope I got them all!)
- machine class:' -machine' sufix instead of 'machine-' prefix
- Regarding replacement of the init order machine_init/type_init:
- I answered on the mail thread that I saw no issues.
- I also stated there that I think that type_init should be before machine_init because the later is using the QOM subsystem.
Addressed Paolo Bonzini's comments:
- Added the current_machine to the QOM tree as '/machine'.
- Passed current_machine->init_args to machine->init.
- I will continue the series following his suggestions (Thanks!).
RFC v1 -> RFC v2
Replaced QemuOpts access by QOM queries. (The main addition)
Addressed Paolo Bonzini's comments:
- Eliminated duplicate fields (of QEMUMachineInitArgs and QemuMachineState) I am not sure about this one, it does mess with the "const" usage. Maybe delay this duplication removal until after QEMUMachineInitArgs disappears completely?
- Added "machine-" prefix to QOM machine type.
- An instance of QEMUMachineInitArgs os is used by QemuMachineState and not a pointer.
The main benefit of QOMifying the qemu machine would be the possibility to have options per machine type and not global.
However, there are other benefits as:
- accessing qemu object properties instead of a global QemuOpts list from different code subsystems.
- improving the machine "initialization" code (compat and stuff)
- getting more close to QOM's vision of single interface for device creation and so on.
Basically the series aims (in the long run) to convert:
QEMUMachine -> MachineClass
QEMUMachineInitArgs -> MachineState.As a first step, in order to make possible an incremental development, both QEMUMachine and QEMUMachineInitArgs are being embedded into the new types.
Marcel Apfelbaum (3):
hw/core: introduced qemu machine as QOM object
vl: use qemu machine QOM class instead of global machines list hw/boards: converted current_machine to be an instance of MachineCLass
device-hotplug.c | 4 +- hw/core/Makefile.objs | 2 +- hw/core/machine.c | 28 ++++++++++++ include/hw/boards.h | 58 +++++++++++++++++++++++- qmp.c | 7 ++- vl.c | 121 ++++++++++++++++++++++++++++++++++---------------- 6 files changed, 176 insertions(+), 44 deletions(-) create mode 100644 hw/core/machine.c
Signature · 1 line
1.8.3.1
PATCH v3 1/3 hw/core: introduced qemu machine as QOM object
The main functionality change is to convert QEMUMachine into MachineClass and QEMUMachineInitArgs into MachineState, instance of MachineClass.
As a first step, in order to make possible an incremental development, both QEMUMachine and QEMUMachineInitArgs are being embedded into the new types.
--- hw/core/Makefile.objs | 2 +- hw/core/machine.c | 28 +++++++++++++++++++++++++++ include/hw/boards.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 hw/core/machine.c
hw/core/Makefile.objs +1 -1
@@ -8,7 +8,7 @@ common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o common-obj-$(CONFIG_XILINX_AXI) += stream.o common-obj-$(CONFIG_PTIMER) += ptimer.o common-obj-$(CONFIG_SOFTMMU) += sysbus.o +common-obj-$(CONFIG_SOFTMMU) += machine.o common-obj-$(CONFIG_SOFTMMU) += null-machine.o common-obj-$(CONFIG_SOFTMMU) += loader.o common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o -
hw/core/machine.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* QEMU Machine +* +* Copyright (C) 2014 Red Hat Inc +* +* Authors: +* Marcel Apfelbaum <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "hw/boards.h" + +static const TypeInfo machine_info = { + .name =TYPE_MACHINE , + .parent =TYPE_OBJECT , + .abstract = true, + .class_size =sizeof (MachineClass), + .instance_size =sizeof (MachineState), +}; + +static void machine_register_types (void ) +{ +type_register_static (&machine_info); +} + +type_init (machine_register_types)
include/hw/boards.h +53 -0
63 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Andreas Färber
AppliedRe: [Qemu-devel] [PATCH v3 1/3] hw/core: introduced qemu machine as QOM object
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 82 lines
The main functionality change is to convert QEMUMachine into MachineClass and QEMUMachineInitArgs into MachineState, instance of MachineClass.
As a first step, in order to make possible an incremental development, both QEMUMachine and QEMUMachineInitArgs are being embedded into the new types.
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Marcel Apfelbaum <[email protected]>--- hw/core/Makefile.objs | 2 +- hw/core/machine.c | 28 +++++++++++++++++++++++++++ include/hw/boards.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 hw/core/machine.chw/core/Makefile.objs +1
-1@@ -8,7 +8,7 @@ common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o common-obj-$(CONFIG_XILINX_AXI) += stream.o common-obj-$(CONFIG_PTIMER) += ptimer.o common-obj-$(CONFIG_SOFTMMU) += sysbus.o +common-obj-$(CONFIG_SOFTMMU) += machine.o common-obj-$(CONFIG_SOFTMMU) += null-machine.o common-obj-$(CONFIG_SOFTMMU) += loader.o common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o -hw/core/machine.c new file +28
-0@@ -0,0 +1,28 @@ +/* +* QEMU Machine +* +* Copyright (C) 2014 Red Hat Inc +* +* Authors: +* Marcel Apfelbaum <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "hw/boards.h" + +static const TypeInfo machine_info = { + .name =TYPE_MACHINE , + .parent =TYPE_OBJECT , + .abstract = true, + .class_size =sizeof (MachineClass), + .instance_size =sizeof (MachineState), +}; + +static void machine_register_types (void ) +{ +type_register_static (&machine_info); +} + +type_init (machine_register_types)include/hw/boards.h +4
-0@@ -5,6 +5,7 @@#include "sysemu/blockdev.h" #include "hw/qdev.h" +#include "qom/object.h" typedef struct QEMUMachine QEMUMachine ;@@ -53,4 +54,56 @@ QEMUMachine *find_default_machine(void);extern QEMUMachine *current_machine; +#define TYPE_MACHINE "machine" +#define MACHINE (obj) \ + OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE)
include/hw/boards.h QEMUMachine *find_default_machine(void); · line 69
Quoted 10 lines
include/hw/boards.h +10
-0+#define MACHINE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE) +#define MACHINE_CLASS (klass) \ + OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE) + +typedef struct MachineState MachineState ; +typedef struct MachineClass MachineClass ; + +/** +* @MachineClass
"MachineClass:"
include/hw/boards.h QEMUMachine *find_default_machine(void); · line 75
Quoted 6 lines
include/hw/boards.h +6
-0+* +* @parent_class: opaque parent class container +*/ +struct MachineClass { +/*< private >*/ +ObjectClass parent_class;
The very purpose of < private > is to suppress this field from documentation, so you don't need to document it.
Quoted 24 lines
include/hw/boards.h +24
-0+/*< public >*/ + +QEMUMachine *qemu_machine; +}; + +/** +* @MachineState +* +* @parent_obj: opaque parent object container +*/ +struct MachineState { +/*< private >*/ +Object parent_obj; +/*< public >*/ + +char *accel; +bool kernel_irqchip; +int kvm_shadow_mem; +char *kernel; +char *initrd; +char *append; +char *dtb; +char *dumpdtb; +int phandle_start;
include/hw/boards.h QEMUMachine *find_default_machine(void); · line 109
Quoted 10 lines
include/hw/boards.h +9
-0+char *dt_compatible; +bool dump_guest_core; +bool mem_merge; +bool usb; +char *firmware; + + QEMUMachineInitArgs init_args; +}; +#endif
Thanks, applied to qom-next with gtk-doc changes:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Andreas
include/hw/boards.h +3 -6
@@ -66,9 +66,8 @@ typedef struct MachineState MachineState;typedef struct MachineClass MachineClass ;/** -* @MachineClass -* -* @parent_class: opaque parent class container +* MachineClass: +* @qemu_machine: #QEMUMachine */ struct MachineClass {/*< private >*/
@@ -79,9 +78,7 @@ struct MachineClass { };/** -* @MachineState -* -* @parent_obj: opaque parent object container +* MachineState: */ struct MachineState {/*< private >*/
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
Re: [Qemu-devel] [PATCH v3 1/3] hw/core: introduced qemu machine as QOM object
In reply to Marcel ApfelbaumAm 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 12 lines
include/hw/boards.h +12
-0+struct MachineState { +/*< private >*/ +Object parent_obj; +/*< public >*/ + +char *accel; +bool kernel_irqchip; +int kvm_shadow_mem; +char *kernel; +char *initrd; +char *append; +char *dtb;
include/hw/boards.h QEMUMachine *find_default_machine(void); · line 107
Quoted 10 lines
include/hw/boards.h +10
-0+char *dumpdtb; +int phandle_start; +char *dt_compatible; +bool dump_guest_core; +bool mem_merge; +bool usb; +char *firmware; + +QEMUMachineInitArgs init_args; +};
If I'm reading directly, init_args is the only field used in this 3-patch series. Should we drop the unused ones for now? Or do you think we should get the whole conversion done for 2.0 and therefore keep them?
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
PATCH v3 2/3 vl: use qemu machine QOM class instead of global machines list
In reply to Marcel ApfelbaumThe machine registration flow is refactored to use the QOM functionality. Instead of linking the machines into a list, each machine has a type and the types can be traversed in the QOM way.
--- include/hw/boards.h | 1 + vl.c | 75 ++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 55 insertions(+), 21 deletions(-)
include/hw/boards.h +1 -0
@@ -49,6 +49,7 @@ struct QEMUMachine {const char *hw_version; }; +#define TYPE_MACHINE_SUFFIX "-machine"int qemu_register_machine (QEMUMachine *m);QEMUMachine *find_default_machine (void );
vl.c +54 -21
133 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Andreas Färber
AppliedRe: [Qemu-devel] [PATCH v3 2/3] vl: use qemu machine QOM class instead of global machines list
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 6 lines
The machine registration flow is refactored to use the QOM functionality. Instead of linking the machines into a list, each machine has a type and the types can be traversed in the QOM way.
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Marcel Apfelbaum <[email protected]>
Thanks, applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
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
PATCH v3 3/3 hw/boards: converted current_machine to be an instance of MachineCLass
In reply to Marcel ApfelbaumIn order to allow attaching machine options to a machine instance, current_machine is converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.
--- device-hotplug.c | 4 ++- include/hw/boards.h | 6 ++--- qmp.c | 7 ++++-- vl.c | 72 +++++++++++++++++++++++++++++++---------------------- 4 files changed, 53 insertions(+), 36 deletions(-)
device-hotplug.c +3 -1
@@ -33,12 +33,14 @@ DriveInfo *add_init_drive(const char *optstr) {DriveInfo *dinfo;QemuOpts *opts; +MachineClass *mc; opts =drive_def (optstr);if (!opts)return NULL ; - dinfo =drive_init (opts, current_machine->block_default_type); + mc =MACHINE_GET_CLASS (current_machine); + dinfo =drive_init (opts, mc->qemu_machine->block_default_type);if (!dinfo) {qemu_opts_del (opts);return NULL ;
include/hw/boards.h +3 -3
@@ -51,9 +51,6 @@ struct QEMUMachine {#define TYPE_MACHINE_SUFFIX "-machine"int qemu_register_machine (QEMUMachine *m); -QEMUMachine *find_default_machine (void ); - -extern QEMUMachine *current_machine;#define TYPE_MACHINE "machine"#define MACHINE (obj) \
@@ -66,6 +63,9 @@ extern QEMUMachine *current_machine;typedef struct MachineState MachineState ;typedef struct MachineClass MachineClass ; +MachineClass *find_default_machine (void ); +extern MachineState *current_machine; +/** * @MachineClass *
qmp.c +5 -2
@@ -114,8 +114,11 @@ void qmp_cpu(int64_t index, Error **errp)void qmp_cpu_add (int64_t id,Error **errp) { -if (current_machine->hot_add_cpu) { - current_machine->hot_add_cpu (id, errp); +MachineClass *mc; + + mc =MACHINE_GET_CLASS (current_machine); +if (mc->qemu_machine->hot_add_cpu) { + mc->qemu_machine->hot_add_cpu (id, errp); }else {error_setg (errp,"Not supported" ); }
vl.c +42 -30
175 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
Quoted 4 lines · Marcel Apfelbaum
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.
s/MachineCLass/MachineClass/ here and in subject
Quoted 3 lines
Signed-off-by Marcel Apfelbaum <[email protected]>---
I'll leave the actual review to others, just pointing out the typo.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
Quoted 7 lines · Eric Blake
Quoted 4 lines · Marcel Apfelbaum
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.s/MachineCLass/MachineClass/ here and in subject
Thanks, I'll take care of it
Marcel
Quoted 7 lines
Quoted 4 lines
Signed-off-by Marcel Apfelbaum <[email protected]>---
I'll leave the actual review to others, just pointing out the typo.
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
In reply to Marcel ApfelbaumAm 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 6 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.Signed-off-by Marcel Apfelbaum <[email protected]>
Looks mostly good, but same issue as Alexey's patch: We are risking qdev_get_machine() creating a Container-typed /machine node.
What about the following on top?
Alexey, if we reach agreement here, this means for you that we can just use type_register_static() in place of qemu_machine_register() to register your custom machine type with interface added.
Regards,
Andreas
hw/core/qdev.c +2 -1
@@ -861,7 +861,8 @@ Object *qdev_get_machine(void)static Object *dev;if (dev ==NULL ) { - dev =container_get (object_get_root (),"/machine" ); + dev =object_resolve_path ("/machine" ,NULL ); +g_assert (dev); }return dev;
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
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
Quoted 10 lines · Andreas Färber
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 6 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.Signed-off-by Marcel Apfelbaum <[email protected]>Looks mostly good, but same issue as Alexey's patch: We are risking
qdev_get_machine()creating a Container-typed /machine node.
Sorry, I am not following you here. object_resolve_path() can create objects?
Quoted 5 lines
What about the following on top?
Alexey, if we reach agreement here, this means for you that we can just use
type_register_static()in place ofqemu_machine_register()to register your custom machine type with interface added.
I am perfectly fine with that, I just do not see what difference does it make and why do you still keep qemu_machine_register() (or this is in the plan already?)?
Quoted 19 lines
Regards,
Andreashw/core/qdev.c +2
-1@@ -861,7 +861,8 @@ Object *qdev_get_machine(void)static Object *dev;if (dev ==NULL ) { - dev =container_get (object_get_root (),"/machine" ); + dev =object_resolve_path ("/machine" ,NULL ); +g_assert (dev); }return dev;
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
Quoted 7 lines · Alexey Kardashevskiy
Quoted 6 lines · Andreas Färber
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 5 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Marcel Apfelbaum <[email protected]>Looks mostly good, but same issue as Alexey's patch: We are risking
qdev_get_machine()creating a Container-typed /machine node.Sorry, I am not following you here.
object_resolve_path()can create objects?
Hi Alexey,
No, object_resolve_path() does not create objects, the point is that the machine is created before, you only need to get it. You don't want to risk creating a container.
Quoted 11 lines
Quoted 7 lines
What about the following on top?
Alexey, if we reach agreement here, this means for you that we can just use
type_register_static()in place ofqemu_machine_register()to register your custom machine type with interface added.I am perfectly fine with that, I just do not see what difference does it make and why do you still keep
qemu_machine_register()(or this is in the plan already?)?
It is in my plan to eliminate qemu_machine_register(), however it will take some time as it includes making changes to lots of files. For the moment, subclassing MachineClass and registering it to QOM will be exactly like calling qemu_machine_register().
Thanks,
Marcel
Quoted 24 lines
Quoted 22 lines
Regards,
Andreashw/core/qdev.c +2
-1@@ -861,7 +861,8 @@ Object *qdev_get_machine(void)static Object *dev;if (dev ==NULL ) { - dev =container_get (object_get_root (),"/machine" ); + dev =object_resolve_path ("/machine" ,NULL ); +g_assert (dev); }return dev;
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
In reply to Andreas FärberQuoted 6 lines · Andreas Färber
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 5 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.
Quoted 6 lines
Quoted 1 line
Signed-off-by Marcel Apfelbaum <[email protected]>Looks mostly good, but same issue as Alexey's patch: We are risking
qdev_get_machine()creating a Container-typed /machine node.What about the following on top?
Hi Andreas,
I checked with the debugger and qdev_get_machine is called long after we add the machine to the QOM tree.
However, the race still exists as someone can call qdev_get_machine before the machine is added to the tree, not being aware of that.
Your change solves the problem, thank you!
Do you want me to add this diff and resend,
or I will send yours separately?
Thanks,
Marcel
Quoted 24 lines
Alexey, if we reach agreement here, this means for you that we can just use
type_register_static()in place ofqemu_machine_register()to register your custom machine type with interface added.Regards,
Andreashw/core/qdev.c +2
-1@@ -861,7 +861,8 @@ Object *qdev_get_machine(void)static Object *dev;if (dev ==NULL ) { - dev =container_get (object_get_root (),"/machine" ); + dev =object_resolve_path ("/machine" ,NULL ); +g_assert (dev); }return dev;
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
Am 07.03.2014 06:32, schrieb Marcel Apfelbaum:
Quoted 15 lines · Andreas Färber
Quoted 6 lines
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 5 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.Quoted 6 lines
Quoted 1 line
Signed-off-by Marcel Apfelbaum <[email protected]>Looks mostly good, but same issue as Alexey's patch: We are risking
qdev_get_machine()creating a Container-typed /machine node.What about the following on top?
Hi Andreas,
Quoted 8 lines
I checked with the debugger and
qdev_get_machineis called long after we add the machine to the QOM tree.
However, the race still exists as someone can callqdev_get_machinebefore the machine is added to the tree, not being aware of that.Your change solves the problem, thank you!
Do you want me to add this diff and resend,
or I will send yours separately?
My preference would be to avoid another round of review on my part by simply squashing into your 3/3.
Cheers,
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
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
Quoted 21 lines · Andreas Färber
Am 07.03.2014 06:32, schrieb Marcel Apfelbaum:
Quoted 20 lines · Andreas Färber
Quoted 6 lines
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 5 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.Quoted 6 lines
Quoted 1 line
Signed-off-by Marcel Apfelbaum <[email protected]>Looks mostly good, but same issue as Alexey's patch: We are risking
qdev_get_machine()creating a Container-typed /machine node.What about the following on top?
Hi Andreas,
I checked with the debugger and
qdev_get_machineis called long after we add the machine to the QOM tree.
However, the race still exists as someone can callqdev_get_machinebefore the machine is added to the tree, not being aware of that.
Quoted 6 lines
Quoted 3 lines
Your change solves the problem, thank you!
Do you want me to add this diff and resend,
or I will send yours separately?My preference would be to avoid another round of review on my part by simply squashing into your 3/3.
There is a problem with it: 'make check fails' on test-qdev-global-props.
- 'qdev_get_machine()' is called by 'device_set_realized()' because static_prop_type has TYPE_DEVICE as parent.
- The machine is added to the QOM tree *only in vl's main* and this test does not reach it, but assumes that always will be a machine in the QOM tree. This is no longer true.
Possible solution would be making existing 'null machine' a subclass of MachineClass and add it manually to QOM on this test(and other places as necessary). The risk here is that there are other places where the machine needs to be added manually to the QOM tree. (I am trying this option, but make check gets stuck !!!, debugging)
Other possible solution is to add some kind of "CONFIG_MACHINE_IS_QOM_OBJECT" define and use this in qdev_get_machine() implementation. (ugly?)
Finally, is possible to be aware that may be a race when doing code review. ("dangerous"?)
Any thoughts?
Thanks,
Marcel
Quoted 4 lines
Cheers,
Andreas
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
Il 07/03/2014 17:22, Marcel Apfelbaum ha scritto:
Quoted 11 lines
There is a problem with it: 'make check fails' on test-qdev-global-props.
- 'qdev_get_machine()' is called by 'device_set_realized()' becausestatic_prop_typehasTYPE_DEVICEas parent.
- The machine is added to the QOM tree *only in vl's main* and this test does not reach it, but assumes that always will be a machine in the QOM tree. This is no longer true.Possible solution would be making existing 'null machine' a subclass of MachineClass and add it manually to QOM on this test(and other places as necessary). The risk here is that there are other places where the machine needs to be added manually to the QOM tree. (I am trying this option, but make check gets stuck !!!, debugging)
This is probably the right thing to do, but I guess it means it's better to leave this series to 2.1.
Paolo
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
In reply to Marcel ApfelbaumAm 07.03.2014 17:22, schrieb Marcel Apfelbaum:
Quoted 35 lines · Andreas Färber
Quoted 21 lines
Am 07.03.2014 06:32, schrieb Marcel Apfelbaum:
Quoted 20 lines · Andreas Färber
Quoted 6 lines
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 5 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.Quoted 6 lines
Quoted 1 line
Signed-off-by Marcel Apfelbaum <[email protected]>Looks mostly good, but same issue as Alexey's patch: We are risking
qdev_get_machine()creating a Container-typed /machine node.What about the following on top?
Hi Andreas,
I checked with the debugger and
qdev_get_machineis called long after we add the machine to the QOM tree.
However, the race still exists as someone can callqdev_get_machinebefore the machine is added to the tree, not being aware of that.Quoted 6 lines
Quoted 3 lines
Your change solves the problem, thank you!
Do you want me to add this diff and resend,
or I will send yours separately?My preference would be to avoid another round of review on my part by simply squashing into your 3/3.
There is a problem with it: 'make check fails' on test-qdev-global-props.
- 'qdev_get_machine()' is called by 'device_set_realized()' becausestatic_prop_typehasTYPE_DEVICEas parent.
- The machine is added to the QOM tree *only in vl's main* and this test does not reach it, but assumes that always will be a machine in the QOM tree. This is no longer true.
Quoted 2 lines
Possible solution would be making existing 'null machine' a subclass of MachineClass and add it manually to QOM on this test(and other places as necessary).
The following hack fixes this particular failure for me (ran into it while trying to generate the HTML report):
tests/test-qdev-global-props.c +2 -0
@@ -167,6 +167,9 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );module_call_init (MODULE_INIT_QOM ); + + object_property_add_child(object_get_root(), "machine",
object_new("container"), NULL);
+
type_register_static(&static_prop_type);
type_register_static(&dynamic_prop_type);Not yet suitable for squashing obviously.
Andreas
Quoted 22 lines
The risk here is
that there are other places where the machine needs to be added manually to the QOM tree. (I am trying this option, but make check gets stuck !!!, debugging)Other possible solution is to add some kind of "
CONFIG_MACHINE_IS_QOM_OBJECT" define and use this inqdev_get_machine()implementation. (ugly?)Finally, is possible to be aware that may be a race when doing code review. ("dangerous"?)
Any thoughts?
Thanks,
MarcelQuoted 4 lines
Cheers,
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
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
Quoted 47 lines · Andreas Färber
Am 07.03.2014 17:22, schrieb Marcel Apfelbaum:
Quoted 35 lines · Andreas Färber
Quoted 21 lines
Am 07.03.2014 06:32, schrieb Marcel Apfelbaum:
Quoted 20 lines · Andreas Färber
Quoted 6 lines
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 5 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.Quoted 6 lines
Quoted 1 line
Signed-off-by Marcel Apfelbaum <[email protected]>Looks mostly good, but same issue as Alexey's patch: We are risking
qdev_get_machine()creating a Container-typed /machine node.What about the following on top?
Hi Andreas,
I checked with the debugger and
qdev_get_machineis called long after we add the machine to the QOM tree.
However, the race still exists as someone can callqdev_get_machinebefore the machine is added to the tree, not being aware of that.Quoted 6 lines
Quoted 3 lines
Your change solves the problem, thank you!
Do you want me to add this diff and resend,
or I will send yours separately?My preference would be to avoid another round of review on my part by simply squashing into your 3/3.
There is a problem with it: 'make check fails' on test-qdev-global-props.
- 'qdev_get_machine()' is called by 'device_set_realized()' becausestatic_prop_typehasTYPE_DEVICEas parent.
- The machine is added to the QOM tree *only in vl's main* and this test does not reach it, but assumes that always will be a machine in the QOM tree. This is no longer true.Quoted 2 lines
Possible solution would be making existing 'null machine' a subclass of MachineClass and add it manually to QOM on this test(and other places as necessary).
The following hack fixes this particular failure for me (ran into it while trying to generate the HTML report):
tests/test-qdev-global-props.c +0
-0
tests/test-qdev-global-props.c int main(int argc, char **argv) · line 173
Quoted 7 lines
tests/test-qdev-global-props.c +3
-0@@ -167,6 +167,9 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );module_call_init (MODULE_INIT_QOM ); + +object_property_add_child (object_get_root (),"machine" ,object_new ("container" ),NULL ); +
Great! Thanks! I was trying to create a null-machine, but for this scenario a container is more than enough.
Quoted 5 lines
tests/test-qdev-global-props.c +0
-0type_register_static (&static_prop_type);type_register_static (&dynamic_prop_type);Not yet suitable for squashing obviously.
I tested it and make check passes for all architectures, so why not? It seems elegant and not a hack (this scenario does not require an actual machine).
Thanks,
Marcel
Quoted 27 lines
Andreas
Quoted 22 lines
The risk here is
that there are other places where the machine needs to be added manually to the QOM tree. (I am trying this option, but make check gets stuck !!!, debugging)Other possible solution is to add some kind of "
CONFIG_MACHINE_IS_QOM_OBJECT" define and use this inqdev_get_machine()implementation. (ugly?)Finally, is possible to be aware that may be a race when doing code review. ("dangerous"?)
Any thoughts?
Thanks,
MarcelQuoted 4 lines
Cheers,
Andreas
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
In reply to Andreas FärberQuoted 58 lines · Andreas Färber
Am 07.03.2014 17:22, schrieb Marcel Apfelbaum:
Quoted 35 lines · Andreas Färber
Quoted 21 lines
Am 07.03.2014 06:32, schrieb Marcel Apfelbaum:
Quoted 20 lines · Andreas Färber
Quoted 6 lines
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 5 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.Quoted 6 lines
Quoted 1 line
Signed-off-by Marcel Apfelbaum <[email protected]>Looks mostly good, but same issue as Alexey's patch: We are risking
qdev_get_machine()creating a Container-typed /machine node.What about the following on top?
Hi Andreas,
I checked with the debugger and
qdev_get_machineis called long after we add the machine to the QOM tree.
However, the race still exists as someone can callqdev_get_machinebefore the machine is added to the tree, not being aware of that.Quoted 6 lines
Quoted 3 lines
Your change solves the problem, thank you!
Do you want me to add this diff and resend,
or I will send yours separately?My preference would be to avoid another round of review on my part by simply squashing into your 3/3.
There is a problem with it: 'make check fails' on test-qdev-global-props.
- 'qdev_get_machine()' is called by 'device_set_realized()' becausestatic_prop_typehasTYPE_DEVICEas parent.
- The machine is added to the QOM tree *only in vl's main* and this test does not reach it, but assumes that always will be a machine in the QOM tree. This is no longer true.Quoted 2 lines
Possible solution would be making existing 'null machine' a subclass of MachineClass and add it manually to QOM on this test(and other places as necessary).
The following hack fixes this particular failure for me (ran into it while trying to generate the HTML report):
tests/test-qdev-global-props.c +3
-0@@ -167,6 +167,9 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );module_call_init (MODULE_INIT_QOM ); + +object_property_add_child (object_get_root (),"machine" ,object_new ("container" ),NULL ); +type_register_static (&static_prop_type);type_register_static (&dynamic_prop_type);
Quoted 1 line
Not yet suitable for squashing obviously.
Hi Andreas,
I found the reason why the 'make check' is getting stuck, it was related to a bug in qtest library. I posted a patch that fixes this:
[PATCH V4] tests/libqtest: Fix possible deadlock in qtest initialization
I saw that you already squashed "object_resolve_path" into qdev_get_machine. I just sent
[PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM
which takes care of the 'make check' failures.
I think is OK now.
Thanks,
Marcel
Quoted 27 lines
Andreas
Quoted 22 lines
The risk here is
that there are other places where the machine needs to be added manually to the QOM tree. (I am trying this option, but make check gets stuck !!!, debugging)Other possible solution is to add some kind of "
CONFIG_MACHINE_IS_QOM_OBJECT" define and use this inqdev_get_machine()implementation. (ugly?)Finally, is possible to be aware that may be a race when doing code review. ("dangerous"?)
Any thoughts?
Thanks,
MarcelQuoted 4 lines
Cheers,
Andreas
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
In reply to Marcel ApfelbaumAm 07.03.2014 17:22, schrieb Marcel Apfelbaum:
Quoted 26 lines · Andreas Färber
Quoted 25 lines
Am 07.03.2014 06:32, schrieb Marcel Apfelbaum:
Quoted 23 lines · Andreas Färber
Quoted 6 lines
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 5 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.Quoted 6 lines
Quoted 1 line
Signed-off-by Marcel Apfelbaum <[email protected]>Looks mostly good, but same issue as Alexey's patch: We are risking
qdev_get_machine()creating a Container-typed /machine node.What about the following on top?
Hi Andreas,
I checked with the debugger and
qdev_get_machineis called long after we add the machine to the QOM tree.
However, the race still exists as someone can callqdev_get_machinebefore the machine is added to the tree, not being aware of that.Your change solves the problem, thank you!
Do you want me to add this diff and resend,
or I will send yours separately?
Quoted 8 lines
Quoted 2 lines
My preference would be to avoid another round of review on my part by simply squashing into your 3/3.
There is a problem with it: 'make check fails' on test-qdev-global-props.
- 'qdev_get_machine()' is called by 'device_set_realized()' becausestatic_prop_typehasTYPE_DEVICEas parent.
- The machine is added to the QOM tree *only in vl's main* and this test does not reach it, but assumes that always will be a machine in the QOM tree. This is no longer true.
My simple solution here is to revert my own patch addition. If /machine exists, container.c:container_get() will use object_resolve_path(), just like my diff, to obtain the pre-existing object. And your addition of the /machine child<> in vl.c actually uses error_abort, so would error out if already added by qdev_get_machine(). This means that vl.c actually works as intended and the unit test would continue to implicitly create the /machine code without us needing to add more workarounds.
Regards,
Andreas
Quoted 14 lines
Possible solution would be making existing 'null machine' a subclass of MachineClass and add it manually to QOM on this test(and other places as necessary). The risk here is that there are other places where the machine needs to be added manually to the QOM tree. (I am trying this option, but make check gets stuck !!!, debugging)
Other possible solution is to add some kind of "
CONFIG_MACHINE_IS_QOM_OBJECT" define and use this inqdev_get_machine()implementation. (ugly?)Finally, is possible to be aware that may be a race when doing code review. ("dangerous"?)
Any thoughts?
Thanks,
Marcel
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
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
Quoted 36 lines · Andreas Färber
Am 07.03.2014 17:22, schrieb Marcel Apfelbaum:
Quoted 26 lines · Andreas Färber
Quoted 25 lines
Am 07.03.2014 06:32, schrieb Marcel Apfelbaum:
Quoted 23 lines · Andreas Färber
Quoted 6 lines
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 5 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.Quoted 6 lines
Quoted 1 line
Signed-off-by Marcel Apfelbaum <[email protected]>Looks mostly good, but same issue as Alexey's patch: We are risking
qdev_get_machine()creating a Container-typed /machine node.What about the following on top?
Hi Andreas,
I checked with the debugger and
qdev_get_machineis called long after we add the machine to the QOM tree.
However, the race still exists as someone can callqdev_get_machinebefore the machine is added to the tree, not being aware of that.Your change solves the problem, thank you!
Do you want me to add this diff and resend,
or I will send yours separately?Quoted 8 lines
Quoted 2 lines
My preference would be to avoid another round of review on my part by simply squashing into your 3/3.
There is a problem with it: 'make check fails' on test-qdev-global-props.
- 'qdev_get_machine()' is called by 'device_set_realized()' becausestatic_prop_typehasTYPE_DEVICEas parent.
- The machine is added to the QOM tree *only in vl's main* and this test does not reach it, but assumes that always will be a machine in the QOM tree. This is no longer true.
Quoted 8 lines
My simple solution here is to revert my own patch addition. If /machine exists, container.c:container_get() will use
object_resolve_path(), just like my diff, to obtain the pre-existing object. And your addition of the /machine child<> invl.cactually useserror_abort, so would error out if already added byqdev_get_machine(). This means thatvl.cactually works as intended and the unit test would continue to implicitly create the /machine code without us needing to add more workarounds.
I completely agree, I liked the idea of "object_resolve_path" because the current code hides the *subtle* and *not straight forward* idea you just mentioned above.
Meaning, it would be much easier to understand the code if it would just work, but maybe it does not worth all the workarounds.
So, no problem, just "un-squash" this,
Thanks for the help,
Marcel
Quoted 19 lines
Regards,
AndreasQuoted 14 lines
Possible solution would be making existing 'null machine' a subclass of MachineClass and add it manually to QOM on this test(and other places as necessary). The risk here is that there are other places where the machine needs to be added manually to the QOM tree. (I am trying this option, but make check gets stuck !!!, debugging)
Other possible solution is to add some kind of "
CONFIG_MACHINE_IS_QOM_OBJECT" define and use this inqdev_get_machine()implementation. (ugly?)Finally, is possible to be aware that may be a race when doing code review. ("dangerous"?)
Any thoughts?
Thanks,
Marcel
Re: [Qemu-devel] [PATCH v3 3/3] hw/boards: converted current_machine to be an instance of MachineCLass
In reply to Andreas FärberIl 07/03/2014 00:44, Andreas Färber ha scritto:
Quoted 6 lines
Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
Quoted 5 lines
In order to allow attaching machine options to a machine instance,
current_machineis converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineCLass.
Quoted 6 lines
Quoted 1 line
Signed-off-by Marcel Apfelbaum <[email protected]>Looks mostly good, but same issue as Alexey's patch: We are risking
qdev_get_machine()creating a Container-typed /machine node.What about the following on top?
Good idea! The smallest patches are (almost) always the best. :)
Paolo
Quoted 23 lines
Alexey, if we reach agreement here, this means for you that we can just use
type_register_static()in place ofqemu_machine_register()to register your custom machine type with interface added.Regards,
Andreashw/core/qdev.c +2
-1@@ -861,7 +861,8 @@ Object *qdev_get_machine(void)static Object *dev;if (dev ==NULL ) { - dev =container_get (object_get_root (),"/machine" ); + dev =object_resolve_path ("/machine" ,NULL ); +g_assert (dev); }return dev;