qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM
@ 2014-03-11 15:35 Marcel Apfelbaum
  2014-03-11 15:35 ` [Qemu-devel] [PATCH 1/3] hw/machine: move QEMUMachine assignment into the core machine Marcel Apfelbaum
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Marcel Apfelbaum @ 2014-03-11 15:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, ehabkost, mst, stefanha, armbru, aliguori, pbonzini,
	lersek, afaerber

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.

Cc: Andreas Färber <afaerber@suse.de>

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(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 1/3] hw/machine: move QEMUMachine assignment into the core machine
  2014-03-11 15:35 [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM Marcel Apfelbaum
@ 2014-03-11 15:35 ` Marcel Apfelbaum
  2014-03-11 15:53   ` Marcel Apfelbaum
  2014-03-11 15:35 ` [Qemu-devel] [PATCH 2/3] hw/null-machine: Convert null machine to QOM Marcel Apfelbaum
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Marcel Apfelbaum @ 2014-03-11 15:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, ehabkost, mst, stefanha, armbru, aliguori, pbonzini,
	lersek, afaerber

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 .

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 hw/core/machine.c | 8 ++++++++
 vl.c              | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index d3ffef7..4b49a7d 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -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)
diff --git a/vl.c b/vl.c
index d75ca55..6a380d9 100644
--- a/vl.c
+++ b/vl.c
@@ -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,
     };
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 2/3] hw/null-machine: Convert null machine to QOM
  2014-03-11 15:35 [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM Marcel Apfelbaum
  2014-03-11 15:35 ` [Qemu-devel] [PATCH 1/3] hw/machine: move QEMUMachine assignment into the core machine Marcel Apfelbaum
@ 2014-03-11 15:35 ` Marcel Apfelbaum
  2014-03-11 15:47   ` Eric Blake
  2014-03-11 15:35 ` [Qemu-devel] [PATCH 3/3] tests/qdev-global-props: Manually add an instance of a QOM machine Marcel Apfelbaum
  2014-03-11 17:11 ` [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM Andreas Färber
  3 siblings, 1 reply; 9+ messages in thread
From: Marcel Apfelbaum @ 2014-03-11 15:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, ehabkost, mst, stefanha, armbru, aliguori, pbonzini,
	lersek, afaerber

Needed by some tests.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 hw/core/null-machine.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
index d813c08..5ec02cf 100644
--- a/hw/core/null-machine.c
+++ b/hw/core/null-machine.c
@@ -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)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 3/3] tests/qdev-global-props: Manually add an instance of a QOM machine
  2014-03-11 15:35 [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM Marcel Apfelbaum
  2014-03-11 15:35 ` [Qemu-devel] [PATCH 1/3] hw/machine: move QEMUMachine assignment into the core machine Marcel Apfelbaum
  2014-03-11 15:35 ` [Qemu-devel] [PATCH 2/3] hw/null-machine: Convert null machine to QOM Marcel Apfelbaum
@ 2014-03-11 15:35 ` Marcel Apfelbaum
  2014-03-11 17:11 ` [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM Andreas Färber
  3 siblings, 0 replies; 9+ messages in thread
From: Marcel Apfelbaum @ 2014-03-11 15:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, ehabkost, mst, stefanha, armbru, aliguori, pbonzini,
	lersek, afaerber

The machine is no longer a container. Add null-machine to
the QOM tree.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 tests/Makefile                 | 2 +-
 tests/test-qdev-global-props.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/Makefile b/tests/Makefile
index b17d41e..b86446d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -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
diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index e4ad173..964ae96 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] hw/null-machine: Convert null machine to QOM
  2014-03-11 15:35 ` [Qemu-devel] [PATCH 2/3] hw/null-machine: Convert null machine to QOM Marcel Apfelbaum
@ 2014-03-11 15:47   ` Eric Blake
  2014-03-11 15:50     ` Marcel Apfelbaum
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Blake @ 2014-03-11 15:47 UTC (permalink / raw)
  To: Marcel Apfelbaum, qemu-devel
  Cc: kwolf, ehabkost, mst, stefanha, armbru, aliguori, pbonzini,
	lersek, afaerber

[-- Attachment #1: Type: text/plain, Size: 601 bytes --]

On 03/11/2014 09:35 AM, Marcel Apfelbaum wrote:
> Needed by some tests.
> 
> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> ---
>  hw/core/null-machine.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 

> -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?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] hw/null-machine: Convert null machine to QOM
  2014-03-11 15:47   ` Eric Blake
@ 2014-03-11 15:50     ` Marcel Apfelbaum
  0 siblings, 0 replies; 9+ messages in thread
From: Marcel Apfelbaum @ 2014-03-11 15:50 UTC (permalink / raw)
  To: Eric Blake
  Cc: kwolf, ehabkost, mst, armbru, qemu-devel, stefanha, pbonzini,
	lersek, afaerber, aliguori

On Tue, 2014-03-11 at 09:47 -0600, Eric Blake wrote:
> On 03/11/2014 09:35 AM, Marcel Apfelbaum wrote:
> > Needed by some tests.
> > 
> > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> > ---
> >  hw/core/null-machine.c | 13 +++++++++----
> >  1 file changed, 9 insertions(+), 4 deletions(-)
> > 
> 
> > -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?
I'll take care of this, thanks!
Marcel

> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] hw/machine: move QEMUMachine assignment into the core machine
  2014-03-11 15:35 ` [Qemu-devel] [PATCH 1/3] hw/machine: move QEMUMachine assignment into the core machine Marcel Apfelbaum
@ 2014-03-11 15:53   ` Marcel Apfelbaum
  0 siblings, 0 replies; 9+ messages in thread
