CPU DeviceState, 5th try
PATCH v5 3/24 qemu-common.h: comment about usage rules
In reply to Eduardo HabkostEvery time we make a tiny change on a header file, we often find circular header dependency problems. To avoid this nightmare, we need to stop including qemu-common.h on other headers, and we should gradually move the declarations from the catchall qemu-common.h header to their specific headers.
This simply adds a comment documenting the rules about qemu-common.h, hoping that people will see it before including qemu-common.h from other header files, and before adding more declarations to qemu-common.h.
--- qemu-common.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
qemu-common.h +10 -1
@@ -1,5 +1,14 @@ -/* Common header file that is included by all of qemu. */ +/* Common header file that is included by all of qemu. +* +* This file is supposed to be included only by .c files. No header file should +* depend on qemu-common.h, as this would easily lead to circular header +* dependencies. +* +* If a header files uses a definition from qemu-common.h, that definition +* must be moved to a separate header file, and the header that uses it +* must include that header. +*/ #ifndef QEMU_COMMON_H #define QEMU_COMMON_H
Signature · 1 line
1.7.11.7
v5 cover CPU DeviceState, 5th try
Changes on v5:
- Tons of header cleanups just to eliminate qlist.h <-> cpu-common.h circular dependency (patches 1-17)
- Add copyright/license information to qdev-properties.c (patch 17)
- Add copyright/license information to qdev-properties-system.c (patch 22)
- use error_report()+abort() instead of hw_error() on qdev.c (patch 18)
- Move qemu_[un]register_reset() and qemu_devices_reset() to qdev-core.c (patch 19)
- Make vmstate_[un]register() weak stubs, instead of a new function (patch 20)
- Make sysbus_get_default() weak stub, instead of new qbus reset (un)register functions (patch 21)
- Eliminate qdev-system.c (all code is kept on qdev.c, now) (patch 22)
v4:
- Add GCC_WEAK_DECL to functions that have GCC_WEAK versions
- Updated the qdev_init_gpio_in() code on qdev-system.c to current version
- Patch description updates (moved changelog below "---" and/or move info about changes made by different authors between SoB lines)
v3 (submitted by Igor):
- rebased on top of 8b4a3df (today's master)
- slight code reshuffling in (see commit's changelog)
"qdev: separate core from the code used only by qemu-system-*" "move qemu_irq typedef out of cpu-common.h"
- commit messages cleanup
v2:
Rremoves the CONFIG_USER_ONLY ifdefs, and use weak symbols to move the vmstate and qemu_register_reset() handling to qdev-system.c
git tree for testing:
https://github.com/ehabkost/qemu-hacks/tree/cpu_qdev.v5
References to previous versions:
v4: http://article.gmane.org/gmane.comp.emulators.qemu/176127
v3: http://article.gmane.org/gmane.comp.emulators.qemu/175980
v2: http://article.gmane.org/gmane.comp.emulators.qemu/173909
v1: http://article.gmane.org/gmane.comp.emulators.qemu/166630
Anthony Liguori (1):
qdev: split up header so it can be used in cpu.h
Eduardo Habkost (20):
user: move *-user/qemu-types.h to main directory
user: rename qemu-types.h to qemu-user-types.h qemu-common.h: comment about usage rules
move I/O-related definitions from qemu-common.h to a new header
(qemu-stdio.h)
qemu-fsdev-dummy.c: include module.h
vnc-palette.h: include <stdbool.h> ui/vnc-pallete.c: include headers it needs qemu-config.h: include headers it needs qapi/qmp-registry.c: include headers it needs qga/channel-posix.c: include headers it needs create qemu-types.h for struct typedefs
sysemu.h: include qemu-types.h instead of qemu-common.h qlist.h: do not include qemu-common.h qdev-properties.c: add copyright/license information
qdev: qdev_create(): use error_report() instead of hw_error()
qdev: move reset handler list from vl.c to qdev.c
qdev: add stub vmstate handling to qdev.c
qdev: add sysbus_get_default() GCC_WEAK stub qdev-properties.c: separate core from the code used only by
qemu-system-*
include qdev code into *-user, too
Igor Mammedov (3):
move qemu_irq typedef out of cpu-common.h
qapi-types.h: don't include qemu-common.h
qom: make CPU a child of DeviceState
Makefile.objs | 8 + bsd-user/qemu-types.h | 24 -- bsd-user/qemu.h | 2 +- cpu-all.h | 2 +- fsdev/qemu-fsdev-dummy.c | 1 + hw/Makefile.objs | 9 +- hw/arm-misc.h | 1 + hw/bt.h | 2 + hw/devices.h | 2 + hw/hw.h | 6 +- hw/irq.h | 2 + hw/mc146818rtc.c | 1 + hw/omap.h | 1 + hw/qdev-addr.c | 1 + hw/qdev-core.h | 229 +++++++++++++++++ hw/qdev-monitor.h | 16 ++ hw/qdev-properties-system.c | 371 +++++++++++++++++++++++++++ hw/qdev-properties.c | 352 +++---------------------- hw/qdev-properties.h | 131 ++++++++++ hw/qdev-reset.h | 11 + hw/qdev.c | 96 +++++-- hw/qdev.h | 371 +-------------------------- hw/soc_dma.h | 1 + hw/xen.h | 1 + include/qemu/cpu.h | 6 +- linux-user/qemu.h | 2 +- qapi/qmp-registry.c | 2 + qemu-common.h | 124 +-------- qemu-config.h | 2 + qemu-stdio.h | 76 ++++++ qemu-types.h | 62 +++++ linux-user/qemu-types.h => qemu-user-types.h | 0 qga/channel-posix.c | 4 + qlist.h | 1 - qom/cpu.c | 3 +- scripts/qapi-types.py | 3 +- sysemu.h | 3 +- ui/vnc-palette.c | 2 + ui/vnc-palette.h | 1 + vl.c | 40 --- vmstate.h | 6 +- 41 files changed, 1081 insertions(+), 897 deletions(-) delete mode 100644 bsd-user/qemu-types.h 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-reset.h create mode 100644 qemu-stdio.h create mode 100644 qemu-types.h rename linux-user/qemu-types.h => qemu-user-types.h (100%)
Signature · 1 line
1.7.11.7
PATCH v5 1/24 user: move *-user/qemu-types.h to main directory
The bsd-user/qemu-types.h and linux-user/qemu-types.h files are almost the same, but linux-user have the additional definitions of tswapal().
This moves the linux-user file to the main directory, so the same file can be used by linux-user and bsd-user.
---
Cc: Blue Swirl <[email protected]>
Cc: Riku Voipio <[email protected]>
--- bsd-user/qemu-types.h | 24 ------------------------ linux-user/qemu-types.h => qemu-types.h | 0 2 files changed, 24 deletions(-) delete mode 100644 bsd-user/qemu-types.h rename linux-user/qemu-types.h => qemu-types.h (100%)
bsd-user/qemu-types.h deleted +0 -24
@@ -1,24 +0,0 @@ -#ifndef QEMU_TYPES_H -#define QEMU_TYPES_H -#include "cpu.h" - -#ifdef TARGET_ABI32 -typedef uint32_t abi_ulong ; -typedef int32_t abi_long ; -#define TARGET_ABI_FMT_lx "%08x" -#define TARGET_ABI_FMT_ld "%d" -#define TARGET_ABI_FMT_lu "%u" -#define TARGET_ABI_BITS 32 -#else -typedef target_ulong abi_ulong ; -typedef target_long abi_long ; -#define TARGET_ABI_FMT_lx TARGET_FMT_lx -#define TARGET_ABI_FMT_ld TARGET_FMT_ld -#define TARGET_ABI_FMT_lu TARGET_FMT_lu -#define TARGET_ABI_BITS TARGET_LONG_BITS -/* for consistency, define ABI32 too */ -#if TARGET_ABI_BITS ==32 -#define TARGET_ABI32 1 -#endif -#endif -#endif
qemu-types.h renamed from linux-user/qemu-types.h +0 -0
Signature · 1 line
1.7.11.7
PATCH v5 4/24 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.
---
Changes v1 (from Igor) -> v2 (sent by Eduardo):
- Chunk adding typedef on hw/irq.h was not present, because of patch rebase against qdev header split patch
Changes v2 -> v3 (from Igor):
- sysemu.h doesn't need irq.h since 013c2f150
Changes v3 -> v4 (from Eduardo):
- re-added the typedef code to hw/irq.h, after rebasing the patch
--- 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 - 8 files changed, 10 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
@@ -295,7 +295,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 ;
Signature · 1 line
1.7.11.7
PATCH v5 9/24 ui/vnc-pallete.c: include headers it needs
In reply to Eduardo HabkostInclude:
- <glib.h> for g_malloc0()
- <string.h> for memset()
Some of those headers were probably being included by accident because some other headers were including qemu-common.h, but those headers should eventually stop including qemu-common.h.
--- ui/vnc-palette.c | 2 ++ 1 file changed, 2 insertions(+)
ui/vnc-palette.c +2 -0
@@ -27,6 +27,8 @@*/ #include "vnc-palette.h" +#include <glib.h> +#include <string.h> static VncPaletteEntry *palette_find (const VncPalette *palette,uint32_t color,unsigned int hash)
Signature · 1 line
1.7.11.7
PATCH v5 15/24 qlist.h: do not include qemu-common.h
In reply to Eduardo HabkostI don't know why it was including it, as I don't see any code that depends on anything from qemu-common.h.
--- qlist.h | 1 - 1 file changed, 1 deletion(-)
qlist.h +0 -1
@@ -15,7 +15,6 @@#include "qobject.h" #include "qemu-queue.h" -#include "qemu-common.h" #include "qemu-queue.h" typedef struct QListEntry {
Signature · 1 line
1.7.11.7
PATCH v5 10/24 qemu-config.h: include headers it needs
In reply to Eduardo HabkostInclude:
- <stdio.h> for FILE
- qemu-option.h for QemuOptsList
Some of those headers were probably being included by accident because some other headers were including qemu-common.h, but those headers should eventually stop including qemu-common.h.
--- qemu-config.h | 2 ++ 1 file changed, 2 insertions(+)
qemu-config.h +2 -0
@@ -1,6 +1,8 @@#ifndef QEMU_CONFIG_H #define QEMU_CONFIG_H +#include <stdio.h> +#include "qemu-option.h" #include "error.h" extern QemuOptsList qemu_fsdev_opts;
Signature · 1 line
1.7.11.7
PATCH v5 16/24 qapi-types.h: don't 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
---
Yes, there is "changelog" data before the "---" mark, but I believe that in this case they are important to indicate authorship and the scope of the Signed-off-by lines (so they need to get into the git commit message).
Changes v1 (from Igor) -> v2 (from Eduardo):
- Include <stdbool.h> too
Changes v2 -> v3 (from Eduardo):
- Only commit description changes
--- 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.7
PATCH v5 6/24 move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h)
In reply to Eduardo HabkostThis will help reduce the qemu-common.h dependency hell.
--
Changes v1 -> v2:
- move qemu_open() & qemu_close() to qemu-stdio.h, too
--- qemu-common.h | 59 ++-------------------------------------------- qemu-stdio.h | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 57 deletions(-) create mode 100644 qemu-stdio.h
qemu-common.h +2 -57
@@ -15,6 +15,8 @@#include "compiler.h" #include "config-host.h" +#include "qemu-stdio.h" +#if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__)#define WORDS_ALIGNED #endif
@@ -57,28 +59,6 @@ typedef struct MigrationParams MigrationParams;#include "qemu-os-posix.h" #endif -#ifndef O_LARGEFILE -#define O_LARGEFILE 0 -#endif -#ifndef O_BINARY -#define O_BINARY 0 -#endif -#ifndef MAP_ANONYMOUS -#define MAP_ANONYMOUS MAP_ANON -#endif -#ifndef ENOMEDIUM -#define ENOMEDIUM ENODEV -#endif -#if !defined(ENOTSUP ) -#define ENOTSUP 4096 -#endif -#if !defined(ECANCELED ) -#define ECANCELED 4097 -#endif -#ifndef TIME_MAX -#define TIME_MAX LONG_MAX -#endif -/* HOST_LONG_BITS is the size of a native pointer in bits. */ #if UINTPTR_MAX ==UINT32_MAX # define HOST_LONG_BITS 32
@@ -88,39 +68,6 @@ typedef struct MigrationParams MigrationParams;# error Unknown pointer size#endif -#ifndef CONFIG_IOVEC -#define CONFIG_IOVEC -struct iovec { -void *iov_base; -size_t iov_len; -}; -/* -* Use the same value as Linux for now. -*/ -#define IOV_MAX 1024 -#else -#include <sys/uio.h> -#endif - -typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) -GCC_FMT_ATTR (2 ,3 ); - -#ifdef _WIN32 -#define fsync _commit -#if !defined(lseek) -# define lseek _lseeki64 -#endif -int qemu_ftruncate64 (int ,int64_t ); -#if !defined(ftruncate) -# define ftruncate qemu_ftruncate64 -#endif - -static inline char *realpath (const char *path,char *resolved_path) -{ -_fullpath (resolved_path, path, _MAX_PATH); -return resolved_path; -} -#endif /* icount */ void configure_icount (const char *option);
@@ -217,8 +164,6 @@ const char *path(const char *pathname);void *qemu_oom_check (void *ptr); -int qemu_open (const char *name,int flags, ...); -int qemu_close (int fd); ssize_t qemu_write_full(int fd, const void *buf, size_t count) QEMU_WARN_UNUSED_RESULT;ssize_t qemu_send_full (int fd,const void *buf,size_t count,int flags)
qemu-stdio.h new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH v5 8/24 vnc-palette.h: include <stdbool.h>
In reply to Eduardo Habkost<stdbool.h> is needed for the 'bool' type, used in the header.
The header is probably being included by accident because some other headers are including qemu-common.h, but those headers should eventually stop including qemu-common.h.
--- ui/vnc-palette.h | 1 + 1 file changed, 1 insertion(+)
ui/vnc-palette.h +1 -0
@@ -32,6 +32,7 @@#include "qlist.h" #include "qemu-queue.h" #include <stdint.h> +#include <stdbool.h> #define VNC_PALETTE_HASH_SIZE 256#define VNC_PALETTE_MAX_SIZE 256
Signature · 1 line
1.7.11.7
PATCH v5 14/24 sysemu.h: include qemu-types.h instead of qemu-common.h
In reply to Eduardo HabkostIt just needs the Monitor and DeviceState typedefs, so it doesn't need all of qemu-common.h.
--- sysemu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sysemu.h +1 -1
@@ -2,7 +2,7 @@#define SYSEMU_H /* Misc. things related to the system emulator. */ -#include "qemu-common.h" +#include "qemu-types.h" #include "qemu-option.h" #include "qemu-queue.h" #include "qemu-timer.h"
Signature · 1 line
1.7.11.7
PATCH v5 2/24 user: rename qemu-types.h to qemu-user-types.h
In reply to Eduardo HabkostThe header file is specific for *-user, but I plan to introduce a more generic qemu-types.h file, so I'm renaming it.
---
Cc: Blue Swirl <[email protected]>
Cc: Riku Voipio <[email protected]>
--- bsd-user/qemu.h | 2 +- cpu-all.h | 2 +- linux-user/qemu.h | 2 +- qemu-types.h => qemu-user-types.h | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename qemu-types.h => qemu-user-types.h (100%)
bsd-user/qemu.h +1 -1
@@ -11,7 +11,7 @@#include <stdlib.h> #endif /* DEBUG_REMAP */ -#include "qemu-types.h" +#include "qemu-user-types.h" enum BSDType { target_freebsd,
cpu-all.h +1 -1
@@ -180,7 +180,7 @@ static inline void tswap64s(uint64_t *s)#if defined(CONFIG_USER_ONLY )#include <assert.h> -#include "qemu-types.h" +#include "qemu-user-types.h" /* On some host systems the guest address space is reserved on the host. * This allows the guest address space to be offset to a convenient location.
linux-user/qemu.h +1 -1
@@ -11,7 +11,7 @@#include <stdlib.h> #endif /* DEBUG_REMAP */ -#include "qemu-types.h" +#include "qemu-user-types.h" #include "thunk.h" #include "syscall_defs.h"
qemu-user-types.h renamed from qemu-types.h +0 -0
Signature · 1 line
1.7.11.7
PATCH v5 7/24 qemu-fsdev-dummy.c: include module.h
In reply to Eduardo Habkostmodule.h is where machine_init() is defined, but qemu-fsdev-dummy.c doesn't include it.
The header is probably being included by accident because some other headers are including qemu-common.h, but those headers should eventually stop including qemu-common.h.
--- fsdev/qemu-fsdev-dummy.c | 1 + 1 file changed, 1 insertion(+)
fsdev/qemu-fsdev-dummy.c +1 -0
@@ -14,6 +14,7 @@#include <string.h> #include "qemu-fsdev.h" #include "qemu-config.h" +#include "module.h" int qemu_fsdev_add (QemuOpts *opts) {
Signature · 1 line
1.7.11.7
PATCH v5 11/24 qapi/qmp-registry.c: include headers it needs
In reply to Eduardo HabkostInclude:
- <glib.h> for g_malloc0()
- <string.h> for strcmp()
Some of those headers were probably being included by accident because some other headers were including qemu-common.h, but those headers should eventually stop including qemu-common.h.
--- qapi/qmp-registry.c | 2 ++ 1 file changed, 2 insertions(+)
qapi/qmp-registry.c +2 -0
@@ -12,6 +12,8 @@* */ +#include <glib.h> +#include <string.h> #include "qapi/qmp-core.h" static QTAILQ_HEAD(QmpCommandList, QmpCommand) qmp_commands =
Signature · 1 line
1.7.11.7
PATCH v5 20/24 qdev: add stub vmstate handling to qdev.c
In reply to Eduardo HabkostAdd GCC_WEAK vmstate symbols to qdev.c, so that qdev.o can be used without savevm.o (i.e. by *-user).
---
Originally submitted as:
Subject: qdev-core: isolate vmstate handling into separate functions
Changes v1 -> v2:
- Add GCC_WEAK_DECL to function declarations
Changes v2 -> v3:
- Make vmstate_register_with_alias_id()/vmstate_unregister() have GCC_WEAK versions, instead of creating a new function
- Kept qdev_get_vmsd() inside qdev.c
--- hw/qdev.c | 21 +++++++++++++++++++++ vmstate.h | 6 ++++-- 2 files changed, 25 insertions(+), 2 deletions(-)
hw/qdev.c +21 -0
@@ -76,6 +76,27 @@ void qemu_devices_reset(void) } } +/* vmstate register/unregister: +* +* The real implementations are on qdev-system.c and savevm.c. +* Those are weak symbols used by *-user. +*/ + +GCC_WEAK int vmstate_register_with_alias_id(DeviceState *dev, +int instance_id, +const VMStateDescription *vmsd, +void *base,int alias_id, +int required_for_version) +{ +return 0 ; +} + +GCC_WEAK void vmstate_unregister(DeviceState *dev, +const VMStateDescription *vmsd, +void *opaque) +{ +} +const VMStateDescription *qdev_get_vmsd (DeviceState *dev) {DeviceClass *dc =DEVICE_GET_CLASS (dev);
vmstate.h +4 -2
@@ -611,11 +611,13 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque);int vmstate_register (DeviceState *dev,int instance_id,const VMStateDescription *vmsd,void *base); -int vmstate_register_with_alias_id (DeviceState *dev,int instance_id, + +/* The following functions have GCC_WEAK stubs on qdev-core, for *-user: */ +GCC_WEAK_DECL int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,const VMStateDescription *vmsd,void *base,int alias_id,int required_for_version); -void vmstate_unregister (DeviceState *dev,const VMStateDescription *vmsd, +GCC_WEAK_DECL void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,void *opaque);struct MemoryRegion ;
Signature · 1 line
1.7.11.7
PATCH v5 23/24 include 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.
---
Changes v1 -> v2:
- Keep files on the hw/ directory
(it's simply easier to keep them there, as qdev.o depends on irq.o)
- Add a $(hw-core-obj-y) variable to Makefile.objs for the qdev core code
- Add irq.o to the list of core qdev files
(as now the gpio code is being kept inside qdev.c)
--- Makefile.objs | 8 ++++++++ hw/Makefile.objs | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-)
Makefile.objs +8 -0
@@ -18,6 +18,13 @@ qom-obj-y = qom/ universal-obj-y += $(qom-obj-y) ####################################################################### +# Core hw code (qdev core) +hw-core-obj-y += hw/ +hw-core-obj-y += qemu-option.o + +universal-obj-y += $(hw-core-obj-y) + +####################################################################### # oslib-obj-y is code depending on the OS (win32 vs posix) oslib-obj-y = osdep.o oslib-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o
@@ -244,5 +251,6 @@ nested-vars += \ qapi-obj-y \ user-obj-y \ common-obj-y \ + hw-core-obj-y \ extra-obj-y dummy := $(call unnest-vars)
hw/Makefile.objs +6 -2
@@ -1,3 +1,8 @@ +# core qdev-related obj files, also used by *-user: +hw-core-obj-y += qdev.o qdev-properties.o +# irq.o needed for qdev GPIO handling: +hw-core-obj-y += irq.o + common-obj-y = usb/ ide/ common-obj-y += loader.o common-obj-$(CONFIG_VIRTIO) += virtio-console.o
@@ -155,7 +160,6 @@ common-obj-$(CONFIG_SOUND) += $(sound-obj-y) common-obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/ common-obj-y += usb/ -common-obj-y += irq.o common-obj-$(CONFIG_PTIMER) += ptimer.o common-obj-$(CONFIG_MAX7310) += max7310.o common-obj-$(CONFIG_WM8750) += wm8750.o
@@ -181,7 +185,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-properties-system.o common-obj-$(CONFIG_BRLAPI) += baum.o
Signature · 1 line
1.7.11.7
PATCH v5 13/24 create qemu-types.h for struct typedefs
In reply to Eduardo HabkostInstead of keeping all those struct typedefs on qemu-common.h, move it to a header that can be safely included by other headers, containing only the struct typedefs and not pulling other dependencies.
Also, move some of the qdev-core.h typedefs to the new file, too, so other headers don't need to include qdev-core.h only because of DeviceState and other typedefs.
This will help us remove qemu-common.h dependencies from some headers later.
--- hw/qdev-core.h | 11 +---------- qemu-common.h | 53 +------------------------------------------------ qemu-types.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 62 deletions(-) create mode 100644 qemu-types.h
hw/qdev-core.h +1 -10
@@ -3,20 +3,11 @@#include "qemu-queue.h" #include "qemu-option.h" +#include "qemu-types.h" #include "qemu/object.h" #include "hw/irq.h" #include "error.h" -typedef struct Property Property ; - -typedef struct PropertyInfo PropertyInfo ; - -typedef struct CompatProperty CompatProperty ; - -typedef struct BusState BusState ; - -typedef struct BusClass BusClass ; -enum DevState {DEV_STATE_CREATED =1 ,DEV_STATE_INITIALIZED ,
qemu-common.h +1 -52
71 lines not on this page · raw message
qemu-types.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH v5 21/24 qdev: add sysbus_get_default() GCC_WEAK stub
In reply to Eduardo HabkostThis version will be used on cases where sysbus.c is not compiled in (e.g. *-user).
--- hw/qdev-core.h | 2 +- hw/qdev.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
hw/qdev-core.h +1 -1
@@ -194,7 +194,7 @@ void qbus_free(BusState *bus);#define FROM_QBUS (type, dev) DO_UPCAST(type, qbus, dev)/* This should go away once we get rid of the NULL bus hack */ -BusState *sysbus_get_default (void ); +GCC_WEAK_DECL BusState *sysbus_get_default(void);char *qdev_get_fw_dev_path (DeviceState *dev);
hw/qdev.c +12 -0
@@ -97,6 +97,18 @@ GCC_WEAK void vmstate_unregister(DeviceState *dev, { } + +/* sysbus stub functions +* +* The real implementation is on sysbus.c, but the stub functions will be used +* on cases where sysbus.c is not compiled in (e.g. *-user). +*/ + +GCC_WEAK BusState *sysbus_get_default(void) +{ +return NULL ; +} +const VMStateDescription *qdev_get_vmsd (DeviceState *dev) {DeviceClass *dc =DEVICE_GET_CLASS (dev);
Signature · 1 line
1.7.11.7
PATCH v5 24/24 qom: make CPU a child of DeviceState
In reply to Eduardo HabkostFrom: Igor Mammedov <[email protected]>
---
Yes, there is "changelog" data before the "---" mark, but I believe that in this case they are important to indicate authorship and the scope of the Signed-off-by lines (so they need to get into the git commit message).
--- 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.7
PATCH v5 18/24 qdev: qdev_create(): use error_report() instead of hw_error()
In reply to Eduardo Habkosthw_error() is specific for fatal hardware emulation errors, not for internal errors related to the qdev object/class abstraction or object initialization.
Replace it with an error_report() call, followed by abort().
This will also help reduce dependencies of the qdev code (as hw_error() is from cpus.o, and depends on the CPU list from exec.o).
--- hw/qdev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
hw/qdev.c +5 -3
@@ -109,10 +109,12 @@ DeviceState *qdev_create(BusState *bus, const char *name) 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))); +error_report ("Unknown device '%s' for bus '%s'\n" , name, +object_get_typename (OBJECT (bus))); +abort (); }else { -hw_error ("Unknown device '%s' for default sysbus\n" , name); +error_report ("Unknown device '%s' for default sysbus\n" , name); +abort (); } }
Signature · 1 line
1.7.11.7
PATCH v5 12/24 qga/channel-posix.c: include headers it needs
In reply to Eduardo HabkostInclude:
- <errno.h> for errno
- <unistd.h> & <fcntl.h> for fcntl()
- "qemu-stdio.h" for qemu_open()
Some of those headers were probably being included by accident because some other headers were including qemu-common.h, but those headers should eventually stop including qemu-common.h.
--- qga/channel-posix.c | 4 ++++ 1 file changed, 4 insertions(+)
qga/channel-posix.c +4 -0
@@ -1,5 +1,9 @@#include <glib.h> #include <termios.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> +#include "qemu-stdio.h" #include "qemu_socket.h" #include "qga/channel.h"
Signature · 1 line
1.7.11.7
PATCH v5 22/24 qdev-properties.c: separate core from the code used only by qemu-system-*
In reply to Eduardo HabkostThis separates the qdev properties code in two parts:
- qdev-properties.c, that contains most of the qdev properties code;
- qdev-properties-system.c for code specific for qemu-system-*, containing:
- Property types: drive, chr, netdev, vlan, that depend on code that won't be included on *-user
- qemu_add_globals(), that depends on qemu-config.o.
This change should help on two things:
- Allowing DeviceState to be used by *-user without pulling dependencies that are specific for qemu-system-*;
- Writing qdev unit tests without pulling too many dependencies.
The copyright/license header for the new file is directly copied from qdev-properties.c.
[ehabkost: updated the qdev_init_gpio_in() code on qdev-system.c to current
version]
---
Yes, there is "changelog" data before the "---" mark, but I believe that in this case they are important to indicate authorship and the scope of the Signed-off-by lines (so they need to get into the git commit message).
Detailed changelog:
Changes v1 (ehabkost) -> v2 (imammedo):
- keep qdev_get_child_bus() in hw/qdev.c
- put qdev_set_nic_properties() in hw/qdev-properties-system.c
Changes v2 -> v3 (ehabkost):
- updated the qdev_init_gpio_in() code on qdev-system.c to current version
Changes v3 -> v4 (ehabkost):
- Added copyright/license information to qdev-properties-system.c (based on copyright/license of qdev-properties.c)
- Whitespace change at the end of qdev-properties.c
- Don't create qdev-system.c, now we can keep the qdev.c code as-is as the qdev.c dependencies were reduced
- Rewrite patch description
--- hw/Makefile.objs | 1 + hw/qdev-properties-system.c | 371 ++++++++++++++++++++++++++++++++++++++++++++ hw/qdev-properties.c | 321 +------------------------------------- hw/qdev-properties.h | 1 + hw/qdev.c | 13 -- 5 files changed, 374 insertions(+), 333 deletions(-) create mode 100644 hw/qdev-properties-system.c
hw/Makefile.objs +1 -0
@@ -182,6 +182,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-properties-system.o common-obj-$(CONFIG_BRLAPI) += baum.o # xen backend driver support
hw/qdev-properties-system.c new file +371 -0
371 lines not on this page · raw message
hw/qdev-properties.c +1 -320
348 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.c +0 -13
@@ -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"
@@ -386,18 +385,6 @@ void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin) 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;
Signature · 1 line
1.7.11.7
PATCH v5 5/24 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
hw/qdev.h is split into following new headers:
hw/qdev-core.h
hw/qdev-properties.h
hw/qdev-monitor.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]
[ehabkost: moved get_fw_dev_path() comment to the original location
(I don't know why it was moved)]
[ehabkost: removed qdev_exists() declaration]
[ehabkost: keep using 'QemuOpts' instead of 'struct QemuOpts', as
qdev-core.h includes qemu-option.h]
---
Yes, there is "changelog" data before the "---" mark, but I believe that in this case they are important to indicate authorship and the scope of the Signed-off-by lines (so they need to get into the git commit message)
Detailed changelog:
Changes v1 (from Anthony) -> v2 (from Eduardo):
- re-add DEFINE_PROP_PCI_HOST_DEVADDR, that was removed on the original patch (by mistake, I guess)
- kill qdev_prop_set_vlan() declaration
Changes v2 -> v3 (from Eduardo):
- moved get_fw_dev_path() comment to the original location (I don't know why it was moved)
- removed qdev_exists() declaration
- keep using 'QemuOpts' instead of 'struct QemuOpts', as qdev-core.h includes qemu-option.h
Changes v3 -> v4 (from Eduardo):
- Edited commit message to include additional information about the specific files being created
--- hw/mc146818rtc.c | 1 + hw/qdev-addr.c | 1 + hw/qdev-core.h | 238 +++++++++++++++++++++++++++++++++ hw/qdev-monitor.h | 16 +++ hw/qdev-properties.c | 1 + hw/qdev-properties.h | 130 ++++++++++++++++++ hw/qdev.c | 1 + hw/qdev.h | 370 +-------------------------------------------------- 8 files changed, 392 insertions(+), 366 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 "hwaddr.h" +#include "qapi/qapi-visit-core.h" /* --- target physical address --- */
hw/qdev-core.h new file +238 -0
238 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 -366
375 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH v5 19/24 qdev: move reset handler list from vl.c to qdev.c
In reply to Eduardo HabkostThe core qdev code uses the reset handler list from vl.c, so move qemu_register_reset(), qemu_unregister_reset() and qemu_devices_reset() to qdev.c.
The function declarations were moved to a new qdev-reset.h file, that is included by hw.h to keep compatibility, so we don't need to change all files that use qemu_register_reset().
--- hw/hw.h | 6 +----- hw/qdev-reset.h | 11 +++++++++++ hw/qdev.c | 41 +++++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 1 + sysemu.h | 1 - vl.c | 40 ---------------------------------------- 6 files changed, 54 insertions(+), 46 deletions(-) create mode 100644 hw/qdev-reset.h
hw/hw.h +1 -5
@@ -13,6 +13,7 @@#include "qemu-file.h" #include "vmstate.h" #include "qemu-log.h" +#include "qdev-reset.h" #ifdef NEED_CPU_H #if TARGET_LONG_BITS ==64
@@ -36,11 +37,6 @@#endif #endif -typedef void QEMUResetHandler (void *opaque); - -void qemu_register_reset (QEMUResetHandler *func,void *opaque); -void qemu_unregister_reset (QEMUResetHandler *func,void *opaque); -/* handler to set the boot_device order for a specific type of QEMUMachine */ /* return 0 if success */ typedef int QEMUBootSetHandler (void *opaque,const char *boot_devices);
hw/qdev-reset.h new file +11 -0
@@ -0,0 +1,11 @@ +/* Device reset handler function registration, used by qdev */ +#ifndef QDEV_RESET_H +#define QDEV_RESET_H + +typedef void QEMUResetHandler (void *opaque); + +void qemu_register_reset (QEMUResetHandler *func,void *opaque); +void qemu_unregister_reset (QEMUResetHandler *func,void *opaque); +void qemu_devices_reset (void ); + +#endif /* QDEV_RESET_H */
hw/qdev.c +41 -0
47 lines not on this page · raw message
hw/qdev.h +1 -0
@@ -5,5 +5,6 @@#include "qdev-core.h" #include "qdev-properties.h" #include "qdev-monitor.h" +#include "qdev-reset.h" #endif
sysemu.h +0 -1
@@ -62,7 +62,6 @@ int qemu_reset_requested(void);int qemu_powerdown_requested (void );void qemu_system_killed (int signal,pid_t pid);void qemu_kill_report (void ); -void qemu_devices_reset (void );void qemu_system_reset (bool report);void qemu_add_exit_notifier (Notifier *notify);
vl.c +0 -40
@@ -1339,14 +1339,6 @@ void vm_start(void)/* reset/shutdown handler */ -typedef struct QEMUResetEntry { -QTAILQ_ENTRY (QEMUResetEntry) entry; -QEMUResetHandler *func; -void *opaque; -}QEMUResetEntry ; - -static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers = -QTAILQ_HEAD_INITIALIZER (reset_handlers);static int reset_requested;static int shutdown_requested, shutdown_signal =-1 ;static pid_t shutdown_pid;
@@ -1443,38 +1435,6 @@ static bool qemu_vmstop_requested(RunState *r)return false; } -void qemu_register_reset (QEMUResetHandler *func,void *opaque) -{ -QEMUResetEntry *re =g_malloc0 (sizeof (QEMUResetEntry)); - - re->func = func; - re->opaque = opaque; -QTAILQ_INSERT_TAIL (&reset_handlers, re, entry); -} - -void qemu_unregister_reset (QEMUResetHandler *func,void *opaque) -{ -QEMUResetEntry *re; - - QTAILQ_FOREACH(re, &reset_handlers, entry) { -if (re->func == func && re->opaque == opaque) { -QTAILQ_REMOVE (&reset_handlers, re, entry); -g_free (re); -return ; - } - } -} - -void qemu_devices_reset (void ) -{ -QEMUResetEntry *re, *nre; - -/* reset all devices */ - QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) { - re->func (re->opaque); - } -} -void qemu_system_reset (bool report) {if (current_machine && current_machine->reset) {
Signature · 1 line
1.7.11.7
PATCH v5 17/24 qdev-properties.c: add copyright/license information
In reply to Eduardo HabkostAdd copyright and license information, based on git log, and discussion at:
http://article.gmane.org/gmane.comp.emulators.qemu/176405
Message-ID: <[email protected]>
The list of Copyright owners is huge, but I didn't think I really could leave any of the authors out of the list.
---
The only reason I am doing this is because:
- I am going to mvoe some of the qdev-properties.c file to another file
- I need to add a copyright/license header to the new file. See http://article.gmane.org/gmane.comp.emulators.qemu/176367
- So, I need to document the copyright/license of the current qdev-properties.c code
I would really love to avoid this whole archaeology/legalese work, because I am not a lawyer. I am only doing that because of the "new files should have a copyright header" requirement.
--- hw/qdev-properties.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
hw/qdev-properties.c +30 -0
@@ -1,3 +1,33 @@ +/* +* qdev property parsing and global properties +* +* Copyright (c) 2009-2010 Gerd Hoffmann <[email protected]> +* Copyright (c) 2009 Christoph Egger <[email protected]> +* Copyright (c) 2009-2010 Blue Swirl <[email protected]> +* Copyright (c) 2009 Juan Quintela <[email protected]> +* Copyright (c) 2010 Michael S. Tsirkin <[email protected]> +* Copyright (c) 2010,2012 Stefan Weil <[email protected]> +* Copyright (c) 2010-2012 Markus Armbruster <[email protected]> +* Copyright (c) 2010 Kevin Wolf <[email protected]> +* Copyright (c) 2010 Isaku Yamahata <[email protected]> +* Copyright (c) 2011 David 'Digit' Turner <[email protected]> +* Copyright (c) 2011-2012 Amit Shah <[email protected]> +* Copyright (c) 2011 Kusanagi Kouichi <[email protected]> +* Copyright (c) 2011-2012 Anthony Liguori <[email protected]> +* Copyright (c) 2011 Donald Dutile <[email protected]> +* Copyright (c) 2011-2012 Jan Kiszka <[email protected]> +* Copyright (c) 2011-2012 Paolo Bonzini <[email protected]> +* Copyright (c) 2012 Stefan Hajnoczi <[email protected]> +* Copyright (c) 2012 dunrong huang <[email protected]> +* Copyright (c) 2012 Michael Roth <[email protected]> +* Copyright (c) 2012 Anthony PERARD <[email protected]> +* Copyright (c) 2012 Christian Borntraeger <[email protected]> +* Copyright (c) 2012 Zhi Yong Wu <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ +#include "net.h" #include "qdev.h" #include "qerror.h"
Signature · 1 line
1.7.11.7