include qdev core in *-user, make CPU child of DeviceState
RFC 8/8 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 6/8 qdev: use full qdev.h include path on qdev*.c
In reply to Eduardo Habkost--- hw/qdev-properties.c | 2 +- hw/qdev.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
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"
hw/qdev.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"
Signature · 1 line
1.7.11.4
RFC 1/8 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/irq.h | 2 ++ hw/omap.h | 1 + hw/soc_dma.h | 1 + hw/xen.h | 1 + qemu-common.h | 1 - sysemu.h | 1 + 9 files changed, 11 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/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/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
@@ -273,7 +273,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 4/8 cleanup error.h, included qapi-types.h aready has stdbool.h
In reply to Eduardo HabkostFrom: Igor Mammedov <[email protected]>
--- error.h | 1 - 1 file changed, 1 deletion(-)
error.h +0 -1
@@ -14,7 +14,6 @@#include "compiler.h" #include "qapi-types.h" -#include <stdbool.h> /** * A class representing internal errors within QEMU. An error has a ErrorClass
Signature · 1 line
1.7.11.4
RFC 7/8 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 qom-obj-y to make sure it's included.
--- Makefile.objs | 1 + hw/Makefile.objs | 2 +- qom/Makefile.objs | 2 +- hw/qdev-properties.c => qom/device-properties.c | 0 hw/qdev.c => qom/device.c | 0 5 files changed, 3 insertions(+), 2 deletions(-) rename hw/qdev-properties.c => qom/device-properties.c (100%) rename hw/qdev.c => qom/device.c (100%)
Makefile.objs +1 -0
@@ -14,6 +14,7 @@ universal-obj-y += $(qobject-obj-y) ####################################################################### # QOM qom-obj-y = qom/ +qom-obj-y += qemu-option.o universal-obj-y += $(qom-obj-y)
hw/Makefile.objs +1 -1
@@ -176,7 +176,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-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 device.o device-properties.o common-obj-y = $(qom-obj-twice-y) user-obj-y = $(qom-obj-twice-y)
qom/device-properties.c renamed from hw/qdev-properties.c +0 -0
qom/device.c renamed from hw/qdev.c +0 -0
Signature · 1 line
1.7.11.4
RFC 3/8 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
--- scripts/qapi-types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qapi-types.py +1 -1
@@ -263,7 +263,7 @@ fdecl.write(mcgen(''' #ifndef %(guard)s #define %(guard)s -#include "qemu-common.h" +#include <stdbool.h> ''', guard=guardname(h_file)))
Signature · 1 line
1.7.11.4
RFC 2/8 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
v1->v2:
move qemu_irq typedef out of this patch into a separate one with an additional cleanup of headers to fix build breakage
--- 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 | 128 ++++++++++++++++++ hw/qdev.c | 1 + hw/qdev.h | 371 +-------------------------------------------------- 8 files changed, 392 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/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 +128 -0
128 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
cover include qdev core in *-user, make CPU child of DeviceState
So, here's a third suggestion to the CPU/DeviceState problem. Basically I split the qdev code into a core (that can be easily compiled into *-user), and a part specific to qemu-system-*.
There are two remaining parts that forced me to use #ifdefs in the "core" .c files:
- vmstate handling on qdev_init()
- the qemu_register_reset() hack
If we address those two issues inside qemu-system-* (instead of inside the qdev core code), using DeviceState inside *-user shouldn't be a big problem anymore.
Anthony Liguori (1):
qdev: split up header so it can be used in cpu.h
Eduardo Habkost (3):
split qdev into a core and code used only by qemu-system-*
qdev: use full qdev.h include path on qdev*.c include core qdev code into *-user, too
Igor Mammedov (4):
move qemu_irq typedef out of cpu-common.h qapi-types.h doesn't really need to include qemu-common.h cleanup error.h, included qapi-types.h aready has stdbool.h make CPU a child of DeviceState
Makefile.objs | 1 + error.h | 1 - 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 | 240 +++++++++++++++ hw/qdev-monitor.h | 16 + hw/qdev-properties-system.c | 329 +++++++++++++++++++++ hw/qdev-properties.h | 129 ++++++++ hw/qdev-system.c | 93 ++++++ 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-properties.c => qom/device-properties.c | 323 +-------------------- hw/qdev.c => qom/device.c | 106 +------ scripts/qapi-types.py | 2 +- sysemu.h | 1 + 26 files changed, 849 insertions(+), 790 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-properties.c => qom/device-properties.c (75%) rename hw/qdev.c => qom/device.c (89%)
Signature · 1 line
1.7.11.4
RFC 5/8 split qdev into a core and code used only by qemu-system-*
This also makes it visible what are the parts of qdev that we may want to split more cleanly (as they are using #ifdefs, now).
There are basically two parts that are specific to qemu-system-*, but are still inside qdev.c (but inside a "#ifndef CONFIG_USER_ONLY").
- vmstate handling
- reset function registration
--- 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 | 103 ++------------ 6 files changed, 435 insertions(+), 412 deletions(-) create mode 100644 hw/qdev-properties-system.c create mode 100644 hw/qdev-system.c
hw/Makefile.objs +1 -0
@@ -177,6 +177,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
@@ -114,6 +114,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 +10 -93
159 lines not on this page · raw message
Signature · 1 line
1.7.11.4
Re: [Qemu-devel] [RFC 1/8] move qemu_irq typedef out of cpu-common.h
In reply to Eduardo HabkostQuoted 17 lines · Eduardo Habkost
qemu-common.h +0
-1@@ -273,7 +273,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 +0
-0
sysemu.h line 14
Quoted 6 lines
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 */
I'm not objecting to this patch if it helps us move forwards, but adding the #include to sysemu.h is effectively just adding the definition to another grabbag header (183 files include sysemu.h). It would be nicer long-term to separate out the one thing in this header that cares about qemu_irq (the extern declaration of qemu_system_powerdown).
[I'm not really convinced that a qemu_irq is even the right way to signal "hey the system has actually powered down now"...]
-- PMM
Re: [Qemu-devel] [RFC 6/8] qdev: use full qdev.h include path on qdev*.c
In reply to Eduardo HabkostQuoted 1 line · Eduardo Habkost
Signed-off-by Eduardo Habkost <[email protected]>
This could use a commit message saying why rather than merely what the patch does.
-- PMM
Re: [Qemu-devel] [RFC 4/8] cleanup error.h, included qapi-types.h aready has stdbool.h
In reply to Eduardo HabkostQuoted 3 lines · Eduardo Habkost
From: Igor Mammedov <[email protected]>
Signed-off-by Igor Mammedov <[email protected]>
I thought we'd agreed to drop this patch?
http://lists.gnu.org/archive/html/qemu-devel/2012-08/msg03644.html
-- PMM
Re: [Qemu-devel] [RFC 4/8] cleanup error.h, included qapi-types.h aready has stdbool.h
Quoted 7 lines · Peter Maydell
Quoted 3 lines · Eduardo Habkost
From: Igor Mammedov <[email protected]>
Signed-off-by Igor Mammedov <[email protected]>I thought we'd agreed to drop this patch?
http://lists.gnu.org/archive/html/qemu-devel/2012-08/msg03644.html
Sure. I just used the existing series as base. The main point is to ask for comments about the last 4 patches.
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 7/8] include core qdev code into *-user, too
In reply to Eduardo HabkostQuoted 19 lines · Eduardo Habkost
The code depends on some functions from qemu-option.o, so add qemu-option.o to qom-obj-y to make sure it's included.
Signed-off-by Eduardo Habkost <[email protected]>--- Makefile.objs | 1 + hw/Makefile.objs | 2 +- qom/Makefile.objs | 2 +- hw/qdev-properties.c => qom/device-properties.c | 0 hw/qdev.c => qom/device.c | 0 5 files changed, 3 insertions(+), 2 deletions(-) rename hw/qdev-properties.c => qom/device-properties.c (100%) rename hw/qdev.c => qom/device.c (100%)Makefile.objs +0
-0
Makefile.objs universal-obj-y += $(qobject-obj-y) · line 17
Quoted 4 lines
Makefile.objs +1
-0@@ -14,6 +14,7 @@ universal-obj-y += $(qobject-obj-y) ####################################################################### # QOM qom-obj-y = qom/ +qom-obj-y += qemu-option.o
qemu-option.c isn't actually QOM related code...
-- PMM
Re: [Qemu-devel] [RFC 3/8] qapi-types.h doesn't really need to include qemu-common.h
In reply to Eduardo HabkostQuoted 14 lines · On Tue, 21 Aug 2012 12:42:57 -0300 Eduardo Habkost <[email protected]> wrote:
From: Igor Mammedov <[email protected]>
needed to prevent build breakage when CPU becomes a child of DeviceState
Signed-off-by Igor Mammedov <[email protected]>--- scripts/qapi-types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/qapi-types.py +0
-0
scripts/qapi-types.py fdecl.write(mcgen(''' · line 266
Quoted 5 lines
scripts/qapi-types.py +1
-1@@ -263,7 +263,7 @@ fdecl.write(mcgen(''' #ifndef %(guard)s #define %(guard)s -#include "qemu-common.h" +#include <stdbool.h>
Case you didn't notice my last review: we should also include <stdint.h> here.
Quoted 3 lines
scripts/qapi-types.py +0
-0''', guard=guardname(h_file)))
Re: [Qemu-devel] [RFC 6/8] qdev: use full qdev.h include path on qdev*.c
In reply to Peter MaydellQuoted 5 lines · Peter Maydell
Quoted 1 line · Eduardo Habkost
Signed-off-by Eduardo Habkost <[email protected]>This could use a commit message saying why rather than merely what the patch does.
Sorry. The reason is to allow the files to be moved inside "qom/" in the next commit.
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 5/8] split qdev into a core and code used only by qemu-system-*
In reply to Eduardo HabkostQuoted 2 lines · Eduardo Habkost
This also makes it visible what are the parts of qdev that we may want to split more cleanly (as they are using #ifdefs, now).
Nice.
hw/qdev-properties-system.c
Quoted 37 lines
There are basically two parts that are specific to qemu-system-*, but are still inside
qdev.c(but inside a "#ifndefCONFIG_USER_ONLY").- vmstate handling
- reset function registrationSigned-off-by Eduardo Habkost <[email protected]>--- 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 | 103 ++------------ 6 files changed, 435 insertions(+), 412 deletions(-) create mode 100644 hw/qdev-properties-system.c create mode 100644 hw/qdev-system.chw/Makefile.objs +1
-0@@ -177,6 +177,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 supporthw/qdev-properties-system.c new file +0
-0@@ -0,0 +1,329 @@
There's no header, neither has qdev-properties.c though. Agreeing on license would need some detective work.
Quoted 51 lines
hw/qdev-properties-system.c new file +51
-0+#include "net.h" +#include "qdev.h" +#include "qerror.h" +#include "blockdev.h" +#include "hw/block-common.h" +#include "net/hub.h" +#include "qapi/qapi-visit-core.h" + +static void get_pointer (Object *obj,Visitor *v,Property *prop, +const char *(*print)(void *ptr), +const char *name,Error **errp) +{ +DeviceState *dev =DEVICE (obj); +void **ptr =qdev_get_prop_ptr (dev, prop); +char *p; + + p = (char *) (*ptr ?"" ); +visit_type_str (v, &p, name, errp); +} + +static void set_pointer (Object *obj,Visitor *v,Property *prop, +int (*parse)(DeviceState *dev,const char *str, +void **ptr), +const char *name,Error **errp) +{ +DeviceState *dev =DEVICE (obj); +Error *local_err =NULL ; +void **ptr =qdev_get_prop_ptr (dev, prop); +char *str; +int ret; + +if (dev->state !=DEV_STATE_CREATED ) { +error_set (errp,QERR_PERMISSION_DENIED ); +return ; + } + +visit_type_str (v, &str, name, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } +if (!*str) { +g_free (str); + *ptr =NULL ; +return ; + } + ret =parse (dev, str, ptr); +error_set_from_qdev_prop_error (errp, ret, dev, prop, str); +g_free (str); +} +
hw/qdev-properties-system.c line 61
Quoted 10 lines
hw/qdev-properties-system.c new file +10
-0+ +/* --- drive --- */ + +static int parse_drive (DeviceState *dev,const char *str,void **ptr) +{ +BlockDriverState *bs; + + bs =bdrv_find (str); +if (bs ==NULL ) +return -ENOENT ;
Before moving, please add braces here and below if. That way the new file gets a fresh start.
Quoted 666 lines
hw/qdev-properties-system.c new file +268
-0+if (bdrv_attach_dev (bs, dev) <0 ) +return -EEXIST ; + *ptr = bs; +return 0 ; +} + +static void release_drive (Object *obj,const char *name,void *opaque) +{ +DeviceState *dev =DEVICE (obj); +Property *prop = opaque; +BlockDriverState **ptr =qdev_get_prop_ptr (dev, prop); + +if (*ptr) { +bdrv_detach_dev (*ptr, dev); +blockdev_auto_del (*ptr); + } +} + +static const char *print_drive (void *ptr) +{ +return bdrv_get_device_name (ptr); +} + +static void get_drive (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +get_pointer (obj, v, opaque, print_drive, name, errp); +} + +static void set_drive (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +set_pointer (obj, v, opaque, parse_drive, name, errp); +} + +PropertyInfo qdev_prop_drive = { + .name ="drive" , + .get = get_drive, + .set = set_drive, + .release = release_drive, +}; + +/* --- character device --- */ + +static int parse_chr (DeviceState *dev,const char *str,void **ptr) +{ +CharDriverState *chr =qemu_chr_find (str); +if (chr ==NULL ) { +return -ENOENT ; + } +if (chr->avail_connections <1 ) { +return -EEXIST ; + } + *ptr = chr; + --chr->avail_connections; +return 0 ; +} + +static void release_chr (Object *obj,const char *name,void *opaque) +{ +DeviceState *dev =DEVICE (obj); +Property *prop = opaque; +CharDriverState **ptr =qdev_get_prop_ptr (dev, prop); + +if (*ptr) { +qemu_chr_add_handlers (*ptr,NULL ,NULL ,NULL ,NULL ); + } +} + + +static const char *print_chr (void *ptr) +{ +CharDriverState *chr = ptr; + +return chr->label ? chr->label :"" ; +} + +static void get_chr (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +get_pointer (obj, v, opaque, print_chr, name, errp); +} + +static void set_chr (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +set_pointer (obj, v, opaque, parse_chr, name, errp); +} + +PropertyInfo qdev_prop_chr = { + .name ="chr" , + .get = get_chr, + .set = set_chr, + .release = release_chr, +}; + +/* --- netdev device --- */ + +static int parse_netdev (DeviceState *dev,const char *str,void **ptr) +{ +NetClientState *netdev =qemu_find_netdev (str); + +if (netdev ==NULL ) { +return -ENOENT ; + } +if (netdev->peer) { +return -EEXIST ; + } + *ptr = netdev; +return 0 ; +} + +static const char *print_netdev (void *ptr) +{ +NetClientState *netdev = ptr; + +return netdev->name ? netdev->name :"" ; +} + +static void get_netdev (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +get_pointer (obj, v, opaque, print_netdev, name, errp); +} + +static void set_netdev (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +set_pointer (obj, v, opaque, parse_netdev, name, errp); +} + +PropertyInfo qdev_prop_netdev = { + .name ="netdev" , + .get = get_netdev, + .set = set_netdev, +}; + +/* --- vlan --- */ + +static int print_vlan (DeviceState *dev,Property *prop,char *dest,size_t len) +{ +NetClientState **ptr =qdev_get_prop_ptr (dev, prop); + +if (*ptr) { +int id; +if (!net_hub_id_for_client (*ptr, &id)) { +return snprintf (dest, len,"%d" , id); + } + } + +return snprintf (dest, len,"<null>" ); +} + +static void get_vlan (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +DeviceState *dev =DEVICE (obj); +Property *prop = opaque; +NetClientState **ptr =qdev_get_prop_ptr (dev, prop); +int32_t id =-1 ; + +if (*ptr) { +int hub_id; +if (!net_hub_id_for_client (*ptr, &hub_id)) { + id = hub_id; + } + } + +visit_type_int32 (v, &id, name, errp); +} + +static void set_vlan (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +DeviceState *dev =DEVICE (obj); +Property *prop = opaque; +NetClientState **ptr =qdev_get_prop_ptr (dev, prop); +Error *local_err =NULL ; +int32_t id; +NetClientState *hubport; + +if (dev->state !=DEV_STATE_CREATED ) { +error_set (errp,QERR_PERMISSION_DENIED ); +return ; + } + +visit_type_int32 (v, &id, name, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } +if (id ==-1 ) { + *ptr =NULL ; +return ; + } + + hubport =net_hub_port_find (id); +if (!hubport) { +error_set (errp,QERR_INVALID_PARAMETER_VALUE , + name, prop->info->name); +return ; + } + *ptr = hubport; +} + +PropertyInfo qdev_prop_vlan = { + .name ="vlan" , + .print = print_vlan, + .get = get_vlan, + .set = set_vlan, +}; + + +int qdev_prop_set_drive (DeviceState *dev,const char *name,BlockDriverState *value) +{ +Error *errp =NULL ; +const char *bdrv_name = value ?bdrv_get_device_name (value) :"" ; +object_property_set_str (OBJECT (dev), bdrv_name, + name, &errp); +if (errp) { +qerror_report_err (errp); +error_free (errp); +return -1 ; + } +return 0 ; +} + +void qdev_prop_set_drive_nofail (DeviceState *dev,const char *name,BlockDriverState *value) +{ +if (qdev_prop_set_drive (dev, name, value) <0 ) { +exit (1 ); + } +} + +void qdev_prop_set_chr (DeviceState *dev,const char *name,CharDriverState *value) +{ +Error *errp =NULL ; +assert (!value || value->label); +object_property_set_str (OBJECT (dev), + value ? value->label :"" , name, &errp); +assert_no_error (errp); +} + +void qdev_prop_set_netdev (DeviceState *dev,const char *name,NetClientState *value) +{ +Error *errp =NULL ; +assert (!value || value->name); +object_property_set_str (OBJECT (dev), + value ? value->name :"" , name, &errp); +assert_no_error (errp); +} + +static int qdev_add_one_global (QemuOpts *opts,void *opaque) +{ +GlobalProperty *g; + + g =g_malloc0 (sizeof (*g)); + g->driver =qemu_opt_get (opts,"driver" ); + g->property =qemu_opt_get (opts,"property" ); + g->value =qemu_opt_get (opts,"value" ); +qdev_prop_register_global (g); +return 0 ; +} + +void qemu_add_globals (void ) +{ +qemu_opts_foreach (qemu_find_opts ("global" ), qdev_add_one_global,NULL ,0 ); +}hw/qdev-properties.c +1
-319@@ -13,49 +13,6 @@ void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)return ptr; } -static void get_pointer (Object *obj,Visitor *v,Property *prop, -const char *(*print)(void *ptr), -const char *name,Error **errp) -{ -DeviceState *dev =DEVICE (obj); -void **ptr =qdev_get_prop_ptr (dev, prop); -char *p; - - p = (char *) (*ptr ?"" ); -visit_type_str (v, &p, name, errp); -} - -static void set_pointer (Object *obj,Visitor *v,Property *prop, -int (*parse)(DeviceState *dev,const char *str, -void **ptr), -const char *name,Error **errp) -{ -DeviceState *dev =DEVICE (obj); -Error *local_err =NULL ; -void **ptr =qdev_get_prop_ptr (dev, prop); -char *str; -int ret; - -if (dev->state !=DEV_STATE_CREATED ) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_str (v, &str, name, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return ; - } -if (!*str) { -g_free (str); - *ptr =NULL ; -return ; - } - ret =parse (dev, str, ptr); -error_set_from_qdev_prop_error (errp, ret, dev, prop, str); -g_free (str); -} -static void get_enum (Object *obj,Visitor *v,void *opaque,const char *name,Error **errp) {@@ -476,227 +433,6 @@ PropertyInfo qdev_prop_string = { .set = set_string, }; -/* --- drive --- */ - -static int parse_drive (DeviceState *dev,const char *str,void **ptr) -{ -BlockDriverState *bs; - - bs =bdrv_find (str); -if (bs ==NULL ) -return -ENOENT ; -if (bdrv_attach_dev (bs, dev) <0 ) -return -EEXIST ; - *ptr = bs; -return 0 ; -} - -static void release_drive (Object *obj,const char *name,void *opaque) -{ -DeviceState *dev =DEVICE (obj); -Property *prop = opaque; -BlockDriverState **ptr =qdev_get_prop_ptr (dev, prop); - -if (*ptr) { -bdrv_detach_dev (*ptr, dev); -blockdev_auto_del (*ptr); - } -} - -static const char *print_drive (void *ptr) -{ -return bdrv_get_device_name (ptr); -} - -static void get_drive (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -get_pointer (obj, v, opaque, print_drive, name, errp); -} - -static void set_drive (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -set_pointer (obj, v, opaque, parse_drive, name, errp); -} - -PropertyInfo qdev_prop_drive = { - .name ="drive" , - .get = get_drive, - .set = set_drive, - .release = release_drive, -}; - -/* --- character device --- */ - -static int parse_chr (DeviceState *dev,const char *str,void **ptr) -{ -CharDriverState *chr =qemu_chr_find (str); -if (chr ==NULL ) { -return -ENOENT ; - } -if (chr->avail_connections <1 ) { -return -EEXIST ; - } - *ptr = chr; - --chr->avail_connections; -return 0 ; -} - -static void release_chr (Object *obj,const char *name,void *opaque) -{ -DeviceState *dev =DEVICE (obj); -Property *prop = opaque; -CharDriverState **ptr =qdev_get_prop_ptr (dev, prop); - -if (*ptr) { -qemu_chr_add_handlers (*ptr,NULL ,NULL ,NULL ,NULL ); - } -} - - -static const char *print_chr (void *ptr) -{ -CharDriverState *chr = ptr; - -return chr->label ? chr->label :"" ; -} - -static void get_chr (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -get_pointer (obj, v, opaque, print_chr, name, errp); -} - -static void set_chr (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -set_pointer (obj, v, opaque, parse_chr, name, errp); -} - -PropertyInfo qdev_prop_chr = { - .name ="chr" , - .get = get_chr, - .set = set_chr, - .release = release_chr, -}; - -/* --- netdev device --- */ - -static int parse_netdev (DeviceState *dev,const char *str,void **ptr) -{ -NetClientState *netdev =qemu_find_netdev (str); - -if (netdev ==NULL ) { -return -ENOENT ; - } -if (netdev->peer) { -return -EEXIST ; - } - *ptr = netdev; -return 0 ; -} - -static const char *print_netdev (void *ptr) -{ -NetClientState *netdev = ptr; - -return netdev->name ? netdev->name :"" ; -} - -static void get_netdev (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -get_pointer (obj, v, opaque, print_netdev, name, errp); -} - -static void set_netdev (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -set_pointer (obj, v, opaque, parse_netdev, name, errp); -} - -PropertyInfo qdev_prop_netdev = { - .name ="netdev" , - .get = get_netdev, - .set = set_netdev, -}; - -/* --- vlan --- */ - -static int print_vlan (DeviceState *dev,Property *prop,char *dest,size_t len) -{ -NetClientState **ptr =qdev_get_prop_ptr (dev, prop); - -if (*ptr) { -int id; -if (!net_hub_id_for_client (*ptr, &id)) { -return snprintf (dest, len,"%d" , id); - } - } - -return snprintf (dest, len,"<null>" ); -} - -static void get_vlan (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -DeviceState *dev =DEVICE (obj); -Property *prop = opaque; -NetClientState **ptr =qdev_get_prop_ptr (dev, prop); -int32_t id =-1 ; - -if (*ptr) { -int hub_id; -if (!net_hub_id_for_client (*ptr, &hub_id)) { - id = hub_id; - } - } - -visit_type_int32 (v, &id, name, errp); -} - -static void set_vlan (Object *obj,Visitor *v,void *opaque, -const char *name,Error **errp) -{ -DeviceState *dev =DEVICE (obj); -Property *prop = opaque; -NetClientState **ptr =qdev_get_prop_ptr (dev, prop); -Error *local_err =NULL ; -int32_t id; -NetClientState *hubport; - -if (dev->state !=DEV_STATE_CREATED ) { -error_set (errp,QERR_PERMISSION_DENIED ); -return ; - } - -visit_type_int32 (v, &id, name, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return ; - } -if (id ==-1 ) { - *ptr =NULL ; -return ; - } - - hubport =net_hub_port_find (id); -if (!hubport) { -error_set (errp,QERR_INVALID_PARAMETER_VALUE , - name, prop->info->name); -return ; - } - *ptr = hubport; -} - -PropertyInfo qdev_prop_vlan = { - .name ="vlan" , - .print = print_vlan, - .get = get_vlan, - .set = set_vlan, -}; -/* --- pointer --- */ /* Not a proper property, just for dirty hacks. TODO Remove it! */ @@ -1158,44 +894,6 @@ void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value)assert_no_error (errp); } -int qdev_prop_set_drive (DeviceState *dev,const char *name,BlockDriverState *value) -{ -Error *errp =NULL ; -const char *bdrv_name = value ?bdrv_get_device_name (value) :"" ; -object_property_set_str (OBJECT (dev), bdrv_name, - name, &errp); -if (errp) { -qerror_report_err (errp); -error_free (errp); -return -1 ; - } -return 0 ; -} - -void qdev_prop_set_drive_nofail (DeviceState *dev,const char *name,BlockDriverState *value) -{ -if (qdev_prop_set_drive (dev, name, value) <0 ) { -exit (1 ); - } -} -void qdev_prop_set_chr (DeviceState *dev,const char *name,CharDriverState *value) -{ -Error *errp =NULL ; -assert (!value || value->label); -object_property_set_str (OBJECT (dev), - value ? value->label :"" , name, &errp); -assert_no_error (errp); -} - -void qdev_prop_set_netdev (DeviceState *dev,const char *name,NetClientState *value) -{ -Error *errp =NULL ; -assert (!value || value->name); -object_property_set_str (OBJECT (dev), - value ? value->name :"" , name, &errp); -assert_no_error (errp); -} -void qdev_prop_set_macaddr (DeviceState *dev,const char *name,uint8_t *value) {Error *errp =NULL ;@@ -1231,7 +929,7 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value) static QTAILQ_HEAD(, GlobalProperty) global_props = QTAILQ_HEAD_INITIALIZER(global_props); -static void qdev_prop_register_global (GlobalProperty *prop) +void qdev_prop_register_global (GlobalProperty *prop) {QTAILQ_INSERT_TAIL (&global_props, prop, next); }@@ -1263,19 +961,3 @@ void qdev_prop_set_globals(DeviceState *dev) }while (class); } -static int qdev_add_one_global (QemuOpts *opts,void *opaque) -{ -GlobalProperty *g; - - g =g_malloc0 (sizeof (*g)); - g->driver =qemu_opt_get (opts,"driver" ); - g->property =qemu_opt_get (opts,"property" ); - g->value =qemu_opt_get (opts,"value" ); -qdev_prop_register_global (g); -return 0 ; -} - -void qemu_add_globals (void ) -{ -qemu_opts_foreach (qemu_find_opts ("global" ), qdev_add_one_global,NULL ,0 ); -}hw/qdev-properties.h +1
-0@@ -114,6 +114,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 +24
-0@@ -0,0 +1,93 @@ +#include "net.h" +#include "qdev.h" + +void qdev_init_gpio_in (DeviceState *dev,qemu_irq_handler handler,int n) +{ +assert (dev->num_gpio_in ==0 ); + dev->num_gpio_in = n; + dev->gpio_in =qemu_allocate_irqs (handler, dev, n); +} + +void qdev_init_gpio_out (DeviceState *dev,qemu_irq *pins,int n) +{ +assert (dev->num_gpio_out ==0 ); + dev->num_gpio_out = n; + dev->gpio_out = pins; +} + +qemu_irq qdev_get_gpio_in (DeviceState *dev,int n) +{ +assert (n >=0 && n < dev->num_gpio_in); +return dev->gpio_in[n]; +} + +void qdev_connect_gpio_out (DeviceState * dev,int n,qemu_irq pin)
hw/qdev-system.c line 34
Quoted 10 lines
hw/qdev-system.c new file +10
-0+{ +assert (n >=0 && n < dev->num_gpio_out); + dev->gpio_out[n] = pin; +} + +void qdev_set_nic_properties (DeviceState *dev,NICInfo *nd) +{ +qdev_prop_set_macaddr (dev,"mac" , nd->macaddr.a); +if (nd->netdev) +qdev_prop_set_netdev (dev,"netdev" , nd->netdev);
Also here.
Quoted 232 lines
hw/qdev-system.c new file +59
-0+if (nd->nvectors !=DEV_NVECTORS_UNSPECIFIED && +object_property_find (OBJECT (dev),"vectors" ,NULL )) { +qdev_prop_set_uint32 (dev,"vectors" , nd->nvectors); + } + nd->instantiated =1 ; +} + +BusState *qdev_get_child_bus (DeviceState *dev,const char *name) +{ +BusState *bus; + + QLIST_FOREACH(bus, &dev->child_bus, sibling) { +if (strcmp (name, bus->name) ==0 ) { +return bus; + } + } +return NULL ; +} + +/* Create a new device. This only initializes the device state structure +and allows properties to be set. qdev_init should be called to +initialize the actual device emulation. */ +DeviceState *qdev_create (BusState *bus,const char *name) +{ +DeviceState *dev; + + dev =qdev_try_create (bus, name); +if (!dev) { +if (bus) { +hw_error ("Unknown device '%s' for bus '%s'\n" , name, +object_get_typename (OBJECT (bus))); + }else { +hw_error ("Unknown device '%s' for default sysbus\n" , name); + } + } + +return dev; +} + +DeviceState *qdev_try_create (BusState *bus,const char *type) +{ +DeviceState *dev; + +if (object_class_by_name (type) ==NULL ) { +return NULL ; + } + dev =DEVICE (object_new (type)); +if (!dev) { +return NULL ; + } + +if (!bus) { + bus =sysbus_get_default (); + } + +qdev_set_parent_bus (dev, bus); + +return dev; +}hw/qdev.c +10
-94@@ -25,7 +25,6 @@inherit from a particular bus (e.g. PCI or I2C) rather than this API directly. */ -#include "net.h" #include "qdev.h" #include "sysemu.h" #include "error.h" @@ -105,47 +104,6 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)bus_add_child (bus, dev); } -/* Create a new device. This only initializes the device state structure -and allows properties to be set. qdev_init should be called to -initialize the actual device emulation. */ -DeviceState *qdev_create (BusState *bus,const char *name) -{ -DeviceState *dev; - - dev =qdev_try_create (bus, name); -if (!dev) { -if (bus) { -hw_error ("Unknown device '%s' for bus '%s'\n" , name, -object_get_typename (OBJECT (bus))); - }else { -hw_error ("Unknown device '%s' for default sysbus\n" , name); - } - } - -return dev; -} - -DeviceState *qdev_try_create (BusState *bus,const char *type) -{ -DeviceState *dev; - -if (object_class_by_name (type) ==NULL ) { -return NULL ; - } - dev =DEVICE (object_new (type)); -if (!dev) { -return NULL ; - } - -if (!bus) { - bus =sysbus_get_default (); - } - -qdev_set_parent_bus (dev, bus); - -return dev; -} -/* Initialize a device. Device properties should be set before calling this function. IRQs and MMIO regions should be connected/mapped after calling this function. @@ -175,11 +133,13 @@ int qdev_init(DeviceState *dev)g_free (name); } +#ifndef CONFIG_USER_ONLY 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); } +#endif dev->state =DEV_STATE_INITIALIZED ;if (dev->hotplugged) {device_reset (dev);@@ -292,56 +252,6 @@ BusState *qdev_get_parent_bus(DeviceState *dev)return dev->parent_bus; } -void qdev_init_gpio_in (DeviceState *dev,qemu_irq_handler handler,int n) -{ -assert (dev->num_gpio_in ==0 ); - dev->num_gpio_in = n; - dev->gpio_in =qemu_allocate_irqs (handler, dev, n); -} - -void qdev_init_gpio_out (DeviceState *dev,qemu_irq *pins,int n) -{ -assert (dev->num_gpio_out ==0 ); - dev->num_gpio_out = n; - dev->gpio_out = pins; -} - -qemu_irq qdev_get_gpio_in (DeviceState *dev,int n) -{ -assert (n >=0 && n < dev->num_gpio_in); -return dev->gpio_in[n]; -} - -void qdev_connect_gpio_out (DeviceState * dev,int n,qemu_irq pin) -{ -assert (n >=0 && n < dev->num_gpio_out); - dev->gpio_out[n] = pin; -} - -void qdev_set_nic_properties (DeviceState *dev,NICInfo *nd) -{ -qdev_prop_set_macaddr (dev,"mac" , nd->macaddr.a); -if (nd->netdev) -qdev_prop_set_netdev (dev,"netdev" , nd->netdev); -if (nd->nvectors !=DEV_NVECTORS_UNSPECIFIED && -object_property_find (OBJECT (dev),"vectors" ,NULL )) { -qdev_prop_set_uint32 (dev,"vectors" , nd->nvectors); - } - nd->instantiated =1 ; -} - -BusState *qdev_get_child_bus (DeviceState *dev,const char *name) -{ -BusState *bus; - - QLIST_FOREACH(bus, &dev->child_bus, sibling) { -if (strcmp (name, bus->name) ==0 ) { -return bus; - } - } -return NULL ; -} -int qbus_walk_children (BusState *bus,qdev_walkerfn *devfn,qbus_walkerfn *busfn,void *opaque) {@@ -440,11 +350,14 @@ 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 ()) { + } +#ifndef CONFIG_USER_ONLY + 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); } +#endif } void qbus_create_inplace(BusState *bus, const char *typename,@@ -703,9 +616,11 @@ static void device_finalize(Object *obj) bus =QLIST_FIRST (&dev->child_bus);qbus_free (bus); } +#ifndef CONFIG_USER_ONLY if (qdev_get_vmsd (dev)) {vmstate_unregister (dev,qdev_get_vmsd (dev), dev); } +#endif if (dc->exit) { dc->exit (dev); }@@ -779,8 +694,10 @@ static void qbus_finalize(Object *obj)QLIST_REMOVE (bus, sibling); bus->parent->num_child_bus--; }else { +#ifndef CONFIG_USER_ONLY assert (bus !=sysbus_get_default ());/* main_system_bus is never freed */ qemu_unregister_reset (qbus_reset_all_fn, bus); +#endif }g_free ((char *)bus->name); } --1.7.11.4
Re: [Qemu-devel] [RFC 7/8] include core qdev code into *-user, too
In reply to Peter MaydellQuoted 15 lines · Peter Maydell
Quoted 14 lines · Eduardo Habkost
The code depends on some functions from qemu-option.o, so add qemu-option.o to qom-obj-y to make sure it's included.
Signed-off-by Eduardo Habkost <[email protected]>--- Makefile.objs | 1 + hw/Makefile.objs | 2 +- qom/Makefile.objs | 2 +- hw/qdev-properties.c => qom/device-properties.c | 0 hw/qdev.c => qom/device.c | 0 5 files changed, 3 insertions(+), 2 deletions(-) rename hw/qdev-properties.c => qom/device-properties.c (100%) rename hw/qdev.c => qom/device.c (100%)
Quoted 11 lines
Makefile.objs universal-obj-y += $(qobject-obj-y) · line 17
Quoted 9 lines
Makefile.objs +1
-0@@ -14,6 +14,7 @@ universal-obj-y += $(qobject-obj-y) ####################################################################### # QOM qom-obj-y = qom/ +qom-obj-y += qemu-option.o
qemu-option.cisn't actually QOM related code...
True, but it's a dependency of the QOM DeviceState code. I don't know if qom-obj-y is for "the QOM code" or "QOM code + dependencies".
I simply added it to qom-obj-y to avoid having to repeat myself (otherwise I would need to add qemu-option.o to both common-obj-y and user-obj-y).
Signature · 1 line
Eduardo
Quoted 4 lines · Eduardo Habkost
So, here's a third suggestion to the CPU/DeviceState problem. Basically I split the qdev code into a core (that can be easily compiled into *-user), and a part specific to qemu-system-*.
I'm barging in late here, so sorry if this has been suggested and shot
down: is it not possible to use composition here?
typedef ... CPU;
typedef struct CPUState {
DeviceState qdev;
CPU cpu;
} CPUState;But I guess bringing qdev to -user is inevitable.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 9 lines · Avi Kivity
Quoted 4 lines · Eduardo Habkost
So, here's a third suggestion to the CPU/DeviceState problem. Basically I split the qdev code into a core (that can be easily compiled into *-user), and a part specific to qemu-system-*.
I'm barging in late here, so sorry if this has been suggested and shot
down: is it not possible to use composition here?
Quoted 8 lines
typedef ... CPU;
typedef struct CPUState { DeviceState qdev; CPU cpu; } CPUState;But I guess bringing qdev to -user is inevitable.
I guess it would be OK, and almost equivalent to the suggestion by Anthony (use a different parent class for the CPU class on system-* and *-user), as most state today is in the arch-specific classes.
The only problem I see is when some part of the CPU code starts using a DeviceState feature (e.g. calling x86_cpu_realize() only at qdev_init()-time). Then we have to duplicate some code to make *-user work differently (not much code, I guess, but it would still make it easier to break it if we have two implementations).
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 1/8] move qemu_irq typedef out of cpu-common.h
In reply to Peter Maydell----- Original Message -----
Quoted 1 line
From: "Peter Maydell" <[email protected]>
...
Quoted 7 lines
I'm not objecting to this patch if it helps us move forwards, but adding the #include to
sysemu.his effectively just adding the definition to another grabbag header (183 files includesysemu.h). It would be nicer long-term to separate out the one thing in this header that cares aboutqemu_irq(the extern declaration ofqemu_system_powerdown).
^^^^
Is there a preference/suggestion in which header it should be declared?
...
Re: [Qemu-devel] [Xen-devel] [RFC 1/8] move qemu_irq typedef out of cpu-common.h
In reply to Peter MaydellQuoted 23 lines · On Tue, 21 Aug 2012 17:10:48 +0100 Peter Maydell <[email protected]>…
Quoted 22 lines · Eduardo Habkost
qemu-common.h +0
-1@@ -273,7 +273,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"
Quoted 10 lines
sysemu.h line 14
Quoted 1 line
sysemu.h +0
-0/* vl.c */ I'm not objecting to this patch if it helps us move forwards, but adding the #include to
sysemu.his effectively just adding the definition to another grabbag header (183 files includesysemu.h). It would be nicer long-term to separate out the one thing in this header that cares aboutqemu_irq(the extern declaration ofqemu_system_powerdown).
[I'm not really convinced that aqemu_irqis even the right way to signal "hey the system has actually powered down now"...]
Instead of global qemu_system_powerdown we could use notifiers like it's done for suspend, I'll post patches today after testing them on target-i386.
BTW getting rid of qemu_system_powerdown is orthogonal to topic of this series. I hope you won't object to this patch providing there will be follow on series to deal with qemu_system_powerdown.
Quoted 7 lines
-- PMM
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [Xen-devel] [RFC 1/8] move qemu_irq typedef out of cpu-common.h
Quoted 10 lines · Igor Mammedov
Quoted 8 lines · Peter Maydell
I'm not objecting to this patch if it helps us move forwards, but adding the #include to
sysemu.his effectively just adding the definition to another grabbag header (183 files includesysemu.h). It would be nicer long-term to separate out the one thing in this header that cares aboutqemu_irq(the extern declaration ofqemu_system_powerdown).
[I'm not really convinced that aqemu_irqis even the right way to signal "hey the system has actually powered down now"...]
Quoted 6 lines
Instead of global
qemu_system_powerdownwe could use notifiers like it's done for suspend, I'll post patches today after testing them on target-i386.BTW getting rid of
qemu_system_powerdownis orthogonal to topic of this series. I hope you won't object to this patch providing there will be follow on series to deal withqemu_system_powerdown.
Yes, as I say, I don't object if this patch is useful in the meantime.
-- PMM