Skip to contentSkip to conversation

qom: Few trivial patches

PATCH In review Philippe Mathieu-Daudé 3 participants 9 messages May 4, 2020 – May 21, 2020

lore
Share & tools
lore
#0 lore raw

v2 cover qom: Few trivial patches

Some QOM patches worth salvaging while doing housekeeping.

Since v1:
- Fixed test build failure (patchew)

Philippe Mathieu-Daudé (3):
qom/object: Move Object typedef to 'qemu/typedefs.h' io/task: Move 'qom/object.h' header to source qom/object: Make reparenting error more verbose

 include/io/task.h         | 2 --
 include/qemu/typedefs.h   | 1 +
 include/qom/object.h      | 2 --
 include/qom/qom-qobject.h | 2 --
 include/sysemu/sysemu.h   | 1 -
 io/task.c                 | 1 +
 qom/object.c              | 7 ++++++-
 tests/test-io-task.c      | 1 +
 8 files changed, 9 insertions(+), 8 deletions(-)
Signature · 1 line
2.21.3
#1 lore raw

PATCH v2 1/3 qom/object: Move Object typedef to 'qemu/typedefs.h'

We use the Object type all over the place.
Forward declare it in "qemu/typedefs.h".

---
 include/qemu/typedefs.h   | 1 +
 include/qom/object.h      | 2 --
 include/qom/qom-qobject.h | 2 --
 include/sysemu/sysemu.h   | 1 -
 4 files changed, 1 insertion(+), 5 deletions(-)
include/qemu/typedefs.h +1 -0
index 375770a80f..b03ec9f40a 100644
@@ -75,6 +75,7 @@ typedef struct NetFilterState NetFilterState;
 typedef struct NICInfo NICInfo;
 typedef struct NodeInfo NodeInfo;
 typedef struct NumaNodeMem NumaNodeMem;
+typedef struct Object Object;
 typedef struct ObjectClass ObjectClass;
 typedef struct PCIBridge PCIBridge;
 typedef struct PCIBus PCIBus;
include/qom/object.h +0 -2
index 784c97c0e1..1edc12e64c 100644
@@ -20,8 +20,6 @@
 struct TypeImpl;
 typedef struct TypeImpl *Type;
 
-typedef struct Object Object;
-
 typedef struct TypeInfo TypeInfo;
 
 typedef struct InterfaceClass InterfaceClass;
include/qom/qom-qobject.h +0 -2
index 77cd717e3f..82136e6e80 100644
@@ -13,8 +13,6 @@
 #ifndef QEMU_QOM_QOBJECT_H
 #define QEMU_QOM_QOBJECT_H
 
-#include "qom/object.h"
-
 /*
  * object_property_get_qobject:
  * @obj: the object
include/sysemu/sysemu.h +0 -1
index ef81302e1a..ca4458e451 100644
@@ -5,7 +5,6 @@
 #include "qemu/timer.h"
 #include "qemu/notify.h"
 #include "qemu/uuid.h"
-#include "qom/object.h"
 
 /* vl.c */
 
Signature · 1 line
2.21.3
#2 lore raw

Re: [PATCH v2 1/3] qom/object: Move Object typedef to 'qemu/typedefs.h'

Quoted 54 lines · Philippe Mathieu-Daudé

We use the Object type all over the place.
Forward declare it in "qemu/typedefs.h".

---
 include/qemu/typedefs.h   | 1 +
 include/qom/object.h      | 2 --
 include/qom/qom-qobject.h | 2 --
 include/sysemu/sysemu.h   | 1 -
 4 files changed, 1 insertion(+), 5 deletions(-)
include/qemu/typedefs.h +1 -0
index 375770a80f..b03ec9f40a 100644
@@ -75,6 +75,7 @@ typedef struct NetFilterState NetFilterState;
 typedef struct NICInfo NICInfo;
 typedef struct NodeInfo NodeInfo;
 typedef struct NumaNodeMem NumaNodeMem;
+typedef struct Object Object;
 typedef struct ObjectClass ObjectClass;
 typedef struct PCIBridge PCIBridge;
 typedef struct PCIBus PCIBus;
include/qom/object.h +0 -2
index 784c97c0e1..1edc12e64c 100644
@@ -20,8 +20,6 @@
 struct TypeImpl;
 typedef struct TypeImpl *Type;
 
-typedef struct Object Object;
-
 typedef struct TypeInfo TypeInfo;
 
 typedef struct InterfaceClass InterfaceClass;
include/qom/qom-qobject.h +0 -2
index 77cd717e3f..82136e6e80 100644
@@ -13,8 +13,6 @@
 #ifndef QEMU_QOM_QOBJECT_H
 #define QEMU_QOM_QOBJECT_H
 
