Skip to contentSkip to conversation

include qdev core in *-user, make CPU child of DeviceState

RFC Applied Eduardo Habkost 6 participants 19 messages Oct 4, 2012 – Oct 16, 2012 Kbuild

lore
Share & tools
lore
#5 lore raw

RFC v2 3/13 qapi-types.h doesn't really need to include qemu-common.h

In reply to Eduardo Habkost

From: Igor Mammedov <[email protected]>

needed to prevent build breakage when CPU becomes a child of DeviceState

[ehabkost: include <stdbool.h> too]

---
 scripts/qapi-types.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/qapi-types.py +2 -1
index 49ef569..6e0e6ba 100644
@@ -273,7 +273,8 @@ fdecl.write(mcgen('''
 #ifndef %(guard)s
 #define %(guard)s
 
-#include "qemu-common.h"
+#include <stdbool.h>
+#include <stdint.h>
 
 ''',
                   guard=guardname(h_file)))
Signature · 1 line
1.7.11.4
#15 lore raw

RFC v2 11/13 qdev: use full qdev.h include path on qdev*.c

In reply to Eduardo Habkost

This way, the files can be moved to the qom/ directory as-is.

---
 hw/qdev-core.c       | 2 +-
 hw/qdev-properties.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/qdev-core.c +1 -1
index 46ab239..472fe8f 100644
@@ -25,7 +25,7 @@
    inherit from a particular bus (e.g. PCI or I2C) rather than
    this API directly.  */
 
-#include "qdev.h"
+#include "hw/qdev.h"
 #include "sysemu.h"
 #include "error.h"
 #include "qapi/qapi-visit-core.h"
hw/qdev-properties.c +1 -1
index 917d986..2e82cb9 100644
@@ -1,5 +1,5 @@
 #include "net.h"
-#include "qdev.h"
+#include "hw/qdev.h"
 #include "qerror.h"
 #include "blockdev.h"
 #include "hw/block-common.h"
Signature · 1 line
1.7.11.4
#0 lore raw

v2 cover include qdev core in *-user, make CPU child of DeviceState

Previous version:
http://article.gmane.org/gmane.comp.emulators.qemu/166630

This version removes the CONFIG_USER_ONLY ifdefs, and use weak symbols to move the vmstate and qemu_register_reset() handling to qdev-system.c.

Anthony Liguori (1):
qdev: split up header so it can be used in cpu.h

Eduardo Habkost (9):
qdev: kill bogus comment
qdev: separate core from the code used only by qemu-system-*
qdev: rename qdev.c to qdev-core.c
qdev-core: isolate vmstate handling into separate functions
qdev: move vmstate handling to qdev-system.c
qdev-core: isolate reset register/unregister code
qdev: move reset register/unregister code to qdev-system.c
qdev: use full qdev.h include path on qdev*.c include core qdev code into *-user, too

Igor Mammedov (3):
qapi-types.h doesn't really need to include qemu-common.h move qemu_irq typedef out of cpu-common.h
make CPU a child of DeviceState

 Makefile.objs                 |   3 +
 hw/Makefile.objs              |   3 +-
 hw/arm-misc.h                 |   1 +
 hw/bt.h                       |   2 +
 hw/devices.h                  |   2 +
 hw/irq.h                      |   2 +
 hw/mc146818rtc.c              |   1 +
 hw/omap.h                     |   1 +
 hw/qdev-addr.c                |   1 +
 hw/qdev-core.h                | 245 ++++++++++++++++++++++++++++
 hw/qdev-monitor.h             |  16 ++
 hw/qdev-properties-system.c   | 329 +++++++++++++++++++++++++++++++++++++
 hw/qdev-properties.h          | 131 +++++++++++++++
 hw/qdev-system.c              | 130 +++++++++++++++
 hw/qdev.h                     | 371 +-----------------------------------------
 hw/soc_dma.h                  |   1 +
 hw/xen.h                      |   1 +
 include/qemu/cpu.h            |   6 +-
 qemu-common.h                 |   1 -
 qom/Makefile.objs             |   2 +-
 qom/cpu.c                     |   3 +-
 hw/qdev.c => qom/qdev-core.c  | 141 ++++------------
 {hw => qom}/qdev-properties.c | 323 +-----------------------------------
 scripts/qapi-types.py         |   3 +-
 sysemu.h                      |   1 +
 25 files changed, 914 insertions(+), 806 deletions(-)
 create mode 100644 hw/qdev-core.h
 create mode 100644 hw/qdev-monitor.h
 create mode 100644 hw/qdev-properties-system.c
 create mode 100644 hw/qdev-properties.h
 create mode 100644 hw/qdev-system.c
 rename hw/qdev.c => qom/qdev-core.c (85%)
 rename {hw => qom}/qdev-properties.c (75%)
