include qdev core in *-user, make CPU child of DeviceState
RFC v2 3/13 qapi-types.h doesn't really need to include qemu-common.h
In reply to Eduardo HabkostFrom: 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
@@ -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
RFC v2 11/13 qdev: use full qdev.h include path on qdev*.c
In reply to Eduardo HabkostThis 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
@@ -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
@@ -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
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
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
@@ -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
Signature · 1 line
1.7.11.4
RFC v2 7/13 qdev: move vmstate handling to qdev-system.c
In reply to Eduardo HabkostAdd 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
@@ -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
@@ -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
@@ -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
RFC v2 1/13 qdev: kill bogus comment
In reply to Eduardo HabkostWhen 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
@@ -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
RFC v2 9/13 qdev: move reset register/unregister code to qdev-system.c
In reply to Eduardo HabkostAlso, 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
@@ -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
@@ -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
@@ -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
RFC v2 13/13 make CPU a child of DeviceState
In reply to Eduardo HabkostFrom: 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
@@ -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
@@ -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
RFC v2 4/13 qdev: separate core from the code used only by qemu-system-*
In reply to Eduardo HabkostThis 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
@@ -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
@@ -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
RFC v2 6/13 qdev-core: isolate vmstate handling into separate functions
In reply to Eduardo HabkostThose 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
@@ -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
RFC v2 2/13 qdev: split up header so it can be used in cpu.h
In reply to Eduardo HabkostFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
RFC v2 10/13 move qemu_irq typedef out of cpu-common.h
In reply to Eduardo HabkostFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -8,6 +8,7 @@*/ #include <inttypes.h> +#include "hw/irq.h" #include "qemu-common.h" /* xen-machine.c */
qemu-common.h +0 -1
@@ -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
@@ -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
RFC v2 12/13 include core qdev code into *-user, too
In reply to Eduardo HabkostThe 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
@@ -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
@@ -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
@@ -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
qom/qdev-properties.c renamed from hw/qdev-properties.c +0 -0
Signature · 1 line
1.7.11.4
RFC v2 8/13 qdev-core: isolate reset register/unregister code
In reply to Eduardo HabkostThe 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
@@ -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
Re: [Qemu-devel] [RFC 10/13] move qemu_irq typedef out of cpu-common.h
In reply to Eduardo Habkostsysemu.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
Stefan Hajnoczi
AppliedRe: [Qemu-devel] [Qemu-trivial] [RFC 01/13] qdev: kill bogus comment
In reply to Eduardo HabkostQuoted 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.Signed-off-by Eduardo Habkost <[email protected]>--- 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
Re: [Qemu-devel] [RFC 13/13] make CPU a child of DeviceState
In reply to Eduardo HabkostPing 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_DEVICEas parent]Signed-off-by Igor Mammedov <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
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@@ -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@@ -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
Re: [Qemu-devel] [RFC 02/13] qdev: split up header so it can be used in cpu.h
In reply to Eduardo HabkostAm 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.htends 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.halong the same lines that we previously split the C file. Thencpu.hjust needs to includeqdev-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: killqdev_prop_set_vlan()declaration]Signed-off-by Anthony Liguori <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
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
[...]
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
[...]
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
Re: [Qemu-devel] [RFC 09/13] qdev: move reset register/unregister code to qdev-system.c
In reply to Eduardo HabkostQuoted 46 lines · Eduardo Habkost
Also, add weak symbols that will be used if qdev-system.o is not compiled in (i.e. on *-user).
Signed-off-by Eduardo Habkost <[email protected]>--- 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@@ -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
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@@ -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