-#include "qom/object.h"
-
 /*
  * object_property_get_qobject:
  * @obj: the object
include/sysemu/sysemu.h +0 -0
index ef81302e1a..ca4458e451 100644

include/sysemu/sysemu.h line 9

Quoted 6 lines
include/sysemu/sysemu.h +0 -1
@@ -5,7 +5,6 @@
 #include "qemu/timer.h"
 #include "qemu/notify.h"
 #include "qemu/uuid.h"
-#include "qom/object.h"
 
 /* vl.c */

How did you identify the inclusions to drop?

#3 lore raw

Re: [PATCH v2 1/3] qom/object: Move Object typedef to 'qemu/typedefs.h'

Quoted 62 lines · Markus Armbruster
Quoted 59 lines · Philippe Mathieu-Daudé

We use the Object type all over the place.
Forward declare it in "qemu/typedefs.h".

---
 include/qemu/typedefs.h   | 1 +
 include/qom/object.h      | 2 --
 include/qom/qom-qobject.h | 2 --
 include/sysemu/sysemu.h   | 1 -
 4 files changed, 1 insertion(+), 5 deletions(-)
include/qemu/typedefs.h +1 -0
index 375770a80f..b03ec9f40a 100644
@@ -75,6 +75,7 @@ typedef struct NetFilterState NetFilterState;
 typedef struct NICInfo NICInfo;
 typedef struct NodeInfo NodeInfo;
 typedef struct NumaNodeMem NumaNodeMem;
+typedef struct Object Object;
 typedef struct ObjectClass ObjectClass;
 typedef struct PCIBridge PCIBridge;
 typedef struct PCIBus PCIBus;
include/qom/object.h +0 -2
index 784c97c0e1..1edc12e64c 100644
@@ -20,8 +20,6 @@
 struct TypeImpl;
 typedef struct TypeImpl *Type;
 
-typedef struct Object Object;
-
 typedef struct TypeInfo TypeInfo;
 
 typedef struct InterfaceClass InterfaceClass;
include/qom/qom-qobject.h +0 -2
index 77cd717e3f..82136e6e80 100644
@@ -13,8 +13,6 @@
 #ifndef QEMU_QOM_QOBJECT_H
 #define QEMU_QOM_QOBJECT_H
 
-#include "qom/object.h"
-
 /*
  * object_property_get_qobject:
  * @obj: the object
include/sysemu/sysemu.h +0 -1
index ef81302e1a..ca4458e451 100644
@@ -5,7 +5,6 @@
 #include "qemu/timer.h"
 #include "qemu/notify.h"
 #include "qemu/uuid.h"
-#include "qom/object.h"
 
Quoted 3 lines

include/sysemu/sysemu.h line 9

Quoted 1 line
include/sysemu/sysemu.h +0 -0
 /* vl.c */

How did you identify the inclusions to drop?

Nothing very strict I'm afraid. I suppose I had the files opened in my editor.

The output of

$ git grep -L -E '(OBJECT_|INTERFACE_)' $(git grep -l qom/object include)
suggests I missed those:

-- >8 --

include/hw/display/edid.h +0 -2
index ff99dc0a05..5b1de57f24 100644
@@ -1,8 +1,6 @@
 #ifndef EDID_H
 #define EDID_H
 