Signature · 1 line
1.7.11.4
#7 lore raw

RFC v2 5/13 qdev: rename qdev.c to qdev-core.c

Just to make clear that it's the qdev core code, corresponding to qdev-core.h.

---
 hw/Makefile.objs           | 2 +-
 hw/{qdev.c => qdev-core.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename hw/{qdev.c => qdev-core.c} (100%)
hw/Makefile.objs +1 -1
index 030cb2d..c876e16 100644
@@ -178,7 +178,7 @@ common-obj-$(CONFIG_SD) += sd.o
 common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += msmouse.o ps2.o
-common-obj-y += qdev.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-core.o qdev-properties.o qdev-monitor.o
 common-obj-y += qdev-system.o qdev-properties-system.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 
hw/qdev-core.c renamed from hw/qdev.c +0 -0
similarity index 100%
rename from hw/qdev.c
rename to hw/qdev-core.c
Signature · 1 line
1.7.11.4
#9 lore raw

RFC v2 7/13 qdev: move vmstate handling to qdev-system.c

In reply to Eduardo Habkost

Add GCC_WEAK symbols to qdev-core.c, so that qdev-core.o can be used without qdev-system.o (i.e. by *-user).

---
 hw/qdev-core.c   | 23 +++++++----------------
 hw/qdev-core.h   |  2 ++
 hw/qdev-system.c | 22 ++++++++++++++++++++++
 3 files changed, 31 insertions(+), 16 deletions(-)
hw/qdev-core.c +7 -16
index 242347f..a5cac45 100644
@@ -34,26 +34,17 @@ int qdev_hotplug = 0;
 static bool qdev_hot_added = false;
 static bool qdev_hot_removed = false;
 
-const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
-{
-    DeviceClass *dc = DEVICE_GET_CLASS(dev);
-    return dc->vmsd;
-}
-
-static void qdev_init_vmstate(DeviceState *dev)
+/* vmstate handling:
+ *
+ * The real implementations are on qdev-system.c. Those are weak symbols
+ * used by *-user.
+ */
+void GCC_WEAK qdev_init_vmstate(DeviceState *dev)
 {
-    if (qdev_get_vmsd(dev)) {
-        vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
-                                       dev->instance_id_alias,
-                                       dev->alias_required_for_version);
-    }
 }
 
-static void qdev_finalize_vmstate(DeviceState *dev)
+void GCC_WEAK qdev_finalize_vmstate(DeviceState *dev)
 {
-    if (qdev_get_vmsd(dev)) {
-        vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
-    }
 }
 
 const char *qdev_fw_name(DeviceState *dev)
hw/qdev-core.h +2 -0
index ca205fc..e9b6d6d 100644
@@ -225,6 +225,8 @@ void qdev_machine_init(void);
 void device_reset(DeviceState *dev);
 
 const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
+void qdev_init_vmstate(DeviceState *dev);
+void qdev_finalize_vmstate(DeviceState *dev);
 
 const char *qdev_fw_name(DeviceState *dev);
 
hw/qdev-system.c +22 -0
index 4891d2f..b4d40e8 100644
@@ -91,3 +91,25 @@ DeviceState *qdev_try_create(BusState *bus, const char *type)
 
     return dev;
 }
+
+const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
+{
+    DeviceClass *dc = DEVICE_GET_CLASS(dev);
+    return dc->vmsd;
+}
+
+void qdev_init_vmstate(DeviceState *dev)
+{
+    if (qdev_get_vmsd(dev)) {
+        vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
+                                       dev->instance_id_alias,
+                                       dev->alias_required_for_version);
+    }
+}
+
+void qdev_finalize_vmstate(DeviceState *dev)
+{
+    if (qdev_get_vmsd(dev)) {
+        vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
+    }
+}
Signature · 1 line
1.7.11.4
#1 lore raw

RFC v2 1/13 qdev: kill bogus comment

In reply to Eduardo Habkost

When the DeviceInfo code was removed, the comment describing qdev_subclass_init() was left in the code by mistake. Remove it.

---
 hw/qdev.c | 1 -
 1 file changed, 1 deletion(-)
hw/qdev.c +0 -1
index b5a52ac..a7270a5 100644
@@ -34,7 +34,6 @@ int qdev_hotplug = 0;
 static bool qdev_hot_added = false;
 static bool qdev_hot_removed = false;
 
-/* Register a new device type.  */
 const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
Signature · 1 line
1.7.11.4
#11 lore raw

RFC v2 9/13 qdev: move reset register/unregister code to qdev-system.c

In reply to Eduardo Habkost

