* [Qemu-devel] [PATCH 01/24] user: move *-user/qemu-types.h to main directory
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 02/24] user: rename qemu-types.h to qemu-user-types.h Eduardo Habkost
` (22 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
---
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%)
diff --git a/bsd-user/qemu-types.h b/bsd-user/qemu-types.h
deleted file mode 100644
index 1adda9f..0000000
--- a/bsd-user/qemu-types.h
+++ /dev/null
@@ -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
diff --git a/linux-user/qemu-types.h b/qemu-types.h
similarity index 100%
rename from linux-user/qemu-types.h
rename to qemu-types.h
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 02/24] user: rename qemu-types.h to qemu-user-types.h
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 01/24] user: move *-user/qemu-types.h to main directory Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 03/24] qemu-common.h: comment about usage rules Eduardo Habkost
` (21 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
The header file is specific for *-user, but I plan to introduce a more
generic qemu-types.h file, so I'm renaming it.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
---
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%)
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 8a5ee3d..d268899 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -11,7 +11,7 @@
#include <stdlib.h>
#endif /* DEBUG_REMAP */
-#include "qemu-types.h"
+#include "qemu-user-types.h"
enum BSDType {
target_freebsd,
diff --git a/cpu-all.h b/cpu-all.h
index c9c51b8..d6b2b19 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -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.
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 5e53dca..ceddb3c 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -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"
diff --git a/qemu-types.h b/qemu-user-types.h
similarity index 100%
rename from qemu-types.h
rename to qemu-user-types.h
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 03/24] qemu-common.h: comment about usage rules
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 01/24] user: move *-user/qemu-types.h to main directory Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 02/24] user: rename qemu-types.h to qemu-user-types.h Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 04/24] move qemu_irq typedef out of cpu-common.h Eduardo Habkost
` (20 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
Every 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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
qemu-common.h | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/qemu-common.h b/qemu-common.h
index ac9985c..ea43bfa 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -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
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 04/24] move qemu_irq typedef out of cpu-common.h
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (2 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 03/24] qemu-common.h: comment about usage rules Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 05/24] qdev: split up header so it can be used in cpu.h Eduardo Habkost
` (19 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
From: Igor Mammedov <imammedo@redhat.com>
it's necessary for making CPU child of DEVICE without
causing circular header deps.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
[ehabkost: re-added the typedef to hw/irq.h after rebasing]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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(-)
diff --git a/hw/arm-misc.h b/hw/arm-misc.h
index adb1665..d129678 100644
--- a/hw/arm-misc.h
+++ b/hw/arm-misc.h
@@ -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
diff --git a/hw/bt.h b/hw/bt.h
index a48b8d4..ebf6a37 100644
--- a/hw/bt.h
+++ b/hw/bt.h
@@ -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];
diff --git a/hw/devices.h b/hw/devices.h
index 1a55c1e..c60bcab 100644
--- a/hw/devices.h
+++ b/hw/devices.h
@@ -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;
diff --git a/hw/irq.h b/hw/irq.h
index e640c10..610e6b7 100644
--- a/hw/irq.h
+++ b/hw/irq.h
@@ -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);
diff --git a/hw/omap.h b/hw/omap.h
index 8bd7c73..2b383ff 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -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
diff --git a/hw/soc_dma.h b/hw/soc_dma.h
index 9340b8f..5948489 100644
--- a/hw/soc_dma.h
+++ b/hw/soc_dma.h
@@ -19,6 +19,7 @@
*/
#include "memory.h"
+#include "hw/irq.h"
struct soc_dma_s;
struct soc_dma_ch_s;
diff --git a/hw/xen.h b/hw/xen.h
index d14e92d..e3cca7f 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -8,6 +8,7 @@
*/
#include <inttypes.h>
+#include "hw/irq.h"
#include "qemu-common.h"
/* xen-machine.c */
diff --git a/qemu-common.h b/qemu-common.h
index ea43bfa..6441bee 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -292,7 +292,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;
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 05/24] qdev: split up header so it can be used in cpu.h
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (3 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 04/24] move qemu_irq typedef out of cpu-common.h Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 06/24] move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h) Eduardo Habkost
` (18 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
From: Anthony Liguori <aliguori@us.ibm.com>
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
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
[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]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index 98839f2..7d84ce3 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -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"
diff --git a/hw/qdev-addr.c b/hw/qdev-addr.c
index de0ba87..ea32c31 100644
--- a/hw/qdev-addr.c
+++ b/hw/qdev-addr.c
@@ -1,6 +1,7 @@
#include "qdev.h"
#include "qdev-addr.h"
#include "hwaddr.h"
+#include "qapi/qapi-visit-core.h"
/* --- target physical address --- */
diff --git a/hw/qdev-core.h b/hw/qdev-core.h
new file mode 100644
index 0000000..fce9e22
--- /dev/null
+++ b/hw/qdev-core.h
@@ -0,0 +1,238 @@
+#ifndef QDEV_CORE_H
+#define QDEV_CORE_H
+
+#include "qemu-queue.h"
+#include "qemu-option.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,
+};
+
+enum {
+ DEV_NVECTORS_UNSPECIFIED = -1,
+};
+
+#define TYPE_DEVICE "device"
+#define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
+#define DEVICE_CLASS(klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE)
+#define DEVICE_GET_CLASS(obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE)
+
+typedef int (*qdev_initfn)(DeviceState *dev);
+typedef int (*qdev_event)(DeviceState *dev);
+typedef void (*qdev_resetfn)(DeviceState *dev);
+
+struct VMStateDescription;
+
+typedef struct DeviceClass {
+ ObjectClass parent_class;
+
+ const char *fw_name;
+ const char *desc;
+ Property *props;
+ int no_user;
+
+ /* callbacks */
+ void (*reset)(DeviceState *dev);
+
+ /* device state */
+ const struct VMStateDescription *vmsd;
+
+ /* Private to qdev / bus. */
+ qdev_initfn init;
+ qdev_event unplug;
+ qdev_event exit;
+ const char *bus_type;
+} DeviceClass;
+
+/* This structure should not be accessed directly. We declare it here
+ so that it can be embedded in individual device state structures. */
+struct DeviceState {
+ Object parent_obj;
+
+ const char *id;
+ enum DevState state;
+ QemuOpts *opts;
+ int hotplugged;
+ BusState *parent_bus;
+ int num_gpio_out;
+ qemu_irq *gpio_out;
+ int num_gpio_in;
+ qemu_irq *gpio_in;
+ QLIST_HEAD(, BusState) child_bus;
+ int num_child_bus;
+ int instance_id_alias;
+ int alias_required_for_version;
+};
+
+#define TYPE_BUS "bus"
+#define BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_BUS)
+#define BUS_CLASS(klass) OBJECT_CLASS_CHECK(BusClass, (klass), TYPE_BUS)
+#define BUS_GET_CLASS(obj) OBJECT_GET_CLASS(BusClass, (obj), TYPE_BUS)
+
+struct BusClass {
+ ObjectClass parent_class;
+
+ /* FIXME first arg should be BusState */
+ void (*print_dev)(Monitor *mon, DeviceState *dev, int indent);
+ char *(*get_dev_path)(DeviceState *dev);
+ /*
+ * This callback is used to create Open Firmware device path in accordance
+ * with OF spec http://forthworks.com/standards/of1275.pdf. Individual bus
+ * bindings can be found at http://playground.sun.com/1275/bindings/.
+ */
+ char *(*get_fw_dev_path)(DeviceState *dev);
+ int (*reset)(BusState *bus);
+};
+
+typedef struct BusChild {
+ DeviceState *child;
+ int index;
+ QTAILQ_ENTRY(BusChild) sibling;
+} BusChild;
+
+/**
+ * BusState:
+ * @qom_allocated: Indicates whether the object was allocated by QOM.
+ * @glib_allocated: Indicates whether the object was initialized in-place
+ * yet is expected to be freed with g_free().
+ */
+struct BusState {
+ Object obj;
+ DeviceState *parent;
+ const char *name;
+ int allow_hotplug;
+ bool qom_allocated;
+ bool glib_allocated;
+ int max_index;
+ QTAILQ_HEAD(ChildrenHead, BusChild) children;
+ QLIST_ENTRY(BusState) sibling;
+};
+
+struct Property {
+ const char *name;
+ PropertyInfo *info;
+ int offset;
+ uint8_t bitnr;
+ uint8_t qtype;
+ int64_t defval;
+};
+
+struct PropertyInfo {
+ const char *name;
+ const char *legacy_name;
+ const char **enum_table;
+ int (*parse)(DeviceState *dev, Property *prop, const char *str);
+ int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
+ ObjectPropertyAccessor *get;
+ ObjectPropertyAccessor *set;
+ ObjectPropertyRelease *release;
+};
+
+typedef struct GlobalProperty {
+ const char *driver;
+ const char *property;
+ const char *value;
+ QTAILQ_ENTRY(GlobalProperty) next;
+} GlobalProperty;
+
+/*** Board API. This should go away once we have a machine config file. ***/
+
+DeviceState *qdev_create(BusState *bus, const char *name);
+DeviceState *qdev_try_create(BusState *bus, const char *name);
+int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
+void qdev_init_nofail(DeviceState *dev);
+void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
+ int required_for_version);
+void qdev_unplug(DeviceState *dev, Error **errp);
+void qdev_free(DeviceState *dev);
+int qdev_simple_unplug_cb(DeviceState *dev);
+void qdev_machine_creation_done(void);
+bool qdev_machine_modified(void);
+
+qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
+void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
+
+BusState *qdev_get_child_bus(DeviceState *dev, const char *name);
+
+/*** Device API. ***/
+
+/* Register device properties. */
+/* GPIO inputs also double as IRQ sinks. */
+void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
+void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
+
+BusState *qdev_get_parent_bus(DeviceState *dev);
+
+/*** BUS API. ***/
+
+DeviceState *qdev_find_recursive(BusState *bus, const char *id);
+
+/* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */
+typedef int (qbus_walkerfn)(BusState *bus, void *opaque);
+typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque);
+
+void qbus_create_inplace(BusState *bus, const char *typename,
+ DeviceState *parent, const char *name);
+BusState *qbus_create(const char *typename, DeviceState *parent, const char *name);
+/* Returns > 0 if either devfn or busfn skip walk somewhere in cursion,
+ * < 0 if either devfn or busfn terminate walk somewhere in cursion,
+ * 0 otherwise. */
+int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn,
+ qbus_walkerfn *busfn, void *opaque);
+int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn,
+ qbus_walkerfn *busfn, void *opaque);
+void qdev_reset_all(DeviceState *dev);
+void qbus_reset_all_fn(void *opaque);
+
+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);
+
+char *qdev_get_fw_dev_path(DeviceState *dev);
+
+/**
+ * @qdev_machine_init
+ *
+ * Initialize platform devices before machine init. This is a hack until full
+ * support for composition is added.
+ */
+void qdev_machine_init(void);
+
+/**
+ * @device_reset
+ *
+ * Reset a single device (by calling the reset method).
+ */
+void device_reset(DeviceState *dev);
+
+const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
+
+const char *qdev_fw_name(DeviceState *dev);
+
+Object *qdev_get_machine(void);
+
+/* FIXME: make this a link<> */
+void qdev_set_parent_bus(DeviceState *dev, BusState *bus);
+
+extern int qdev_hotplug;
+
+char *qdev_get_dev_path(DeviceState *dev);
+
+#endif
diff --git a/hw/qdev-monitor.h b/hw/qdev-monitor.h
new file mode 100644
index 0000000..220ceba
--- /dev/null
+++ b/hw/qdev-monitor.h
@@ -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
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 8aca0d4..81d901c 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -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)
{
diff --git a/hw/qdev-properties.h b/hw/qdev-properties.h
new file mode 100644
index 0000000..5b046ab
--- /dev/null
+++ b/hw/qdev-properties.h
@@ -0,0 +1,130 @@
+#ifndef QEMU_QDEV_PROPERTIES_H
+#define QEMU_QDEV_PROPERTIES_H
+
+#include "qdev-core.h"
+
+/*** qdev-properties.c ***/
+
+extern PropertyInfo qdev_prop_bit;
+extern PropertyInfo qdev_prop_uint8;
+extern PropertyInfo qdev_prop_uint16;
+extern PropertyInfo qdev_prop_uint32;
+extern PropertyInfo qdev_prop_int32;
+extern PropertyInfo qdev_prop_uint64;
+extern PropertyInfo qdev_prop_hex8;
+extern PropertyInfo qdev_prop_hex32;
+extern PropertyInfo qdev_prop_hex64;
+extern PropertyInfo qdev_prop_string;
+extern PropertyInfo qdev_prop_chr;
+extern PropertyInfo qdev_prop_ptr;
+extern PropertyInfo qdev_prop_macaddr;
+extern PropertyInfo qdev_prop_losttickpolicy;
+extern PropertyInfo qdev_prop_bios_chs_trans;
+extern PropertyInfo qdev_prop_drive;
+extern PropertyInfo qdev_prop_netdev;
+extern PropertyInfo qdev_prop_vlan;
+extern PropertyInfo qdev_prop_pci_devfn;
+extern PropertyInfo qdev_prop_blocksize;
+extern PropertyInfo qdev_prop_pci_host_devaddr;
+
+#define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
+ .name = (_name), \
+ .info = &(_prop), \
+ .offset = offsetof(_state, _field) \
+ + type_check(_type,typeof_field(_state, _field)), \
+ }
+#define DEFINE_PROP_DEFAULT(_name, _state, _field, _defval, _prop, _type) { \
+ .name = (_name), \
+ .info = &(_prop), \
+ .offset = offsetof(_state, _field) \
+ + type_check(_type,typeof_field(_state, _field)), \
+ .qtype = QTYPE_QINT, \
+ .defval = (_type)_defval, \
+ }
+#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
+ .name = (_name), \
+ .info = &(qdev_prop_bit), \
+ .bitnr = (_bit), \
+ .offset = offsetof(_state, _field) \
+ + type_check(uint32_t,typeof_field(_state, _field)), \
+ .qtype = QTYPE_QBOOL, \
+ .defval = (bool)_defval, \
+ }
+
+#define DEFINE_PROP_UINT8(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
+#define DEFINE_PROP_UINT16(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
+#define DEFINE_PROP_UINT32(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
+#define DEFINE_PROP_INT32(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
+#define DEFINE_PROP_UINT64(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
+#define DEFINE_PROP_HEX8(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t)
+#define DEFINE_PROP_HEX32(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t)
+#define DEFINE_PROP_HEX64(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex64, uint64_t)
+#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
+
+#define DEFINE_PROP_PTR(_n, _s, _f) \
+ DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
+#define DEFINE_PROP_CHR(_n, _s, _f) \
+ DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
+#define DEFINE_PROP_STRING(_n, _s, _f) \
+ DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
+#define DEFINE_PROP_NETDEV(_n, _s, _f) \
+ DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NetClientState*)
+#define DEFINE_PROP_VLAN(_n, _s, _f) \
+ DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, NetClientState*)
+#define DEFINE_PROP_DRIVE(_n, _s, _f) \
+ DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
+#define DEFINE_PROP_MACADDR(_n, _s, _f) \
+ DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
+#define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
+ LostTickPolicy)
+#define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
+#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
+ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
+#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
+ DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
+
+#define DEFINE_PROP_END_OF_LIST() \
+ {}
+
+/* Set properties between creation and init. */
+void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
+int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
+void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value);
+void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value);
+void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value);
+void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
+void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value);
+void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
+void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value);
+void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
+void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState *value);
+int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT;
+void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value);
+void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
+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_list(GlobalProperty *props);
+void qdev_prop_set_globals(DeviceState *dev);
+void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
+ Property *prop, const char *value);
+
+/**
+ * @qdev_property_add_static - add a @Property to a device referencing a
+ * field in a struct.
+ */
+void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
+
+#endif
diff --git a/hw/qdev.c b/hw/qdev.c
index 9b9aba3..7ddcd24 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -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;
diff --git a/hw/qdev.h b/hw/qdev.h
index c6ac636..365b8d6 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -1,371 +1,9 @@
#ifndef QDEV_H
#define QDEV_H
-#include "hw.h"
-#include "qemu-queue.h"
-#include "qemu-char.h"
-#include "qemu-option.h"
-#include "qapi/qapi-visit-core.h"
-#include "qemu/object.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,
-};
-
-enum {
- DEV_NVECTORS_UNSPECIFIED = -1,
-};
-
-#define TYPE_DEVICE "device"
-#define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
-#define DEVICE_CLASS(klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE)
-#define DEVICE_GET_CLASS(obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE)
-
-typedef int (*qdev_initfn)(DeviceState *dev);
-typedef int (*qdev_event)(DeviceState *dev);
-typedef void (*qdev_resetfn)(DeviceState *dev);
-
-typedef struct DeviceClass {
- ObjectClass parent_class;
-
- const char *fw_name;
- const char *desc;
- Property *props;
- int no_user;
-
- /* callbacks */
- void (*reset)(DeviceState *dev);
-
- /* device state */
- const VMStateDescription *vmsd;
-
- /* Private to qdev / bus. */
- qdev_initfn init;
- qdev_event unplug;
- qdev_event exit;
- const char *bus_type;
-} DeviceClass;
-
-/* This structure should not be accessed directly. We declare it here
- so that it can be embedded in individual device state structures. */
-struct DeviceState {
- Object parent_obj;
-
- const char *id;
- enum DevState state;
- QemuOpts *opts;
- int hotplugged;
- BusState *parent_bus;
- int num_gpio_out;
- qemu_irq *gpio_out;
- int num_gpio_in;
- qemu_irq *gpio_in;
- QLIST_HEAD(, BusState) child_bus;
- int num_child_bus;
- int instance_id_alias;
- int alias_required_for_version;
-};
-
-#define TYPE_BUS "bus"
-#define BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_BUS)
-#define BUS_CLASS(klass) OBJECT_CLASS_CHECK(BusClass, (klass), TYPE_BUS)
-#define BUS_GET_CLASS(obj) OBJECT_GET_CLASS(BusClass, (obj), TYPE_BUS)
-
-struct BusClass {
- ObjectClass parent_class;
-
- /* FIXME first arg should be BusState */
- void (*print_dev)(Monitor *mon, DeviceState *dev, int indent);
- char *(*get_dev_path)(DeviceState *dev);
- /*
- * This callback is used to create Open Firmware device path in accordance
- * with OF spec http://forthworks.com/standards/of1275.pdf. Individual bus
- * bindings can be found at http://playground.sun.com/1275/bindings/.
- */
- char *(*get_fw_dev_path)(DeviceState *dev);
- int (*reset)(BusState *bus);
-};
-
-typedef struct BusChild {
- DeviceState *child;
- int index;
- QTAILQ_ENTRY(BusChild) sibling;
-} BusChild;
-
-/**
- * BusState:
- * @qom_allocated: Indicates whether the object was allocated by QOM.
- * @glib_allocated: Indicates whether the object was initialized in-place
- * yet is expected to be freed with g_free().
- */
-struct BusState {
- Object obj;
- DeviceState *parent;
- const char *name;
- int allow_hotplug;
- bool qom_allocated;
- bool glib_allocated;
- int max_index;
- QTAILQ_HEAD(ChildrenHead, BusChild) children;
- QLIST_ENTRY(BusState) sibling;
-};
-
-struct Property {
- const char *name;
- PropertyInfo *info;
- int offset;
- uint8_t bitnr;
- uint8_t qtype;
- int64_t defval;
-};
-
-struct PropertyInfo {
- const char *name;
- const char *legacy_name;
- const char **enum_table;
- int (*parse)(DeviceState *dev, Property *prop, const char *str);
- int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
- ObjectPropertyAccessor *get;
- ObjectPropertyAccessor *set;
- ObjectPropertyRelease *release;
-};
-
-typedef struct GlobalProperty {
- const char *driver;
- const char *property;
- const char *value;
- QTAILQ_ENTRY(GlobalProperty) next;
-} GlobalProperty;
-
-/*** Board API. This should go away once we have a machine config file. ***/
-
-DeviceState *qdev_create(BusState *bus, const char *name);
-DeviceState *qdev_try_create(BusState *bus, const char *name);
-int qdev_device_help(QemuOpts *opts);
-DeviceState *qdev_device_add(QemuOpts *opts);
-int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
-void qdev_init_nofail(DeviceState *dev);
-void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
- int required_for_version);
-void qdev_unplug(DeviceState *dev, Error **errp);
-void qdev_free(DeviceState *dev);
-int qdev_simple_unplug_cb(DeviceState *dev);
-void qdev_machine_creation_done(void);
-bool qdev_machine_modified(void);
-
-qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
-void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
-
-BusState *qdev_get_child_bus(DeviceState *dev, const char *name);
-
-/*** Device API. ***/
-
-/* Register device properties. */
-/* GPIO inputs also double as IRQ sinks. */
-void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
-void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
-
-BusState *qdev_get_parent_bus(DeviceState *dev);
-
-/*** BUS API. ***/
-
-DeviceState *qdev_find_recursive(BusState *bus, const char *id);
-
-/* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */
-typedef int (qbus_walkerfn)(BusState *bus, void *opaque);
-typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque);
-
-void qbus_create_inplace(BusState *bus, const char *typename,
- DeviceState *parent, const char *name);
-BusState *qbus_create(const char *typename, DeviceState *parent, const char *name);
-/* Returns > 0 if either devfn or busfn skip walk somewhere in cursion,
- * < 0 if either devfn or busfn terminate walk somewhere in cursion,
- * 0 otherwise. */
-int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn,
- qbus_walkerfn *busfn, void *opaque);
-int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn,
- qbus_walkerfn *busfn, void *opaque);
-void qdev_reset_all(DeviceState *dev);
-void qbus_reset_all_fn(void *opaque);
-
-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);
-
-/*** 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);
-
-/*** qdev-properties.c ***/
-
-extern PropertyInfo qdev_prop_bit;
-extern PropertyInfo qdev_prop_uint8;
-extern PropertyInfo qdev_prop_uint16;
-extern PropertyInfo qdev_prop_uint32;
-extern PropertyInfo qdev_prop_int32;
-extern PropertyInfo qdev_prop_uint64;
-extern PropertyInfo qdev_prop_hex8;
-extern PropertyInfo qdev_prop_hex32;
-extern PropertyInfo qdev_prop_hex64;
-extern PropertyInfo qdev_prop_string;
-extern PropertyInfo qdev_prop_chr;
-extern PropertyInfo qdev_prop_ptr;
-extern PropertyInfo qdev_prop_macaddr;
-extern PropertyInfo qdev_prop_losttickpolicy;
-extern PropertyInfo qdev_prop_bios_chs_trans;
-extern PropertyInfo qdev_prop_drive;
-extern PropertyInfo qdev_prop_netdev;
-extern PropertyInfo qdev_prop_vlan;
-extern PropertyInfo qdev_prop_pci_devfn;
-extern PropertyInfo qdev_prop_blocksize;
-extern PropertyInfo qdev_prop_pci_host_devaddr;
-
-#define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
- .name = (_name), \
- .info = &(_prop), \
- .offset = offsetof(_state, _field) \
- + type_check(_type,typeof_field(_state, _field)), \
- }
-#define DEFINE_PROP_DEFAULT(_name, _state, _field, _defval, _prop, _type) { \
- .name = (_name), \
- .info = &(_prop), \
- .offset = offsetof(_state, _field) \
- + type_check(_type,typeof_field(_state, _field)), \
- .qtype = QTYPE_QINT, \
- .defval = (_type)_defval, \
- }
-#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
- .name = (_name), \
- .info = &(qdev_prop_bit), \
- .bitnr = (_bit), \
- .offset = offsetof(_state, _field) \
- + type_check(uint32_t,typeof_field(_state, _field)), \
- .qtype = QTYPE_QBOOL, \
- .defval = (bool)_defval, \
- }
-
-#define DEFINE_PROP_UINT8(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
-#define DEFINE_PROP_UINT16(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
-#define DEFINE_PROP_UINT32(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
-#define DEFINE_PROP_INT32(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
-#define DEFINE_PROP_UINT64(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
-#define DEFINE_PROP_HEX8(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t)
-#define DEFINE_PROP_HEX32(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t)
-#define DEFINE_PROP_HEX64(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex64, uint64_t)
-#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
-
-#define DEFINE_PROP_PTR(_n, _s, _f) \
- DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
-#define DEFINE_PROP_CHR(_n, _s, _f) \
- DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
-#define DEFINE_PROP_STRING(_n, _s, _f) \
- DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
-#define DEFINE_PROP_NETDEV(_n, _s, _f) \
- DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NetClientState*)
-#define DEFINE_PROP_VLAN(_n, _s, _f) \
- DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, NetClientState*)
-#define DEFINE_PROP_DRIVE(_n, _s, _f) \
- DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
-#define DEFINE_PROP_MACADDR(_n, _s, _f) \
- DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
-#define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
- LostTickPolicy)
-#define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
-#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
-#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
- DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
-
-#define DEFINE_PROP_END_OF_LIST() \
- {}
-
-/* Set properties between creation and init. */
-void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
-int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
-void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value);
-void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value);
-void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value);
-void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
-void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value);
-void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
-void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value);
-void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
-void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState *value);
-int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT;
-void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value);
-void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
-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_list(GlobalProperty *props);
-void qdev_prop_set_globals(DeviceState *dev);
-void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
- Property *prop, const char *value);
-
-char *qdev_get_fw_dev_path(DeviceState *dev);
-
-/**
- * @qdev_property_add_static - add a @Property to a device referencing a
- * field in a struct.
- */
-void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
-
-/**
- * @qdev_machine_init
- *
- * Initialize platform devices before machine init. This is a hack until full
- * support for composition is added.
- */
-void qdev_machine_init(void);
-
-/**
- * @device_reset
- *
- * Reset a single device (by calling the reset method).
- */
-void device_reset(DeviceState *dev);
-
-const VMStateDescription *qdev_get_vmsd(DeviceState *dev);
-
-const char *qdev_fw_name(DeviceState *dev);
-
-Object *qdev_get_machine(void);
-
-/* FIXME: make this a link<> */
-void qdev_set_parent_bus(DeviceState *dev, BusState *bus);
-
-extern int qdev_hotplug;
-
-char *qdev_get_dev_path(DeviceState *dev);
+#include "hw/hw.h"
+#include "qdev-core.h"
+#include "qdev-properties.h"
+#include "qdev-monitor.h"
#endif
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 06/24] move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h)
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (4 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 05/24] qdev: split up header so it can be used in cpu.h Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 07/24] qemu-fsdev-dummy.c: include module.h Eduardo Habkost
` (17 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
This will help reduce the qemu-common.h dependency hell.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
--
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
diff --git a/qemu-common.h b/qemu-common.h
index 6441bee..5080382 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -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
@@ -58,28 +60,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
@@ -89,39 +69,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)
diff --git a/qemu-stdio.h b/qemu-stdio.h
new file mode 100644
index 0000000..b2e8eda
--- /dev/null
+++ b/qemu-stdio.h
@@ -0,0 +1,76 @@
+/* Some basic definitions related to stdio.h or other I/O interfaces
+ */
+#ifndef QEMU_STDIO_H
+#define QEMU_STDIO_H
+
+#include "compiler.h"
+#include "config-host.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+
+#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
+
+#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
+
+int qemu_open(const char *name, int flags, ...);
+int qemu_close(int fd);
+
+#endif /* QEMU_STDIO_H */
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 07/24] qemu-fsdev-dummy.c: include module.h
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (5 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 06/24] move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h) Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 08/24] vnc-palette.h: include <stdbool.h> Eduardo Habkost
` (16 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
module.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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
fsdev/qemu-fsdev-dummy.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fsdev/qemu-fsdev-dummy.c b/fsdev/qemu-fsdev-dummy.c
index 4e700dd..300f275 100644
--- a/fsdev/qemu-fsdev-dummy.c
+++ b/fsdev/qemu-fsdev-dummy.c
@@ -14,6 +14,7 @@
#include <string.h>
#include "qemu-fsdev.h"
#include "qemu-config.h"
+#include "module.h"
int qemu_fsdev_add(QemuOpts *opts)
{
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 08/24] vnc-palette.h: include <stdbool.h>
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (6 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 07/24] qemu-fsdev-dummy.c: include module.h Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 09/24] ui/vnc-pallete.c: include headers it needs Eduardo Habkost
` (15 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
<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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
ui/vnc-palette.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/ui/vnc-palette.h b/ui/vnc-palette.h
index 3260885..b82dc5d 100644
--- a/ui/vnc-palette.h
+++ b/ui/vnc-palette.h
@@ -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
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 09/24] ui/vnc-pallete.c: include headers it needs
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (7 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 08/24] vnc-palette.h: include <stdbool.h> Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 10/24] qemu-config.h: " Eduardo Habkost
` (14 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
Include:
- <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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
ui/vnc-palette.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ui/vnc-palette.c b/ui/vnc-palette.c
index 63d5f64..c130dee 100644
--- a/ui/vnc-palette.c
+++ b/ui/vnc-palette.c
@@ -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)
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 10/24] qemu-config.h: include headers it needs
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (8 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 09/24] ui/vnc-pallete.c: include headers it needs Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 11/24] qapi/qmp-registry.c: " Eduardo Habkost
` (13 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
Include:
- <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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
qemu-config.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/qemu-config.h b/qemu-config.h
index 5557562..812c4c5 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -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;
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 11/24] qapi/qmp-registry.c: include headers it needs
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (9 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 10/24] qemu-config.h: " Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 12/24] qga/channel-posix.c: " Eduardo Habkost
` (12 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
Include:
- <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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
qapi/qmp-registry.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c
index 5414613..c2c31b4 100644
--- a/qapi/qmp-registry.c
+++ b/qapi/qmp-registry.c
@@ -12,6 +12,8 @@
*
*/
+#include <glib.h>
+#include <string.h>
#include "qapi/qmp-core.h"
static QTAILQ_HEAD(QmpCommandList, QmpCommand) qmp_commands =
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 12/24] qga/channel-posix.c: include headers it needs
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (10 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 11/24] qapi/qmp-registry.c: " Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 13/24] create qemu-types.h for struct typedefs Eduardo Habkost
` (11 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
Include:
- <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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
qga/channel-posix.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/qga/channel-posix.c b/qga/channel-posix.c
index d152827..2a68451 100644
--- a/qga/channel-posix.c
+++ b/qga/channel-posix.c
@@ -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"
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 13/24] create qemu-types.h for struct typedefs
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (11 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 12/24] qga/channel-posix.c: " Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 14/24] sysemu.h: include qemu-types.h instead of qemu-common.h Eduardo Habkost
` (10 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
Instead 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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v1 -> v2:
- Rebased against latest qemu.git master
- New typedefs: QEMUBH, QemuConsole
- Old typedefs removed: DisplayAllocator, TextConsole, QEMUConsole
---
hw/qdev-core.h | 11 +----------
qemu-common.h | 52 +------------------------------------------------
qemu-types.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+), 61 deletions(-)
create mode 100644 qemu-types.h
diff --git a/hw/qdev-core.h b/hw/qdev-core.h
index fce9e22..494b687 100644
--- a/hw/qdev-core.h
+++ b/hw/qdev-core.h
@@ -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,
diff --git a/qemu-common.h b/qemu-common.h
index 5080382..1b4a12c 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -16,6 +16,7 @@
#include "config-host.h"
#include "qemu-stdio.h"
+#include "qemu-types.h"
#if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__)
#define WORDS_ALIGNED
@@ -23,15 +24,6 @@
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
-typedef struct QEMUTimer QEMUTimer;
-typedef struct QEMUFile QEMUFile;
-typedef struct QEMUBH QEMUBH;
-typedef struct DeviceState DeviceState;
-
-struct Monitor;
-typedef struct Monitor Monitor;
-typedef struct MigrationParams MigrationParams;
-
/* we put basic includes here to avoid repeating them in device drivers */
#include <stdlib.h>
#include <stdio.h>
@@ -205,48 +197,6 @@ struct ParallelIOArg {
typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
-/* A load of opaque types so that device init declarations don't have to
- pull in all the real definitions. */
-typedef struct NICInfo NICInfo;
-typedef struct HCIInfo HCIInfo;
-typedef struct AudioState AudioState;
-typedef struct BlockDriverState BlockDriverState;
-typedef struct DriveInfo DriveInfo;
-typedef struct DisplayState DisplayState;
-typedef struct DisplayChangeListener DisplayChangeListener;
-typedef struct DisplaySurface DisplaySurface;
-typedef struct PixelFormat PixelFormat;
-typedef struct QemuConsole QemuConsole;
-typedef struct CharDriverState CharDriverState;
-typedef struct MACAddr MACAddr;
-typedef struct NetClientState NetClientState;
-typedef struct i2c_bus i2c_bus;
-typedef struct ISABus ISABus;
-typedef struct ISADevice ISADevice;
-typedef struct SMBusDevice SMBusDevice;
-typedef struct PCIHostState PCIHostState;
-typedef struct PCIExpressHost PCIExpressHost;
-typedef struct PCIBus PCIBus;
-typedef struct PCIDevice PCIDevice;
-typedef struct PCIExpressDevice PCIExpressDevice;
-typedef struct PCIBridge PCIBridge;
-typedef struct PCIEAERMsg PCIEAERMsg;
-typedef struct PCIEAERLog PCIEAERLog;
-typedef struct PCIEAERErr PCIEAERErr;
-typedef struct PCIEPort PCIEPort;
-typedef struct PCIESlot PCIESlot;
-typedef struct MSIMessage MSIMessage;
-typedef struct SerialState SerialState;
-typedef struct PCMCIACardState PCMCIACardState;
-typedef struct MouseTransformInfo MouseTransformInfo;
-typedef struct uWireSlave uWireSlave;
-typedef struct I2SCodec I2SCodec;
-typedef struct SSIBus SSIBus;
-typedef struct EventNotifier EventNotifier;
-typedef struct VirtIODevice VirtIODevice;
-typedef struct QEMUSGList QEMUSGList;
-typedef struct SHPCDevice SHPCDevice;
-
typedef uint64_t pcibus_t;
typedef enum LostTickPolicy {
diff --git a/qemu-types.h b/qemu-types.h
new file mode 100644
index 0000000..fd532a2
--- /dev/null
+++ b/qemu-types.h
@@ -0,0 +1,61 @@
+#ifndef QEMU_TYPEDEFS_H
+#define QEMU_TYPEDEFS_H
+
+/* A load of opaque types so that device init declarations don't have to
+ pull in all the real definitions. */
+typedef struct QEMUTimer QEMUTimer;
+typedef struct QEMUFile QEMUFile;
+typedef struct QEMUBH QEMUBH;
+
+struct Monitor;
+typedef struct Monitor Monitor;
+typedef struct MigrationParams MigrationParams;
+
+typedef struct Property Property;
+typedef struct PropertyInfo PropertyInfo;
+typedef struct CompatProperty CompatProperty;
+typedef struct DeviceState DeviceState;
+typedef struct BusState BusState;
+typedef struct BusClass BusClass;
+
+typedef struct NICInfo NICInfo;
+typedef struct HCIInfo HCIInfo;
+typedef struct AudioState AudioState;
+typedef struct BlockDriverState BlockDriverState;
+typedef struct DriveInfo DriveInfo;
+typedef struct DisplayState DisplayState;
+typedef struct DisplayChangeListener DisplayChangeListener;
+typedef struct DisplaySurface DisplaySurface;
+typedef struct PixelFormat PixelFormat;
+typedef struct QemuConsole QemuConsole;
+typedef struct CharDriverState CharDriverState;
+typedef struct MACAddr MACAddr;
+typedef struct NetClientState NetClientState;
+typedef struct i2c_bus i2c_bus;
+typedef struct ISABus ISABus;
+typedef struct ISADevice ISADevice;
+typedef struct SMBusDevice SMBusDevice;
+typedef struct PCIHostState PCIHostState;
+typedef struct PCIExpressHost PCIExpressHost;
+typedef struct PCIBus PCIBus;
+typedef struct PCIDevice PCIDevice;
+typedef struct PCIExpressDevice PCIExpressDevice;
+typedef struct PCIBridge PCIBridge;
+typedef struct PCIEAERMsg PCIEAERMsg;
+typedef struct PCIEAERLog PCIEAERLog;
+typedef struct PCIEAERErr PCIEAERErr;
+typedef struct PCIEPort PCIEPort;
+typedef struct PCIESlot PCIESlot;
+typedef struct MSIMessage MSIMessage;
+typedef struct SerialState SerialState;
+typedef struct PCMCIACardState PCMCIACardState;
+typedef struct MouseTransformInfo MouseTransformInfo;
+typedef struct uWireSlave uWireSlave;
+typedef struct I2SCodec I2SCodec;
+typedef struct SSIBus SSIBus;
+typedef struct EventNotifier EventNotifier;
+typedef struct VirtIODevice VirtIODevice;
+typedef struct QEMUSGList QEMUSGList;
+typedef struct SHPCDevice SHPCDevice;
+
+#endif /* QEMU_TYPEDEFS_H */
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 14/24] sysemu.h: include qemu-types.h instead of qemu-common.h
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (12 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 13/24] create qemu-types.h for struct typedefs Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 15/24] qlist.h: do not include qemu-common.h Eduardo Habkost
` (9 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
It just needs the Monitor and DeviceState typedefs, so it doesn't need
all of qemu-common.h.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
sysemu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysemu.h b/sysemu.h
index f5ac664..ab1ef8b 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -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"
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 15/24] qlist.h: do not include qemu-common.h
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (13 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 14/24] sysemu.h: include qemu-types.h instead of qemu-common.h Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 16/24] qapi-types.h: don't " Eduardo Habkost
` (8 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
I don't know why it was including it, as I don't see any code that
depends on anything from qemu-common.h.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
qlist.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/qlist.h b/qlist.h
index ae776f9..7408947 100644
--- a/qlist.h
+++ b/qlist.h
@@ -15,7 +15,6 @@
#include "qobject.h"
#include "qemu-queue.h"
-#include "qemu-common.h"
#include "qemu-queue.h"
typedef struct QListEntry {
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 16/24] qapi-types.h: don't include qemu-common.h
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (14 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 15/24] qlist.h: do not include qemu-common.h Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 17/24] qdev-properties.c: add copyright/license information Eduardo Habkost
` (7 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
From: Igor Mammedov <imammedo@redhat.com>
needed to prevent build breakage when CPU becomes a child of DeviceState
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
[ehabkost: include <stdbool.h> too]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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 <stdboo.h> too
Changes v2 -> v3 (from Eduardo):
- Only commit description changes
---
scripts/qapi-types.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 1b84834..6bc2391 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -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)))
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 17/24] qdev-properties.c: add copyright/license information
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (15 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 16/24] qapi-types.h: don't " Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 18/24] qdev: qdev_create(): use error_report() instead of hw_error() Eduardo Habkost
` (6 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
Add copyright and license information, based on git log,
and discussion at:
http://article.gmane.org/gmane.comp.emulators.qemu/176405
Message-ID: <20121017201414.GA5665@otherpad.lan.raisama.net>
The list of Copyright owners is huge, but I didn't think I really could
leave any of the authors out of the list.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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.
Cc: Amit Shah <amit.shah@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Cc: Anthony PERARD <anthony.perard@citrix.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Christoph Egger <Christoph.Egger@amd.com>
Cc: David 'Digit' Turner <digit@google.com>
Cc: Donald Dutile <ddutile@redhat.com>
Cc: dunrong huang <riegamaths@gmail.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jan Kiszka <jan.kiszka@web.de>
Cc: Juan Quintela <quintela@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Kusanagi Kouichi <slash@ac.auone-net.jp>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: Stefan Weil <sw@weilnetz.de>
Cc: Stefan Weil <weil@mail.berlios.de>
Cc: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
hw/qdev-properties.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 81d901c..ff5aa0a 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -1,3 +1,33 @@
+/*
+ * qdev property parsing and global properties
+ *
+ * Copyright (c) 2009-2010 Gerd Hoffmann <kraxel@redhat.com>
+ * Copyright (c) 2009 Christoph Egger <Christoph.Egger@amd.com>
+ * Copyright (c) 2009-2010 Blue Swirl <blauwirbel@gmail.com>
+ * Copyright (c) 2009 Juan Quintela <quintela@redhat.com>
+ * Copyright (c) 2010 Michael S. Tsirkin <mst@redhat.com>
+ * Copyright (c) 2010,2012 Stefan Weil <weil@mail.berlios.de>
+ * Copyright (c) 2010-2012 Markus Armbruster <armbru@redhat.com>
+ * Copyright (c) 2010 Kevin Wolf <kwolf@redhat.com>
+ * Copyright (c) 2010 Isaku Yamahata <yamahata@valinux.co.jp>
+ * Copyright (c) 2011 David 'Digit' Turner <digit@google.com>
+ * Copyright (c) 2011-2012 Amit Shah <amit.shah@redhat.com>
+ * Copyright (c) 2011 Kusanagi Kouichi <slash@ac.auone-net.jp>
+ * Copyright (c) 2011-2012 Anthony Liguori <aliguori@us.ibm.com>
+ * Copyright (c) 2011 Donald Dutile <ddutile@redhat.com>
+ * Copyright (c) 2011-2012 Jan Kiszka <jan.kiszka@siemens.com>
+ * Copyright (c) 2011-2012 Paolo Bonzini <pbonzini@redhat.com>
+ * Copyright (c) 2012 Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
+ * Copyright (c) 2012 dunrong huang <riegamaths@gmail.com>
+ * Copyright (c) 2012 Michael Roth <mdroth@linux.vnet.ibm.com>
+ * Copyright (c) 2012 Anthony PERARD <anthony.perard@citrix.com>
+ * Copyright (c) 2012 Christian Borntraeger <borntraeger@de.ibm.com>
+ * Copyright (c) 2012 Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
+ *
+ * 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"
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 18/24] qdev: qdev_create(): use error_report() instead of hw_error()
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (16 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 17/24] qdev-properties.c: add copyright/license information Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 19/24] qdev: move reset handler list from vl.c to qdev.c Eduardo Habkost
` (5 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
hw_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).
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/qdev.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index 7ddcd24..2cc6434 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -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();
}
}
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 19/24] qdev: move reset handler list from vl.c to qdev.c
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (17 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 18/24] qdev: qdev_create(): use error_report() instead of hw_error() Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 20/24] qdev: add stub vmstate handling " Eduardo Habkost
` (4 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
The 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().
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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
diff --git a/hw/hw.h b/hw/hw.h
index f530f6f..622a157 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -14,6 +14,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
@@ -37,11 +38,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);
diff --git a/hw/qdev-reset.h b/hw/qdev-reset.h
new file mode 100644
index 0000000..40ae9a5
--- /dev/null
+++ b/hw/qdev-reset.h
@@ -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 */
diff --git a/hw/qdev.c b/hw/qdev.c
index 2cc6434..c242097 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -35,6 +35,47 @@ int qdev_hotplug = 0;
static bool qdev_hot_added = false;
static bool qdev_hot_removed = false;
+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);
+
+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);
+ }
+}
+
const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
{
DeviceClass *dc = DEVICE_GET_CLASS(dev);
diff --git a/hw/qdev.h b/hw/qdev.h
index 365b8d6..2487b3b 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -5,5 +5,6 @@
#include "qdev-core.h"
#include "qdev-properties.h"
#include "qdev-monitor.h"
+#include "qdev-reset.h"
#endif
diff --git a/sysemu.h b/sysemu.h
index ab1ef8b..51f19cc 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -57,7 +57,6 @@ void qemu_system_vmstop_request(RunState reason);
int qemu_shutdown_requested_get(void);
int qemu_reset_requested_get(void);
void qemu_system_killed(int signal, pid_t pid);
-void qemu_devices_reset(void);
void qemu_system_reset(bool report);
void qemu_add_exit_notifier(Notifier *notify);
diff --git a/vl.c b/vl.c
index 4f03a72..c7448a2 100644
--- a/vl.c
+++ b/vl.c
@@ -1456,14 +1456,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;
@@ -1560,38 +1552,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) {
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 20/24] qdev: add stub vmstate handling to qdev.c
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (18 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 19/24] qdev: move reset handler list from vl.c to qdev.c Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 14:39 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 21/24] qdev: add sysbus_get_default() GCC_WEAK stub Eduardo Habkost
` (3 subsequent siblings)
23 siblings, 1 reply; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
Add GCC_WEAK vmstate symbols to qdev.c, so that qdev.o can be used
without savevm.o (i.e. by *-user).
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index c242097..fe4de96 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -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);
diff --git a/vmstate.h b/vmstate.h
index 623af0a..7a56b88 100644
--- a/vmstate.h
+++ b/vmstate.h
@@ -624,11 +624,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;
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [Qemu-devel] [PATCH 20/24] qdev: add stub vmstate handling to qdev.c
2012-11-09 13:08 ` [Qemu-devel] [PATCH 20/24] qdev: add stub vmstate handling " Eduardo Habkost
@ 2012-11-09 14:39 ` Eduardo Habkost
0 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 14:39 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Paolo Bonzini, Igor Mammedov, Andreas Färber
On Fri, Nov 09, 2012 at 11:08:35AM -0200, Eduardo Habkost wrote:
> Add GCC_WEAK vmstate symbols to qdev.c, so that qdev.o can be used
> without savevm.o (i.e. by *-user).
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
So, this is now broken as GCC_WEAK is gone and now I have to use
QEMU_WEAK_ALIAS instead. I will send v7 of the series soon.
> ---
> 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(-)
>
> diff --git a/hw/qdev.c b/hw/qdev.c
> index c242097..fe4de96 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -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);
> diff --git a/vmstate.h b/vmstate.h
> index 623af0a..7a56b88 100644
> --- a/vmstate.h
> +++ b/vmstate.h
> @@ -624,11 +624,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;
> --
> 1.7.11.4
>
>
--
Eduardo
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 21/24] qdev: add sysbus_get_default() GCC_WEAK stub
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (19 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 20/24] qdev: add stub vmstate handling " Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 22/24] qdev-properties.c: separate core from the code used only by qemu-system-* Eduardo Habkost
` (2 subsequent siblings)
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
This version will be used on cases where sysbus.c is not compiled in
(e.g. *-user).
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/qdev-core.h | 2 +-
hw/qdev.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/hw/qdev-core.h b/hw/qdev-core.h
index 494b687..19d9e03 100644
--- a/hw/qdev-core.h
+++ b/hw/qdev-core.h
@@ -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);
diff --git a/hw/qdev.c b/hw/qdev.c
index fe4de96..1c4ff03 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -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);
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 22/24] qdev-properties.c: separate core from the code used only by qemu-system-*
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (20 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 21/24] qdev: add sysbus_get_default() GCC_WEAK stub Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 23/24] include qdev code into *-user, too Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 24/24] qom: make CPU a child of DeviceState Eduardo Habkost
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
This 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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
[imammedo: keep qdev_get_child_bus() in hw/qdev.c]
[imammedo: put qdev_set_nic_properties() in hw/qdev-properties-system.c]
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
[ehabkost: updated the qdev_init_gpio_in() code on qdev-system.c to current
version]
[ehabkost: added copyright/license information to new qdev*-system.c files]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index af4ab0c..4833b90 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -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
diff --git a/hw/qdev-properties-system.c b/hw/qdev-properties-system.c
new file mode 100644
index 0000000..d7ea4e3
--- /dev/null
+++ b/hw/qdev-properties-system.c
@@ -0,0 +1,371 @@
+/*
+ * qdev property parsing and global properties
+ * (parts specific for qemu-system-*)
+ *
+ * Copyright (c) 2009-2010 Gerd Hoffmann <kraxel@redhat.com>
+ * Copyright (c) 2009 Christoph Egger <Christoph.Egger@amd.com>
+ * Copyright (c) 2009-2010 Blue Swirl <blauwirbel@gmail.com>
+ * Copyright (c) 2009 Juan Quintela <quintela@redhat.com>
+ * Copyright (c) 2010 Michael S. Tsirkin <mst@redhat.com>
+ * Copyright (c) 2010,2012 Stefan Weil <weil@mail.berlios.de>
+ * Copyright (c) 2010-2012 Markus Armbruster <armbru@redhat.com>
+ * Copyright (c) 2010 Kevin Wolf <kwolf@redhat.com>
+ * Copyright (c) 2010 Isaku Yamahata <yamahata@valinux.co.jp>
+ * Copyright (c) 2011 David 'Digit' Turner <digit@google.com>
+ * Copyright (c) 2011-2012 Amit Shah <amit.shah@redhat.com>
+ * Copyright (c) 2011 Kusanagi Kouichi <slash@ac.auone-net.jp>
+ * Copyright (c) 2011-2012 Anthony Liguori <aliguori@us.ibm.com>
+ * Copyright (c) 2011 Donald Dutile <ddutile@redhat.com>
+ * Copyright (c) 2011-2012 Jan Kiszka <jan.kiszka@siemens.com>
+ * Copyright (c) 2011-2012 Paolo Bonzini <pbonzini@redhat.com>
+ * Copyright (c) 2012 Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
+ * Copyright (c) 2012 dunrong huang <riegamaths@gmail.com>
+ * Copyright (c) 2012 Michael Roth <mdroth@linux.vnet.ibm.com>
+ * Copyright (c) 2012 Anthony PERARD <anthony.perard@citrix.com>
+ * Copyright (c) 2012 Christian Borntraeger <borntraeger@de.ibm.com>
+ * Copyright (c) 2012 Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
+ *
+ * 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"
+#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 ? print(*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);
+}
+
+/* --- 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,
+};
+
+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;
+}
+
+/* --- 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);
+}
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index ff5aa0a..d363971 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -43,49 +43,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 ? print(*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)
{
@@ -506,227 +463,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! */
@@ -1188,44 +924,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;
@@ -1261,7 +959,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);
}
@@ -1292,20 +990,3 @@ void qdev_prop_set_globals(DeviceState *dev)
class = object_class_get_parent(class);
} 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);
-}
diff --git a/hw/qdev-properties.h b/hw/qdev-properties.h
index 5b046ab..ddcf774 100644
--- a/hw/qdev-properties.h
+++ b/hw/qdev-properties.h
@@ -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,
diff --git a/hw/qdev.c b/hw/qdev.c
index 1c4ff03..bf998d3 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -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;
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 23/24] include qdev code into *-user, too
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (21 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 22/24] qdev-properties.c: separate core from the code used only by qemu-system-* Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
2012-11-09 13:08 ` [Qemu-devel] [PATCH 24/24] qom: make CPU a child of DeviceState Eduardo Habkost
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
The code depends on some functions from qemu-option.o, so add
qemu-option.o to universal-obj-y to make sure it's included.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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(-)
diff --git a/Makefile.objs b/Makefile.objs
index 593a592..be3c8ef 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -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 cutils.o qemu-timer-common.o
oslib-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o
@@ -244,5 +251,6 @@ nested-vars += \
block-obj-y \
user-obj-y \
common-obj-y \
+ hw-core-obj-y \
extra-obj-y
dummy := $(call unnest-vars)
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 4833b90..2c931e9 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -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
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Qemu-devel] [PATCH 24/24] qom: make CPU a child of DeviceState
2012-11-09 13:08 [Qemu-devel] [PATCH 00/24] CPU DeviceState v6 Eduardo Habkost
` (22 preceding siblings ...)
2012-11-09 13:08 ` [Qemu-devel] [PATCH 23/24] include qdev code into *-user, too Eduardo Habkost
@ 2012-11-09 13:08 ` Eduardo Habkost
23 siblings, 0 replies; 30+ messages in thread
From: Eduardo Habkost @ 2012-11-09 13:08 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, riku.voipio, blauwirbel, Anthony Liguori,
Igor Mammedov, Andreas Färber
From: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
[ehabkost: change CPU type declaration to hae TYPE_DEVICE as parent]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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(-)
diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h
index 61b7698..bc004fd 100644
--- a/include/qemu/cpu.h
+++ b/include/qemu/cpu.h
@@ -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);
@@ -62,7 +62,7 @@ typedef struct CPUClass {
*/
struct CPUState {
/*< private >*/
- Object parent_obj;
+ DeviceState parent_obj;
/*< public >*/
struct QemuThread *thread;
diff --git a/qom/cpu.c b/qom/cpu.c
index 5b36046..f59db7d 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -20,6 +20,7 @@
#include "qemu/cpu.h"
#include "qemu-common.h"
+#include "hw/qdev-core.h"
void cpu_reset(CPUState *cpu)
{
@@ -43,7 +44,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
static TypeInfo cpu_type_info = {
.name = TYPE_CPU,
- .parent = TYPE_OBJECT,
+ .parent = TYPE_DEVICE,
.instance_size = sizeof(CPUState),
.abstract = true,
.class_size = sizeof(CPUClass),
--
1.7.11.4
^ permalink raw reply related [flat|nested] 30+ messages in thread