From: Marcel Apfelbaum @ 2014-03-11 15:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, ehabkost, mst, stefanha, armbru, aliguori, pbonzini,
	lersek, afaerber

On Tue, 2014-03-11 at 17:35 +0200, Marcel Apfelbaum wrote:
> 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

> 
> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> ---
>  hw/core/machine.c | 8 ++++++++
>  vl.c              | 8 --------
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index d3ffef7..4b49a7d 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -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)
> diff --git a/vl.c b/vl.c
> index d75ca55..6a380d9 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -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,
>      };
I'll remove the casting to void* here, thanks Eric!
Marcel
>  

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM
  2014-03-11 15:35 [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM Marcel Apfelbaum
                   ` (2 preceding siblings ...)
  2014-03-11 15:35 ` [Qemu-devel] [PATCH 3/3] tests/qdev-global-props: Manually add an instance of a QOM machine Marcel Apfelbaum
@ 2014-03-11 17:11 ` Andreas Färber
  2014-03-11 19:44   ` Marcel Apfelbaum
  3 siblings, 1 reply; 9+ messages in thread
From: Andreas Färber @ 2014-03-11 17:11 UTC (permalink / raw)
  To: Marcel Apfelbaum, qemu-devel
  Cc: kwolf, ehabkost, mst, stefanha, armbru, aliguori, pbonzini,
	lersek

Hi Marcel,

Am 11.03.2014 16:35, schrieb Marcel Apfelbaum:
> 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.
> 
> Cc: Andreas Färber <afaerber@suse.de>
> 
> 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

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM
  2014-03-11 17:11 ` [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM Andreas Färber
@ 2014-03-11 19:44   ` Marcel Apfelbaum
  0 siblings, 0 replies; 9+ messages in thread
From: Marcel Apfelbaum @ 2014-03-11 19:44 UTC (permalink / raw)
  To: Andreas Färber
  Cc: kwolf, ehabkost, mst, armbru, qemu-devel, stefanha, pbonzini,
	lersek, aliguori

On Tue, 2014-03-11 at 18:11 +0100, Andreas Färber wrote:
> Hi Marcel,
> 
> Am 11.03.2014 16:35, schrieb Marcel Apfelbaum:
> > 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.
> > 
> > Cc: Andreas Färber <afaerber@suse.de>
> > 
> > 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. ;)
Well, I am on the "follow the rules" and not on "make the rules" stage yet,
so I am trying to adapt... :)

> 
> I'd rather not take the class_base_init patch - for one class_init would
> 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)

> 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.
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
> 
> Regards,
> Andreas
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-03-11 19:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-11 15:35 [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM Marcel Apfelbaum
2014-03-11 15:35 ` [Qemu-devel] [PATCH 1/3] hw/machine: move QEMUMachine assignment into the core machine Marcel Apfelbaum
2014-03-11 15:53   ` Marcel Apfelbaum
2014-03-11 15:35 ` [Qemu-devel] [PATCH 2/3] hw/null-machine: Convert null machine to QOM Marcel Apfelbaum
2014-03-11 15:47   ` Eric Blake
2014-03-11 15:50     ` Marcel Apfelbaum
2014-03-11 15:35 ` [Qemu-devel] [PATCH 3/3] tests/qdev-global-props: Manually add an instance of a QOM machine Marcel Apfelbaum
2014-03-11 17:11 ` [Qemu-devel] [PATCH 0/3] tests/qdev-global-props: fixes due to machine conversion to QOM Andreas Färber
2014-03-11 19:44   ` Marcel Apfelbaum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).