Also, add weak symbols that will be used if qdev-system.o is not compiled in (i.e. on *-user).

---
 hw/qdev-core.c   | 16 +++++++---------
 hw/qdev-core.h   |  3 +++
 hw/qdev-system.c | 15 +++++++++++++++
 3 files changed, 25 insertions(+), 9 deletions(-)
hw/qdev-core.c +7 -9
index 1b45e51..46ab239 100644
@@ -47,19 +47,17 @@ void GCC_WEAK qdev_finalize_vmstate(DeviceState *dev)
 {
 }
 
-static void qbus_register_reset(BusState *bus)
+/* reset handler register/unregister:
+ *
+ * The real implementations are on qdev-system.c. Those are weak symbols
+ * used by *-user.
+ */
+void GCC_WEAK qbus_register_reset(BusState *bus)
 {
-    if (bus != sysbus_get_default()) {
-        /* TODO: once all bus devices are qdevified,
-           only reset handler for main_system_bus should be registered here. */
-        qemu_register_reset(qbus_reset_all_fn, bus);
-    }
 }
 
-static void qbus_unregister_reset(BusState *bus)
+void GCC_WEAK qbus_unregister_reset(BusState *bus)
 {
-    assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
-    qemu_unregister_reset(qbus_reset_all_fn, bus);
 }
 
 const char *qdev_fw_name(DeviceState *dev)
hw/qdev-core.h +3 -0
index e9b6d6d..e10021d 100644
@@ -228,6 +228,9 @@ const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
 void qdev_init_vmstate(DeviceState *dev);
 void qdev_finalize_vmstate(DeviceState *dev);
 
+void qbus_register_reset(BusState *bus);
+void qbus_unregister_reset(BusState *bus);
+
 const char *qdev_fw_name(DeviceState *dev);
 
 Object *qdev_get_machine(void);
hw/qdev-system.c +15 -0
index b4d40e8..eca5fd5 100644
@@ -113,3 +113,18 @@ void qdev_finalize_vmstate(DeviceState *dev)
         vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
     }
 }
+
+void qbus_register_reset(BusState *bus)
+{
+    if (bus != sysbus_get_default()) {
+        /* TODO: once all bus devices are qdevified,
+           only reset handler for main_system_bus should be registered here. */
+        qemu_register_reset(qbus_reset_all_fn, bus);
+    }
+}
+
+void qbus_unregister_reset(BusState *bus)
+{
+    assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
+    qemu_unregister_reset(qbus_reset_all_fn, bus);
+}
Signature · 1 line
1.7.11.4
#17 lore raw

RFC v2 13/13 make CPU a child of DeviceState

In reply to Eduardo Habkost

From: Igor Mammedov <[email protected]>

[ehabkost: change CPU type declaration to hae TYPE_DEVICE as parent]

---
 include/qemu/cpu.h | 6 +++---
 qom/cpu.c          | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
include/qemu/cpu.h +3 -3
index ad706a6..ac44057 100644
@@ -20,7 +20,7 @@
 #ifndef QEMU_CPU_H
 #define QEMU_CPU_H
 