-#include "qom/object.h"
-
 typedef struct qemu_edid_info {
     const char *vendor; /* http://www.uefi.org/pnp_id_list */
     const char *name;
include/io/task.h +0 -2
index 1abbfb8b65..6818dfedd0 100644
@@ -21,8 +21,6 @@
 #ifndef QIO_TASK_H
 #define QIO_TASK_H
 
-#include "qom/object.h"
-
 typedef struct QIOTask QIOTask;
 
 typedef void (*QIOTaskFunc)(QIOTask *task,

---

#4 lore raw

Re: [PATCH v2 1/3] qom/object: Move Object typedef to 'qemu/typedefs.h'

Quoted 63 lines · Philippe Mathieu-Daudé
Quoted 62 lines · Markus Armbruster
Quoted 59 lines · Philippe Mathieu-Daudé

We use the Object type all over the place.
Forward declare it in "qemu/typedefs.h".

---
 include/qemu/typedefs.h   | 1 +
 include/qom/object.h      | 2 --
 include/qom/qom-qobject.h | 2 --
 include/sysemu/sysemu.h   | 1 -
 4 files changed, 1 insertion(+), 5 deletions(-)
include/qemu/typedefs.h +1 -0
index 375770a80f..b03ec9f40a 100644
@@ -75,6 +75,7 @@ typedef struct NetFilterState NetFilterState;
 typedef struct NICInfo NICInfo;
 typedef struct NodeInfo NodeInfo;
 typedef struct NumaNodeMem NumaNodeMem;
+typedef struct Object Object;
 typedef struct ObjectClass ObjectClass;
 typedef struct PCIBridge PCIBridge;
 typedef struct PCIBus PCIBus;
include/qom/object.h +0 -2
index 784c97c0e1..1edc12e64c 100644
@@ -20,8 +20,6 @@
 struct TypeImpl;
 typedef struct TypeImpl *Type;
 
-typedef struct Object Object;
-
 typedef struct TypeInfo TypeInfo;
 
 typedef struct InterfaceClass InterfaceClass;
include/qom/qom-qobject.h +0 -2
index 77cd717e3f..82136e6e80 100644
@@ -13,8 +13,6 @@
 #ifndef QEMU_QOM_QOBJECT_H
 #define QEMU_QOM_QOBJECT_H
 
-#include "qom/object.h"
-
 /*
  * object_property_get_qobject:
  * @obj: the object
include/sysemu/sysemu.h +0 -1
index ef81302e1a..ca4458e451 100644
@@ -5,7 +5,6 @@
 #include "qemu/timer.h"
 #include "qemu/notify.h"
 #include "qemu/uuid.h"
-#include "qom/object.h"
 
Quoted 8 lines
Quoted 3 lines

include/sysemu/sysemu.h line 9

Quoted 1 line
include/sysemu/sysemu.h +0 -0
 /* vl.c */

How did you identify the inclusions to drop?

Nothing very strict I'm afraid. I suppose I had the files opened in my editor.

The output of

$ git grep -L -E '(OBJECT_|INTERFACE_)' $(git grep -l qom/object include)

Why limit to include, and not check '*.h', or even '*.[ch]'?

Quoted 30 lines

suggests I missed those:

-- >8 --

include/hw/display/edid.h +0 -2
index ff99dc0a05..5b1de57f24 100644
@@ -1,8 +1,6 @@
 #ifndef EDID_H
 #define EDID_H
 
-#include "qom/object.h"
-
 typedef struct qemu_edid_info {
     const char *vendor; /* http://www.uefi.org/pnp_id_list */
     const char *name;
include/io/task.h +0 -3
index 1abbfb8b65..6818dfedd0 100644
@@ -21,8 +21,6 @@
 #ifndef QIO_TASK_H
 #define QIO_TASK_H
 
-#include "qom/object.h"
-
 typedef struct QIOTask QIOTask;
 
 typedef void (*QIOTaskFunc)(QIOTask *task,
---
#5 lore raw

Re: [PATCH v2 1/3] qom/object: Move Object typedef to 'qemu/typedefs.h'

In reply to Philippe Mathieu-Daudé
Quoted 63 lines · Philippe Mathieu-Daudé
Quoted 62 lines · Markus Armbruster
Quoted 59 lines · Philippe Mathieu-Daudé

We use the Object type all over the place.
Forward declare it in "qemu/typedefs.h".

---
 include/qemu/typedefs.h   | 1 +
 include/qom/object.h      | 2 --
 include/qom/qom-qobject.h | 2 --
 include/sysemu/sysemu.h   | 1 -
 4 files changed, 1 insertion(+), 5 deletions(-)
include/qemu/typedefs.h +1 -0
index 375770a80f..b03ec9f40a 100644
@@ -75,6 +75,7 @@ typedef struct NetFilterState NetFilterState;
 typedef struct NICInfo NICInfo;
 typedef struct NodeInfo NodeInfo;
 typedef struct NumaNodeMem NumaNodeMem;
+typedef struct Object Object;
 typedef struct ObjectClass ObjectClass;
 typedef struct PCIBridge PCIBridge;
 typedef struct PCIBus PCIBus;
include/qom/object.h +0 -2
index 784c97c0e1..1edc12e64c 100644
@@ -20,8 +20,6 @@
 struct TypeImpl;
 typedef struct TypeImpl *Type;
 
-typedef struct Object Object;
-
 typedef struct TypeInfo TypeInfo;
 
 typedef struct InterfaceClass InterfaceClass;
include/qom/qom-qobject.h +0 -2
index 77cd717e3f..82136e6e80 100644
@@ -13,8 +13,6 @@
 #ifndef QEMU_QOM_QOBJECT_H
 #define QEMU_QOM_QOBJECT_H
 
-#include "qom/object.h"
-
 /*
  * object_property_get_qobject:
  * @obj: the object
include/sysemu/sysemu.h +0 -1
index ef81302e1a..ca4458e451 100644
@@ -5,7 +5,6 @@
 #include "qemu/timer.h"
 #include "qemu/notify.h"
 #include "qemu/uuid.h"
-#include "qom/object.h"
 
Quoted 5 lines
Quoted 3 lines

include/sysemu/sysemu.h line 9

Quoted 1 line
include/sysemu/sysemu.h +0 -0
 /* vl.c */

How did you identify the inclusions to drop?

Nothing very strict I'm afraid. I suppose I had the files opened in my editor.

Looks like all of these are affected:

 accel/accel.c             | 1 -
 block/throttle-groups.c   | 1 -
 hw/audio/soundhw.c        | 1 -
 hw/block/vhost-user-blk.c | 1 -
 hw/pci-host/pam.c         | 1 -
 hw/ppc/spapr_drc.c        | 1 -
 hw/scsi/vhost-user-scsi.c | 1 -
 include/hw/display/edid.h | 1 -
 include/hw/misc/pvpanic.h | 1 -
 include/hw/timer/hpet.h   | 1 -
 io/task.c                 | 1 -
 memory.c                  | 1 -
 stubs/qmp_memory_device.c | 1 -
 target/arm/kvm.c          | 1 -
 tests/test-io-task.c      | 1 -

Patch 3 doesn't apply anymore, I queued the first two.

Paolo

#6 lore raw

PATCH v2 2/3 io/task: Move 'qom/object.h' header to source

In reply to Philippe Mathieu-Daudé

We need "qom/object.h" to call object_ref()/object_unref(), and to test the TYPE_DUMMY.

---
v2: Add missing header in tests/test-io-task.c (patchew)

---
 include/io/task.h    | 2 --
 io/task.c            | 1 +
 tests/test-io-task.c | 1 +
 3 files changed, 2 insertions(+), 2 deletions(-)
include/io/task.h +0 -2
index 1abbfb8b65..6818dfedd0 100644
@@ -21,8 +21,6 @@
 #ifndef QIO_TASK_H
 #define QIO_TASK_H
 
-#include "qom/object.h"
-
 typedef struct QIOTask QIOTask;
 
 typedef void (*QIOTaskFunc)(QIOTask *task,
io/task.c +1 -0
index 1ae7b86488..53c0bed686 100644
@@ -22,6 +22,7 @@
 #include "io/task.h"
 #include "qapi/error.h"
 #include "qemu/thread.h"
+#include "qom/object.h"
 #include "trace.h"
 
 struct QIOTaskThreadData {
tests/test-io-task.c +1 -0
index aa8b653bfa..c8a3813d49 100644
@@ -20,6 +20,7 @@
 
 #include "qemu/osdep.h"
 
+#include "qom/object.h"
 #include "io/task.h"
 #include "qapi/error.h"
 #include "qemu/module.h"
Signature · 1 line
2.21.3
#7 lore raw

PATCH v2 3/3 qom/object: Make reparenting error more verbose

In reply to Philippe Mathieu-Daudé

Display child and parent names when reparenting occurs.

---
 qom/object.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
qom/object.c +6 -1
index be700e831f..417fd90aa5 100644
@@ -1683,7 +1683,12 @@ void object_property_add_child(Object *obj, const char *name,
     ObjectProperty *op;
 
     if (child->parent != NULL) {
-        error_setg(errp, "child object is already parented");
+        error_setg(errp, "child object '%s' is already parented (parent: '%s') "
+                         "can not be children '%s' of '%s'",
+                   object_get_typename(child),
+                   object_get_typename(child->parent),
+                   name,
+                   object_get_typename(obj));
         return;
     }
 
Signature · 1 line
2.21.3
#8 lore raw
In reply to Philippe Mathieu-Daudé

ping?

Quoted 20 lines · Philippe Mathieu-Daudé

Some QOM patches worth salvaging while doing housekeeping.

Since v1:
- Fixed test build failure (patchew)

Philippe Mathieu-Daudé (3):
qom/object: Move Object typedef to 'qemu/typedefs.h' io/task: Move 'qom/object.h' header to source qom/object: Make reparenting error more verbose

  include/io/task.h         | 2 --
  include/qemu/typedefs.h   | 1 +
  include/qom/object.h      | 2 --
  include/qom/qom-qobject.h | 2 --
  include/sysemu/sysemu.h   | 1 -
  io/task.c                 | 1 +
  qom/object.c              | 7 ++++++-
  tests/test-io-task.c      | 1 +
  8 files changed, 9 insertions(+), 8 deletions(-)