cpu: make a child of DeviceState
v2 cover cpu: make a child of DeviceState
this is th 3rd approach to make CPU a child of DeviceState for both kinds of targets *-user and *-softmmu. It seems with current state of qemu it doesn't take too much effort to make it compile. Please check if it doesn't break something on other targets/archs/hosts than i386.
what's tested:
- compile tested building all targets on FC17x64 host.
- briefly tested i386 user and softmmu targets
Anthony Liguori (1):
qdev: split up header so it can be used in cpu.h
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
error.h | 1 - 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.c | 1 + hw/qdev-properties.h | 128 +++++++++++++++++ hw/qdev.c | 1 + hw/qdev.h | 371 +------------------------------------------------ hw/soc_dma.h | 1 + hw/xen.h | 1 + include/qemu/cpu.h | 6 +- qemu-common.h | 1 - scripts/qapi-types.py | 2 +- sysemu.h | 1 + 20 files changed, 407 insertions(+), 373 deletions(-) create mode 100644 hw/qdev-core.h create mode 100644 hw/qdev-monitor.h create mode 100644 hw/qdev-properties.h
PATCH v2 1/5 move qemu_irq typedef out of cpu-common.h
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 deletions(-)
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.1
Re: [Qemu-devel] [PATCH 1/5] move qemu_irq typedef out of cpu-common.h
Am 20.08.2012 01:39, schrieb Igor Mammedov:
Quoted 108 lines
it's necessary for making CPU child of DEVICE without causing circular header deps.
Signed-off-by Igor Mammedov <[email protected]>--- 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 deletions(-)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 0hw/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 0x00000000hw/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
-0
qemu-common.h typedef struct PCIEPort PCIEPort; · line 278
Quoted 7 lines
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 ;
Just move the declaration of qemu_irq to the beginning of qemu-common.h and leave the rest of files untouched. That also fixes the circular dependency.
I already have a patch that does this, so you can integrate it in your series instead of this one.
Quoted 12 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 */
Re: [Qemu-devel] [PATCH 1/5] move qemu_irq typedef out of cpu-common.h
Quoted 121 lines · On Mon, 20 Aug 2012 06:41:04 +0200 Stefan Weil <[email protected]> wrote:
Am 20.08.2012 01:39, schrieb Igor Mammedov:
Quoted 108 lines
it's necessary for making CPU child of DEVICE without causing circular header deps.
Signed-off-by Igor Mammedov <[email protected]>--- 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 deletions(-)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 0hw/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 0x00000000hw/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
-0qemu-common.h typedef struct PCIEPort PCIEPort; · line 278
Quoted 7 lines
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 ;Just move the declaration of
qemu_irqto the beginning ofqemu-common.hand leave the rest of files untouched. That also fixes the circular dependency.
Quoted 3 lines
I already have a patch that does this, so you can integrate it in your series
instead of this one.
No doubt it's more simpler way, but IMHO It's more of a hack than fixing problem.
It works for now but doesn't alleviate problem with header nightmare in qemu, where everything is included in qemu-common.h and everything includes it as well.
Any way if majority prefer simple move, I'll drop this patch in favor of yours.
Quoted 15 lines
Quoted 14 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 */
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 1/5] move qemu_irq typedef out of cpu-common.h
Quoted 127 lines · Igor Mammedov
Quoted 121 lines · On Mon, 20 Aug 2012 06:41:04 +0200 Stefan Weil <[email protected]> wrote:
Am 20.08.2012 01:39, schrieb Igor Mammedov:
Quoted 108 lines
it's necessary for making CPU child of DEVICE without causing circular header deps.
Signed-off-by Igor Mammedov <[email protected]>--- 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 deletions(-)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 0hw/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 0x00000000hw/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
-0qemu-common.h typedef struct PCIEPort PCIEPort; · line 278
Quoted 7 lines
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 ;Just move the declaration of
qemu_irqto the beginning ofqemu-common.hand leave the rest of files untouched. That also fixes the circular dependency.Quoted 3 lines
I already have a patch that does this, so you can integrate it in your series
instead of this one.
Quoted 7 lines
No doubt it's more simpler way, but IMHO It's more of a hack than fixing problem.
It works for now but doesn't alleviate problem with header nightmare in qemu, where everything is included inqemu-common.hand everything includes it as well.Any way if majority prefer simple move, I'll drop this patch in favor of yours.
I like Igor's approach more.
Quoted 21 lines
Quoted 13 lines
Quoted 13 lines
sysemu.h +1
-0@@ -9,6 +9,7 @@#include "qapi-types.h" #include "notify.h" #include "main-loop.h" +#include "hw/irq.h" Quoted 3 lines
sysemu.h line 15
Quoted 2 lines
sysemu.h +0
-0/* vl.c */ --
Regards,
Igor
Re: [Qemu-devel] [PATCH 1/5] move qemu_irq typedef out of cpu-common.h
Quoted 134 lines · Blue Swirl
Quoted 133 lines · Igor Mammedov
Quoted 121 lines · On Mon, 20 Aug 2012 06:41:04 +0200 Stefan Weil <[email protected]> wrote:
Am 20.08.2012 01:39, schrieb Igor Mammedov:
Quoted 108 lines
it's necessary for making CPU child of DEVICE without causing circular header deps.
Signed-off-by Igor Mammedov <[email protected]>--- 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 deletions(-)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 0hw/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 0x00000000hw/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
-0qemu-common.h typedef struct PCIEPort PCIEPort; · line 278
Quoted 7 lines
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 ;Just move the declaration of
qemu_irqto the beginning ofqemu-common.hand leave the rest of files untouched. That also fixes the circular dependency.Quoted 3 lines
I already have a patch that does this, so you can integrate it in your series
instead of this one.No doubt it's more simpler way, but IMHO It's more of a hack than fixing problem.
It works for now but doesn't alleviate problem with header nightmare in qemu, where everything is included inqemu-common.hand everything includes it as well.
Quoted 3 lines
Quoted 1 line
Any way if majority prefer simple move, I'll drop this patch in favor of yours.
I like Igor's approach more.
Ack.
We should move away from dumping ground includes like qemu-common in favor of meaningful headers that are explicitly included where needed.
Regards,
Anthony Liguori
Quoted 22 lines
Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
sysemu.h +1
-0@@ -9,6 +9,7 @@#include "qapi-types.h" #include "notify.h" #include "main-loop.h" +#include "hw/irq.h" Quoted 3 lines
sysemu.h line 15
Quoted 2 lines
sysemu.h +0
-0/* vl.c */ --
Regards,
Igor
PATCH v2 2/5 qdev: split up header so it can be used in cpu.h
In reply to Igor MammedovFrom: 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.1
PATCH v2 3/5 qapi-types.h doesn't really need to include qemu-common.h
In reply to Igor Mammedovneeded to prevent build breakage when CPU becomes a child of DeviceState
--- scripts/qapi-types.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
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.1
Re: [Qemu-devel] [PATCH 3/5] qapi-types.h doesn't really need to include qemu-common.h
Quoted 12 lines · On Mon, 20 Aug 2012 01:39:37 +0200 Igor Mammedov <[email protected]> wrote:
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 files changed, 1 insertions(+), 1 deletions(-)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>
Please, also include <stdint.h>, as int64_t is used in qapi-types.h.
The build doesn't break probably because files including qapi-types.h are including <stdint.h> first.
Quoted 3 lines
scripts/qapi-types.py +0
-0''', guard=guardname(h_file)))
Re: [Qemu-devel] [PATCH 3/5] qapi-types.h doesn't really need to include qemu-common.h
Quoted 18 lines · On Mon, 20 Aug 2012 12:22:10 -0300 Luiz Capitulino <[email protected]>…
Quoted 15 lines · On Mon, 20 Aug 2012 01:39:37 +0200 Igor Mammedov <[email protected]> wrote:
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 files changed, 1 insertions(+), 1 deletions(-)scripts/qapi-types.py +0
-0@@ -263,7 +263,7 @@ fdecl.write(mcgen(''' #ifndef %(guard)s #define %(guard)s
Quoted 7 lines
scripts/qapi-types.py fdecl.write(mcgen(''' · line 266
Quoted 2 lines
scripts/qapi-types.py +1
-1-#include "qemu-common.h" +#include <stdbool.h>Please, also include <
stdint.h>, asint64_tis used inqapi-types.h.The build doesn't break probably because files including
qapi-types.hare including <stdint.h> first.
Thanks for suggestion. I'll fix it for next respin.
Quoted 5 lines
Quoted 4 lines
scripts/qapi-types.py +0
-0''', guard=guardname(h_file)))
Signature · 2 lines
Regards, Igor
PATCH v2 4/5 cleanup error.h, included qapi-types.h aready has stdbool.h
In reply to Igor Mammedov--- error.h | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
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.1
Re: [Qemu-devel] [PATCH 4/5] cleanup error.h, included qapi-types.h aready has stdbool.h
Quoted 10 lines · On Mon, 20 Aug 2012 01:39:38 +0200 Igor Mammedov <[email protected]> wrote:
Signed-off-by Igor Mammedov <[email protected]>--- error.h | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)error.h +0
-0
error.h line 17
Quoted 4 lines
error.h +0
-1@@ -14,7 +14,6 @@#include "compiler.h" #include "qapi-types.h" -#include <stdbool.h>
Hmm, not good. qapi-types.h includes <stdbool.h> for internal matters, files including qapi-types.h shouldn't rely on this (as they can break if qapi-types.h is changed not to include <stdbool.h>).
You can keep this code as it is.
Quoted 3 lines
error.h +0
-0/** * A class representing internal errors within QEMU. An error has a ErrorClass
Re: [Qemu-devel] [Xen-devel] [PATCH 4/5] cleanup error.h, included qapi-types.h aready has stdbool.h
Quoted 22 lines · On Mon, 20 Aug 2012 12:28:05 -0300 Luiz Capitulino <[email protected]>…
Quoted 10 lines · On Mon, 20 Aug 2012 01:39:38 +0200 Igor Mammedov <[email protected]> wrote:
Signed-off-by Igor Mammedov <[email protected]>--- error.h | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)error.h +0
-0error.h line 17
Quoted 4 lines
error.h +0
-1@@ -14,7 +14,6 @@#include "compiler.h" #include "qapi-types.h" -#include <stdbool.h> Hmm, not good.
qapi-types.hincludes <stdbool.h> for internal matters, files includingqapi-types.hshouldn't rely on this (as they can break ifqapi-types.his changed not to include <stdbool.h>).
Quoted 1 line
You can keep this code as it is.
Agreed, I'll drop this patch.
Quoted 10 lines
error.h line 19
Quoted 4 lines
error.h +0
-0/** * A class representing internal errors within QEMU. An error has a ErrorClass _______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Signature · 2 lines
Regards, Igor
PATCH v2 5/5 make CPU a child of DeviceState
In reply to Igor Mammedov--- include/qemu/cpu.h | 6 +++--- 1 files changed, 3 insertions(+), 3 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;
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 5/5] make CPU a child of DeviceState
Quoted 28 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- include/qemu/cpu.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)include/qemu/cpu.h +2
-2@@ -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);
include/qemu/cpu.h typedef struct CPUClass { · line 65
Quoted 8 lines
include/qemu/cpu.h +1
-1@@ -59,7 +59,7 @@ typedef struct CPUClass {*/ struct CPUState {/*< private >*/ -Object parent_obj; +DeviceState parent_obj;/*< public >*/ struct QemuThread *thread;
Don't you need to update cpu_type_info on qom/cpu.c as well? It still has .parent = TYPE_OBJECT.
Signature · 1 line
Eduardo
Am 20.08.2012 01:39, schrieb Igor Mammedov:
Quoted 40 lines
this is th 3rd approach to make CPU a child of DeviceState for both kinds of targets *-user and *-softmmu. It seems with current state of qemu it doesn't take too much effort to make it compile. Please check if it doesn't break something on other targets/archs/hosts than i386.
what's tested:
- compile tested building all targets on FC17x64 host.
- briefly tested i386 user and softmmu targetsAnthony Liguori (1):
qdev: split up header so it can be used incpu.hIgor Mammedov (4):
moveqemu_irqtypedef out ofcpu-common.hqapi-types.hdoesn't really need to includeqemu-common.hcleanuperror.h, includedqapi-types.haready hasstdbool.hmake CPU a child of DeviceStateerror.h | 1 - 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.c | 1 + hw/qdev-properties.h | 128 +++++++++++++++++ hw/qdev.c | 1 + hw/qdev.h | 371 +------------------------------------------------ hw/soc_dma.h | 1 + hw/xen.h | 1 + include/qemu/cpu.h | 6 +- qemu-common.h | 1 - scripts/qapi-types.py | 2 +- sysemu.h | 1 + 20 files changed, 407 insertions(+), 373 deletions(-)
Quoted 4 lines
create mode 100644
hw/qdev-core.h
create mode 100644hw/qdev-monitor.h
create mode 100644hw/qdev-properties.h
I'd prefer if you could keep the following simple pattern:
* Start includes in *.c files with config.h (optionally) and qemu-common.h.
* Don't include standard include files which are already included in qemu-common.h
* Don't include qemu-common.h in *.h files.
Regards,
Stefan Weil
Quoted 46 lines · On Mon, 20 Aug 2012 06:52:51 +0200 Stefan Weil <[email protected]> wrote:
Am 20.08.2012 01:39, schrieb Igor Mammedov:
Quoted 40 lines
this is th 3rd approach to make CPU a child of DeviceState for both kinds of targets *-user and *-softmmu. It seems with current state of qemu it doesn't take too much effort to make it compile. Please check if it doesn't break something on other targets/archs/hosts than i386.
what's tested:
- compile tested building all targets on FC17x64 host.
- briefly tested i386 user and softmmu targetsAnthony Liguori (1):
qdev: split up header so it can be used incpu.hIgor Mammedov (4):
moveqemu_irqtypedef out ofcpu-common.hqapi-types.hdoesn't really need to includeqemu-common.hcleanuperror.h, includedqapi-types.haready hasstdbool.hmake CPU a child of DeviceStateerror.h | 1 - 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.c | 1 + hw/qdev-properties.h | 128 +++++++++++++++++ hw/qdev.c | 1 + hw/qdev.h | 371 +------------------------------------------------ hw/soc_dma.h | 1 + hw/xen.h | 1 + include/qemu/cpu.h | 6 +- qemu-common.h | 1 - scripts/qapi-types.py | 2 +- sysemu.h | 1 + 20 files changed, 407 insertions(+), 373 deletions(-)Quoted 4 lines
create mode 100644
hw/qdev-core.h
create mode 100644hw/qdev-monitor.h
create mode 100644hw/qdev-properties.h
Quoted 4 lines
I'd prefer if you could keep the following simple pattern:
* Start includes in *.c files with
config.h(optionally) andqemu-common.h.
Can't agree with you on this. I'd say that every header should be be self sufficient, include other headers if it uses types from them and NOT depend on the position where it's included, it should provide all its own deps.
Quoted 3 lines
* Don't include standard include files which are already included in
qemu-common.h
Probably initially qemu-common.h was intended to simplify inclusion of standard headers and glue stuff in multi-os build environment. but it seems to be become misused. It includes now a lot of stuff that is not common to every file it's included in.
Perhaps we should split out of it std includes and glue layer into something like std/host-common.h and case on case basis move out other type definitions that are not common into there appropriate places. Like with qemu_irq.
Quoted 2 lines
* Don't include
qemu-common.hin *.h files.
I'm all for it. But it's difficult right now because it tends to be included in a lot of headers that don't really need it and then other headers happens to depend on previous inclusion of it. It's difficult to untangle this in one take, but could be possible in small steps.
[1/1] is a direction that could be used to put type custom types in their proper places. It would be better way long term and help to avoid problems with including one header in another.
Quoted 5 lines
Regards,
Stefan Weil
Signature · 2 lines
Regards, Igor
[Qemu-devel] [RFC] How should QEMU code handle include statements (was: Re: [PATCH 0/5 v2] cpu: make a child of DeviceState)
Am 20.08.2012 13:47, schrieb Igor Mammedov:
Quoted 11 lines
Quoted 4 lines · On Mon, 20 Aug 2012 06:52:51 +0200 Stefan Weil<[email protected]> wrote:
I'd prefer if you could keep the following simple pattern:
* Start includes in *.c files with
config.h(optionally) andqemu-common.h.Can't agree with you on this. I'd say that every header should be be self sufficient, include other headers if it uses types from them and NOT depend on the position where it's included, it should provide all its own deps.
Quoted 2 lines
* Don't include standard include files which are already included in
qemu-common.h
Quoted 8 lines
Probably initially
qemu-common.hwas intended to simplify inclusion of standard headers and glue stuff in multi-os build environment. but it seems to be become misused. It includes now a lot of stuff that is not common to every file it's included in.
Perhaps we should split out of it std includes and glue layer into something likestd/host-common.hand case on case basis move out other type definitions that are not common into there appropriate places. Like withqemu_irq.
There are several possible strategies regarding include statements:
1. Each header file which represents some public interface must include any header file which it depends on, so applications which include xxx.h can rely on the fact that they won't need anything else to compile xxx.h.
To minimize dependencies, this rule can be extended: each header file must not include unneeded header files.
Usually header files in /usr/include are built according to these rules.
2. There is one header file (or a small set of header files) which includes a basic set of features which normal code needs. Any C code file starts by including this header file.
Other header files can rely on the fact that the basic set of features are already available.
3. In a modification of (2), each header file can include the basic header file(s).
4. The status quo of QEMU is a wild mixture of those strategies.
IMHO, there should be a consensus about the strategy which is used for QEMU code.
While I personally prefer (1) and used it for my first contributions, QEMU introduced qemu-common.h. I had the impression that from then on QEMU preferred strategy (2). Obviously not everybody shares that impression.
Which strategy / rule do we want to use for QEMU code?
Regards,
Stefan Weil
Re: [Qemu-devel] [RFC] How should QEMU code handle include statements
Quoted 6 lines · Stefan Weil
While I personally prefer (1) and used it for my first contributions, QEMU introduced
qemu-common.h. I had the impression that from then on QEMU preferred strategy (2). Obviously not everybody shares that impression.Which strategy / rule do we want to use for QEMU code?
(1).
Signature · 1 line
error compiling committee.c: too many arguments to function