-#include "qemu/object.h"
+#include "hw/qdev-core.h"
 #include "qemu-thread.h"
 
 /**
@@ -46,7 +46,7 @@ typedef struct CPUState CPUState;
  */
 typedef struct CPUClass {
     /*< private >*/
-    ObjectClass parent_class;
+    DeviceClass parent_class;
     /*< public >*/
 
     void (*reset)(CPUState *cpu);
@@ -59,7 +59,7 @@ typedef struct CPUClass {
  */
 struct CPUState {
     /*< private >*/
-    Object parent_obj;
+    DeviceState parent_obj;
     /*< public >*/
 
     struct QemuThread *thread;
qom/cpu.c +2 -1
index 5b36046..f59db7d 100644
@@ -20,6 +20,7 @@
 
 #include "qemu/cpu.h"
 #include "qemu-common.h"
+#include "hw/qdev-core.h"
 
 void cpu_reset(CPUState *cpu)
 {
@@ -43,7 +44,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
 
 static TypeInfo cpu_type_info = {
     .name = TYPE_CPU,
-    .parent = TYPE_OBJECT,
+    .parent = TYPE_DEVICE,
     .instance_size = sizeof(CPUState),
     .abstract = true,
     .class_size = sizeof(CPUClass),
Signature · 1 line
1.7.11.4
#6 lore raw

RFC v2 4/13 qdev: separate core from the code used only by qemu-system-*

In reply to Eduardo Habkost

This change should help on two things:
- Allowing DeviceState to be used by *-user;
- Writing qdev unit tests without pulling too many dependencies.

Note that there are two parts that depend on code compiled only on qemu-system-*, but are still inside qdev.c:
- vmstate handling
- reset function registration.

Those two parts will be handled later, by moving that code to qdev-system.c but keeping weak symbols for *-user.

---
 hw/Makefile.objs            |   1 +
 hw/qdev-properties-system.c | 329 ++++++++++++++++++++++++++++++++++++++++++++
 hw/qdev-properties.c        | 320 +-----------------------------------------
 hw/qdev-properties.h        |   1 +
 hw/qdev-system.c            |  93 +++++++++++++
 hw/qdev.c                   |  92 -------------
 6 files changed, 425 insertions(+), 411 deletions(-)
 create mode 100644 hw/qdev-properties-system.c
 create mode 100644 hw/qdev-system.c
hw/Makefile.objs +1 -0
index ecdbe44..030cb2d 100644
@@ -179,6 +179,7 @@ common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += msmouse.o ps2.o
 common-obj-y += qdev.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-system.o qdev-properties-system.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 
 # xen backend driver support
hw/qdev-properties-system.c new file +329 -0

329 lines not on this page · raw message

hw/qdev-properties.c +1 -319

347 lines not on this page · raw message

hw/qdev-properties.h +1 -0
index 5b046ab..ddcf774 100644
@@ -116,6 +116,7 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 /* FIXME: Remove opaque pointer properties.  */
 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
 
+void qdev_prop_register_global(GlobalProperty *prop);
 void qdev_prop_register_global_list(GlobalProperty *props);
 void qdev_prop_set_globals(DeviceState *dev);
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
hw/qdev-system.c new file +93 -0

93 lines not on this page · raw message

hw/qdev.c +0 -92

110 lines not on this page · raw message

Signature · 1 line
1.7.11.4
#8 lore raw

RFC v2 6/13 qdev-core: isolate vmstate handling into separate functions

In reply to Eduardo Habkost

Those functions will eventually be moved somewhere else, and won't get included on *-user.

---
 hw/qdev-core.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
hw/qdev-core.c +18 -8
index c3c4d77..242347f 100644
@@ -40,6 +40,22 @@ const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
     return dc->vmsd;
 }
 
+static void qdev_init_vmstate(DeviceState *dev)
+{
+    if (qdev_get_vmsd(dev)) {
+        vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
+                                       dev->instance_id_alias,
+                                       dev->alias_required_for_version);
+    }
+}
+
+static void qdev_finalize_vmstate(DeviceState *dev)
+{
+    if (qdev_get_vmsd(dev)) {
+        vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
+    }
+}
+
 const char *qdev_fw_name(DeviceState *dev)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
@@ -131,11 +147,7 @@ int qdev_init(DeviceState *dev)
         g_free(name);
     }
 
-    if (qdev_get_vmsd(dev)) {
-        vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
-                                       dev->instance_id_alias,
-                                       dev->alias_required_for_version);
-    }
+    qdev_init_vmstate(dev);
     dev->state = DEV_STATE_INITIALIZED;
     if (dev->hotplugged) {
         device_reset(dev);
@@ -608,9 +620,7 @@ static void device_finalize(Object *obj)
             bus = QLIST_FIRST(&dev->child_bus);
             qbus_free(bus);
         }
-        if (qdev_get_vmsd(dev)) {
-            vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
-        }
+        qdev_finalize_vmstate(dev);
         if (dc->exit) {
             dc->exit(dev);
         }
Signature · 1 line
1.7.11.4
#3 lore raw

RFC v2 2/13 qdev: split up header so it can be used in cpu.h

In reply to Eduardo Habkost

From: Anthony Liguori <[email protected]>

Header file dependency is a frickin' nightmare right now. cpu.h tends to get included in our 'include everything' header files but qdev also needs to include those headers mainly for qdev-properties since it knows about CharDriverState and friends.

We can solve this for now by splitting out qdev.h along the same lines that we previously split the C file. Then cpu.h just needs to include qdev-core.h

[ehabkost: re-add DEFINE_PROP_PCI_HOST_DEVADDR, that was removed on the
original patch (by mistake, I guess)]
[ehabkost: kill qdev_prop_set_vlan() declaration]

---
 hw/irq.h             |   2 +
 hw/mc146818rtc.c     |   1 +
 hw/qdev-addr.c       |   1 +
 hw/qdev-core.h       | 240 +++++++++++++++++++++++++++++++++
 hw/qdev-monitor.h    |  16 +++
 hw/qdev-properties.c |   1 +
 hw/qdev-properties.h | 130 ++++++++++++++++++
 hw/qdev.c            |   1 +
 hw/qdev.h            | 371 +--------------------------------------------------
 9 files changed, 396 insertions(+), 367 deletions(-)
 create mode 100644 hw/qdev-core.h
 create mode 100644 hw/qdev-monitor.h
 create mode 100644 hw/qdev-properties.h
hw/irq.h +2 -0
index 56c55f0..1339a3a 100644
@@ -3,6 +3,8 @@
 
 /* Generic IRQ/GPIO pin infrastructure.  */
 
+typedef struct IRQState *qemu_irq;
+
 typedef void (*qemu_irq_handler)(void *opaque, int n, int level);
 
 void qemu_set_irq(qemu_irq irq, int level);
hw/mc146818rtc.c +1 -0
index d63554f..1718a57 100644
@@ -25,6 +25,7 @@
 #include "qemu-timer.h"
 #include "sysemu.h"
 #include "mc146818rtc.h"
+#include "qapi/qapi-visit-core.h"
 
 #ifdef TARGET_I386
 #include "apic.h"
hw/qdev-addr.c +1 -0
index b711b6b..5b5d38f 100644
@@ -1,6 +1,7 @@
 #include "qdev.h"
 #include "qdev-addr.h"
 #include "targphys.h"
+#include "qapi/qapi-visit-core.h"
 
 /* --- target physical address --- */
 
hw/qdev-core.h new file +240 -0

240 lines not on this page · raw message

hw/qdev-monitor.h new file +16 -0
new file mode 100644
index 0000000..220ceba
@@ -0,0 +1,16 @@
+#ifndef QEMU_QDEV_MONITOR_H
+#define QEMU_QDEV_MONITOR_H
+
+#include "qdev-core.h"
+#include "monitor.h"
+
+/*** monitor commands ***/
+
+void do_info_qtree(Monitor *mon);
+void do_info_qdm(Monitor *mon);
+int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
+int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
+int qdev_device_help(QemuOpts *opts);
+DeviceState *qdev_device_add(QemuOpts *opts);
+
+#endif
hw/qdev-properties.c +1 -0
index 8aca0d4..81d901c 100644
@@ -4,6 +4,7 @@
 #include "blockdev.h"
 #include "hw/block-common.h"
 #include "net/hub.h"
+#include "qapi/qapi-visit-core.h"
 
 void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
 {
hw/qdev-properties.h new file +130 -0

130 lines not on this page · raw message

hw/qdev.c +1 -0
index a7270a5..01cbd26 100644
@@ -29,6 +29,7 @@
 #include "qdev.h"
 #include "sysemu.h"
 #include "error.h"
+#include "qapi/qapi-visit-core.h"
 
 int qdev_hotplug = 0;
 static bool qdev_hot_added = false;
hw/qdev.h +4 -367

376 lines not on this page · raw message

Signature · 1 line
1.7.11.4
#13 lore raw

RFC v2 10/13 move qemu_irq typedef out of cpu-common.h

In reply to Eduardo Habkost

From: Igor Mammedov <[email protected]>

it's necessary for making CPU child of DEVICE without causing circular header deps.

---
 hw/arm-misc.h | 1 +
 hw/bt.h       | 2 ++
 hw/devices.h  | 2 ++
 hw/omap.h     | 1 +
 hw/soc_dma.h  | 1 +
 hw/xen.h      | 1 +
 qemu-common.h | 1 -
 sysemu.h      | 1 +
 8 files changed, 9 insertions(+), 1 deletion(-)
hw/arm-misc.h +1 -0
index bdd8fec..b13aa59 100644
@@ -12,6 +12,7 @@
 #define ARM_MISC_H 1
 
 #include "memory.h"
+#include "hw/irq.h"
 
 /* The CPU is also modeled as an interrupt controller.  */
 #define ARM_PIC_CPU_IRQ 0
hw/bt.h +2 -0
index a48b8d4..ebf6a37 100644
@@ -23,6 +23,8 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "hw/irq.h"
+
 /* BD Address */
 typedef struct {
     uint8_t b[6];
hw/devices.h +2 -0
index 1a55c1e..c60bcab 100644
@@ -1,6 +1,8 @@
 #ifndef QEMU_DEVICES_H
 #define QEMU_DEVICES_H
 
+#include "hw/irq.h"
+
 /* ??? Not all users of this file can include cpu-common.h.  */
 struct MemoryRegion;
 
hw/omap.h +1 -0
index 413851b..8b08462 100644
@@ -19,6 +19,7 @@
 #ifndef hw_omap_h
 #include "memory.h"
 # define hw_omap_h		"omap.h"
+#include "hw/irq.h"
 
 # define OMAP_EMIFS_BASE	0x00000000
 # define OMAP2_Q0_BASE		0x00000000
hw/soc_dma.h +1 -0
index 904b26c..e386ace 100644
@@ -19,6 +19,7 @@
  */
 
 #include "memory.h"
+#include "hw/irq.h"
 
 struct soc_dma_s;
 struct soc_dma_ch_s;
hw/xen.h +1 -0
index e5926b7..ff11dfd 100644
@@ -8,6 +8,7 @@
  */
 #include <inttypes.h>
 
+#include "hw/irq.h"
 #include "qemu-common.h"
 
 /* xen-machine.c */
qemu-common.h +0 -1
index 15d9e4e..e9df9f5 100644
@@ -278,7 +278,6 @@ typedef struct PCIEPort PCIEPort;
 typedef struct PCIESlot PCIESlot;
 typedef struct MSIMessage MSIMessage;
 typedef struct SerialState SerialState;
-typedef struct IRQState *qemu_irq;
 typedef struct PCMCIACardState PCMCIACardState;
 typedef struct MouseTransformInfo MouseTransformInfo;
 typedef struct uWireSlave uWireSlave;
sysemu.h +1 -0
index 1093046..ad8d339 100644
@@ -9,6 +9,7 @@
 #include "qapi-types.h"
 #include "notify.h"
 #include "main-loop.h"
+#include "hw/irq.h"
 
 /* vl.c */
 
Signature · 1 line
1.7.11.4
#16 lore raw

RFC v2 12/13 include core qdev code into *-user, too

In reply to Eduardo Habkost

The code depends on some functions from qemu-option.o, so add qemu-option.o to universal-obj-y to make sure it's included.

---
 Makefile.objs                 | 3 +++
 hw/Makefile.objs              | 2 +-
 qom/Makefile.objs             | 2 +-
 {hw => qom}/qdev-core.c       | 0
 {hw => qom}/qdev-properties.c | 0
 5 files changed, 5 insertions(+), 2 deletions(-)
 rename {hw => qom}/qdev-core.c (100%)
 rename {hw => qom}/qdev-properties.c (100%)
Makefile.objs +3 -0
index 4412757..7b0950e 100644
@@ -16,6 +16,9 @@ universal-obj-y += $(qobject-obj-y)
 qom-obj-y = qom/
 
 universal-obj-y += $(qom-obj-y)
+# QOM qdev-core.o requires qemu-option.o:
+universal-obj-y += qemu-option.o
+
 
 #######################################################################
 # oslib-obj-y is code depending on the OS (win32 vs posix)
hw/Makefile.objs +1 -1
index c876e16..021d206 100644
@@ -178,7 +178,7 @@ common-obj-$(CONFIG_SD) += sd.o
 common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += msmouse.o ps2.o
-common-obj-y += qdev-core.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-monitor.o
 common-obj-y += qdev-system.o qdev-properties-system.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 
qom/Makefile.objs +1 -1
index 5ef060a..09ef871 100644
@@ -1,4 +1,4 @@
 qom-obj-y = object.o container.o qom-qobject.o
-qom-obj-twice-y = cpu.o
+qom-obj-twice-y = cpu.o qdev-core.o qdev-properties.o
 common-obj-y = $(qom-obj-twice-y)
 user-obj-y = $(qom-obj-twice-y)
qom/qdev-core.c renamed from hw/qdev-core.c +0 -0
similarity index 100%
rename from hw/qdev-core.c
rename to qom/qdev-core.c
qom/qdev-properties.c renamed from hw/qdev-properties.c +0 -0
similarity index 100%
rename from hw/qdev-properties.c
rename to qom/qdev-properties.c
Signature · 1 line
1.7.11.4
#10 lore raw

RFC v2 8/13 qdev-core: isolate reset register/unregister code

In reply to Eduardo Habkost

The reset register/unregister code is specific to qemu-system-*, so isolate it so it can be moved to qdev-system.c.

---
 hw/qdev-core.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
hw/qdev-core.c +18 -6
index a5cac45..1b45e51 100644
@@ -47,6 +47,21 @@ void GCC_WEAK qdev_finalize_vmstate(DeviceState *dev)
 {
 }
 
+static void qbus_register_reset(BusState *bus)
+{
+    if (bus != sysbus_get_default()) {
+        /* TODO: once all bus devices are qdevified,
+           only reset handler for main_system_bus should be registered here. */
+        qemu_register_reset(qbus_reset_all_fn, bus);
+    }
+}
+
+static void qbus_unregister_reset(BusState *bus)
+{
+    assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
+    qemu_unregister_reset(qbus_reset_all_fn, bus);
+}
+
 const char *qdev_fw_name(DeviceState *dev)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
@@ -348,10 +363,8 @@ static void qbus_realize(BusState *bus)
         QLIST_INSERT_HEAD(&bus->parent->child_bus, bus, sibling);
         bus->parent->num_child_bus++;
         object_property_add_child(OBJECT(bus->parent), bus->name, OBJECT(bus), NULL);
-    } else if (bus != sysbus_get_default()) {
-        /* TODO: once all bus devices are qdevified,
-           only reset handler for main_system_bus should be registered here. */
-        qemu_register_reset(qbus_reset_all_fn, bus);
+    } else {
+        qbus_register_reset(bus);
     }
 }
 
@@ -685,8 +698,7 @@ static void qbus_finalize(Object *obj)
         QLIST_REMOVE(bus, sibling);
         bus->parent->num_child_bus--;
     } else {
-        assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
-        qemu_unregister_reset(qbus_reset_all_fn, bus);
+        qbus_unregister_reset(bus);
     }
     g_free((char *)bus->name);
 }
Signature · 1 line
1.7.11.4
#14 lore raw

Re: [Qemu-devel] [RFC 10/13] move qemu_irq typedef out of cpu-common.h

In reply to Eduardo Habkost

sysemu.h line 14

Quoted 9 lines · Eduardo Habkost
sysemu.h +1 -0
@@ -9,6 +9,7 @@
 #include "qapi-types.h"
 #include "notify.h"
 #include "main-loop.h"
+#include "hw/irq.h"
 
 /* vl.c */

Igor's qemu_system_powerdown cleanup has hit master now, so sysemu.h doesn't need to include hw/irq.h now.

(You may find that this means some files which were implicitly getting hw/irq.h now need to include it directly, of course.)

-- PMM

#2 lore raw

Re: [Qemu-devel] [Qemu-trivial] [RFC 01/13] qdev: kill bogus comment

In reply to Eduardo Habkost
Quoted 8 lines · Eduardo Habkost

When the DeviceInfo code was removed, the comment describing qdev_subclass_init() was left in the code by mistake. Remove it.

---
 hw/qdev.c | 1 -
 1 file changed, 1 deletion(-)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan

Acked-by on v2 13/13
#18 lore raw

Re: [Qemu-devel] [RFC 13/13] make CPU a child of DeviceState

In reply to Eduardo Habkost

Ping for Peter,

This is a prerequisite for you ARM CPU reset as a GPIO idea. I'm on board with it, if we can get this through which will make it relatively painless to refactor my series.

Regards,
Peter

Quoted 6 lines · Eduardo Habkost

From: Igor Mammedov <[email protected]>

[ehabkost: change CPU type declaration to hae TYPE_DEVICE as parent]

Quoted 61 lines
---
 include/qemu/cpu.h | 6 +++---
 qom/cpu.c          | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
include/qemu/cpu.h +3 -3
index ad706a6..ac44057 100644
@@ -20,7 +20,7 @@
 #ifndef QEMU_CPU_H
 #define QEMU_CPU_H
 
-#include "qemu/object.h"
+#include "hw/qdev-core.h"
 #include "qemu-thread.h"
 
 /**
@@ -46,7 +46,7 @@ typedef struct CPUState CPUState;
  */
 typedef struct CPUClass {
     /*< private >*/
-    ObjectClass parent_class;
+    DeviceClass parent_class;
     /*< public >*/
 
     void (*reset)(CPUState *cpu);
@@ -59,7 +59,7 @@ typedef struct CPUClass {
  */
 struct CPUState {
     /*< private >*/
-    Object parent_obj;
+    DeviceState parent_obj;
     /*< public >*/
 
     struct QemuThread *thread;
qom/cpu.c +2 -2
index 5b36046..f59db7d 100644
@@ -20,6 +20,7 @@
 
 #include "qemu/cpu.h"
 #include "qemu-common.h"
+#include "hw/qdev-core.h"
 
 void cpu_reset(CPUState *cpu)
 {
@@ -43,7 +44,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
 
 static TypeInfo cpu_type_info = {
     .name = TYPE_CPU,
-    .parent = TYPE_OBJECT,
+    .parent = TYPE_DEVICE,
     .instance_size = sizeof(CPUState),
     .abstract = true,
     .class_size = sizeof(CPUClass),
--

1.7.11.4

#4 lore raw

Re: [Qemu-devel] [RFC 02/13] qdev: split up header so it can be used in cpu.h

In reply to Eduardo Habkost

Am 04.10.2012 21:15, schrieb Eduardo Habkost:

Quoted 10 lines

From: Anthony Liguori <[email protected]>

Header file dependency is a frickin' nightmare right now. cpu.h tends to get included in our 'include everything' header files but qdev also needs to include those headers mainly for qdev-properties since it knows about CharDriverState and friends.

We can solve this for now by splitting out qdev.h along the same lines that we previously split the C file. Then cpu.h just needs to include qdev-core.h

Quoted 6 lines

[ehabkost: re-add DEFINE_PROP_PCI_HOST_DEVADDR, that was removed on the
original patch (by mistake, I guess)]
[ehabkost: kill qdev_prop_set_vlan() declaration]

Generally I am still in favor of doing such a per-topic file split, in whatever way exactly we proceed with CPU-as-a-device.

If this is supposed to go through my CPU queue then I would prefer to move the [ehabkost: ...] lines chronologically between the Sobs fwiw.

What I would insist on is mentioning both new file names in the commit message (qdev-core.h and qdev-properties.h iiuc) since the +++ stats are ambiguous.

I spotted the following textual discrepancy:

Quoted 5 lines
hw/qdev-core.h new file +0 -0
new file mode 100644
index 0000000..ca205fc

[...]

Quoted 5 lines

+/*
+ * This callback is used to create Open Firmware device path in accordance with
+ * OF spec http://forthworks.com/standards/of1275.pdf. Indicidual bus bindings
+ * can be found here http://playground.sun.com/1275/bindings/.
+ */

[...]

Quoted 4 lines
hw/qdev.h +0 -0
index d699194..365b8d6 100644

[...]

hw/qdev.h line 96

Quoted 5 lines
hw/qdev.h +0 -5
-    /*
-     * This callback is used to create Open Firmware device path in accordance
-     * with OF spec http://forthworks.com/standards/of1275.pdf. Individual bus
-     * bindings can be found at http://playground.sun.com/1275/bindings/.
-     */

[snip]

"Individual" became "Indicidual" and the comment seems misplaced, which makes myself ask whether this split was not done safely via copy&paste?

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
#12 lore raw

Re: [Qemu-devel] [RFC 09/13] qdev: move reset register/unregister code to qdev-system.c

In reply to Eduardo Habkost
Quoted 46 lines · Eduardo Habkost

Also, add weak symbols that will be used if qdev-system.o is not compiled in (i.e. on *-user).

---
 hw/qdev-core.c   | 16 +++++++---------
 hw/qdev-core.h   |  3 +++
 hw/qdev-system.c | 15 +++++++++++++++
 3 files changed, 25 insertions(+), 9 deletions(-)
hw/qdev-core.c +7 -9
index 1b45e51..46ab239 100644
@@ -47,19 +47,17 @@ void GCC_WEAK qdev_finalize_vmstate(DeviceState *dev)
 {
 }
 
-static void qbus_register_reset(BusState *bus)
+/* reset handler register/unregister:
+ *
+ * The real implementations are on qdev-system.c. Those are weak symbols
+ * used by *-user.
+ */
+void GCC_WEAK qbus_register_reset(BusState *bus)
 {
-    if (bus != sysbus_get_default()) {
-        /* TODO: once all bus devices are qdevified,
-           only reset handler for main_system_bus should be registered here. */
-        qemu_register_reset(qbus_reset_all_fn, bus);
-    }
 }
 
-static void qbus_unregister_reset(BusState *bus)
+void GCC_WEAK qbus_unregister_reset(BusState *bus)
 {
-    assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
-    qemu_unregister_reset(qbus_reset_all_fn, bus);
 }
 
 const char *qdev_fw_name(DeviceState *dev)
hw/qdev-core.h +0 -0
index e9b6d6d..e10021d 100644

hw/qdev-core.h const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev); · line 232

Quoted 5 lines
hw/qdev-core.h +2 -0
@@ -228,6 +228,9 @@ const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
 void qdev_init_vmstate(DeviceState *dev);
 void qdev_finalize_vmstate(DeviceState *dev);
 
+void qbus_register_reset(BusState *bus);
+void qbus_unregister_reset(BusState *bus);

You also need to use GCC_WEAK_DECL here.

Regards,

Anthony Liguori

Quoted 29 lines
hw/qdev-core.h +1 -0
+
 const char *qdev_fw_name(DeviceState *dev);
 
 Object *qdev_get_machine(void);
hw/qdev-system.c +15 -0
index b4d40e8..eca5fd5 100644
@@ -113,3 +113,18 @@ void qdev_finalize_vmstate(DeviceState *dev)
         vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
     }
 }
+
+void qbus_register_reset(BusState *bus)
+{
+    if (bus != sysbus_get_default()) {
+        /* TODO: once all bus devices are qdevified,
+           only reset handler for main_system_bus should be registered here. */
+        qemu_register_reset(qbus_reset_all_fn, bus);
+    }
+}
+
+void qbus_unregister_reset(BusState *bus)
+{
+    assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
+    qemu_unregister_reset(qbus_reset_all_fn, bus);
+}
Signature · 1 line
1.7.11.4