Skip to contentSkip to conversation

CPU DeviceState v7

PATCH Applied Eduardo Habkost 5 participants 61 messages Nov 9, 2012 – Dec 4, 2012 Kbuild

lore
Share & tools
lore
#4 lore raw

PATCH 2/24 user: rename qemu-types.h to qemu-user-types.h

In reply to Eduardo Habkost

The header file is specific for *-user, but I plan to introduce a more generic qemu-types.h file, so I'm renaming it.

---
Cc: Blue Swirl <[email protected]>
Cc: Riku Voipio <[email protected]>

---
 bsd-user/qemu.h                   | 2 +-
 cpu-all.h                         | 2 +-
 linux-user/qemu.h                 | 2 +-
 qemu-types.h => qemu-user-types.h | 0
 4 files changed, 3 insertions(+), 3 deletions(-)
 rename qemu-types.h => qemu-user-types.h (100%)
bsd-user/qemu.h +1 -1
index 8a5ee3d..d268899 100644
@@ -11,7 +11,7 @@
 #include <stdlib.h>
 #endif /* DEBUG_REMAP */
 
-#include "qemu-types.h"
+#include "qemu-user-types.h"
 
 enum BSDType {
     target_freebsd,
cpu-all.h +1 -1
index c9c51b8..d6b2b19 100644
@@ -180,7 +180,7 @@ static inline void tswap64s(uint64_t *s)
 
 #if defined(CONFIG_USER_ONLY)
 #include <assert.h>
-#include "qemu-types.h"
+#include "qemu-user-types.h"
 
 /* On some host systems the guest address space is reserved on the host.
  * This allows the guest address space to be offset to a convenient location.
linux-user/qemu.h +1 -1
index 5e53dca..ceddb3c 100644
@@ -11,7 +11,7 @@
 #include <stdlib.h>
 #endif /* DEBUG_REMAP */
 
-#include "qemu-types.h"
+#include "qemu-user-types.h"
 
 #include "thunk.h"
 #include "syscall_defs.h"
qemu-user-types.h renamed from qemu-types.h +0 -0
similarity index 100%
rename from qemu-types.h
rename to qemu-user-types.h
Signature · 1 line
1.7.11.7
#37 lore raw

PATCH 15/24 qlist.h: do not include qemu-common.h

In reply to Eduardo Habkost

I don't know why it was including it, as I don't see any code that depends on anything from qemu-common.h.

---
 qlist.h | 1 -
 1 file changed, 1 deletion(-)
qlist.h +0 -1
index ae776f9..7408947 100644
@@ -15,7 +15,6 @@
 
 #include "qobject.h"
 #include "qemu-queue.h"
-#include "qemu-common.h"
 #include "qemu-queue.h"
 
 typedef struct QListEntry {
Signature · 1 line
1.7.11.7
#55 lore raw

PATCH 20/24 qdev: add weak aliases for vmstate handling on qdev.c

In reply to Eduardo Habkost

Add weak alias to vmstate stub functions on qdev.c, so that qdev.o can be used without savevm.o when vmstate support is not necessary (i.e. by *-user).

---
Originally submitted as:
Subject: qdev-core: isolate vmstate handling into separate functions

Changes v1 -> v2:
- Add GCC_WEAK_DECL to function declarations

Changes v2 -> v3:
- Make vmstate_register_with_alias_id()/vmstate_unregister() have GCC_WEAK versions, instead of creating a new function
- Kept qdev_get_vmsd() inside qdev.c

Changess v3 -> v4:
- Use the new QEMU_WEAK_ALIAS system instead of GCC_WEAK

---
 hw/qdev.c | 24 ++++++++++++++++++++++++
 vmstate.h |  2 ++
 2 files changed, 26 insertions(+)
hw/qdev.c +24 -0
index c242097..94ae1cd 100644
@@ -76,6 +76,30 @@ 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.
+ */
+
+static int stub_vmstate_register_with_alias_id(DeviceState *dev,
+                                               int instance_id,
+                                               const VMStateDescription *vmsd,
+                                               void *base, int alias_id,
+                                               int required_for_version)
+{
+    return 0;
+}
+QEMU_WEAK_ALIAS(vmstate_register_with_alias_id,
+                stub_vmstate_register_with_alias_id);
+
+static void stub_vmstate_unregister(DeviceState *dev,
+                                    const VMStateDescription *vmsd,
+                                    void *opaque)
+{
+}
+QEMU_WEAK_ALIAS(vmstate_unregister, stub_vmstate_unregister);
+
 const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
vmstate.h +2 -0
index 623af0a..114c994 100644
@@ -624,6 +624,8 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
                         void *opaque);
 int vmstate_register(DeviceState *dev, int instance_id,
                      const VMStateDescription *vmsd, void *base);
+
+/* The following functions have weak aliases on qdev-core, for *-user: */
 int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
                                    const VMStateDescription *vmsd,
                                    void *base, int alias_id,
Signature · 1 line
1.7.11.7
#19 lore raw

PATCH 7/24 qemu-fsdev-dummy.c: include module.h

In reply to Eduardo Habkost

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.

---
 fsdev/qemu-fsdev-dummy.c | 1 +
 1 file changed, 1 insertion(+)
fsdev/qemu-fsdev-dummy.c +1 -0
index 4e700dd..300f275 100644
@@ -14,6 +14,7 @@
 #include <string.h>
 #include "qemu-fsdev.h"
 #include "qemu-config.h"
+#include "module.h"
 
 int qemu_fsdev_add(QemuOpts *opts)
 {
Signature · 1 line
1.7.11.7
#30 lore raw

PATCH 12/24 qga/channel-posix.c: include headers it needs

In reply to Eduardo Habkost

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.

---
 qga/channel-posix.c | 4 ++++
 1 file changed, 4 insertions(+)
qga/channel-posix.c +4 -0
index d152827..2a68451 100644
@@ -1,5 +1,9 @@
 #include <glib.h>
 #include <termios.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "qemu-stdio.h"
 #include "qemu_socket.h"
 #include "qga/channel.h"
 
Signature · 1 line
1.7.11.7
#34 lore raw

PATCH 14/24 sysemu.h: include qemu-types.h instead of qemu-common.h

In reply to Eduardo Habkost

It just needs the Monitor and DeviceState typedefs, so it doesn't need all of qemu-common.h.

---
 sysemu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sysemu.h +1 -1
index f5ac664..ab1ef8b 100644
@@ -2,7 +2,7 @@
 #define SYSEMU_H
 /* Misc. things related to the system emulator.  */
 
-#include "qemu-common.h"
+#include "qemu-types.h"
 #include "qemu-option.h"
 #include "qemu-queue.h"
 #include "qemu-timer.h"
Signature · 1 line
1.7.11.7
#59 lore raw

PATCH 23/24 include qdev code into *-user, too

In reply to Eduardo Habkost

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.

---
Changes v1 -> v2:
- Keep files on the hw/ directory
(it's simply easier to keep them there, as qdev.o depends on irq.o)
- Add a $(hw-core-obj-y) variable to Makefile.objs for the qdev core code
- Add irq.o to the list of core qdev files
(as now the gpio code is being kept inside qdev.c)

---
 Makefile.objs    | 8 ++++++++
 hw/Makefile.objs | 8 ++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
Makefile.objs +8 -0
index 593a592..be3c8ef 100644
@@ -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)
hw/Makefile.objs +6 -2
index 4833b90..2c931e9 100644
@@ -1,3 +1,8 @@
+# core qdev-related obj files, also used by *-user:
+hw-core-obj-y += qdev.o qdev-properties.o
+# irq.o needed for qdev GPIO handling:
+hw-core-obj-y += irq.o
+
 common-obj-y = usb/ ide/
 common-obj-y += loader.o
 common-obj-$(CONFIG_VIRTIO) += virtio-console.o
@@ -155,7 +160,6 @@ common-obj-$(CONFIG_SOUND) += $(sound-obj-y)
 common-obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/
 
 common-obj-y += usb/
-common-obj-y += irq.o
 common-obj-$(CONFIG_PTIMER) += ptimer.o
 common-obj-$(CONFIG_MAX7310) += max7310.o
 common-obj-$(CONFIG_WM8750) += wm8750.o
@@ -181,7 +185,7 @@ common-obj-$(CONFIG_SD) += sd.o
 common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += msmouse.o ps2.o
-common-obj-y += qdev.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-monitor.o
 common-obj-y += qdev-properties-system.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 
Signature · 1 line
1.7.11.7
#60 lore raw

PATCH 24/24 qom: make CPU a child of DeviceState

In reply to Eduardo Habkost

From: Igor Mammedov <[email protected]>

[ehabkost: change CPU type declaration to hae TYPE_DEVICE as parent]

---
Yes, there is "changelog" data before the "---" mark, but I believe that in this case they are important to indicate authorship and the scope of the Signed-off-by lines (so they need to get into the git commit message).

---
 include/qemu/cpu.h | 6 +++---
 qom/cpu.c          | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
include/qemu/cpu.h +3 -3
index 61b7698..bc004fd 100644
@@ -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;
qom/cpu.c +2 -1
index 5b36046..f59db7d 100644
@@ -20,6 +20,7 @@
 
 #include "qemu/cpu.h"
 #include "qemu-common.h"
+#include "hw/qdev-core.h"
 
 void cpu_reset(CPUState *cpu)
 {
@@ -43,7 +44,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
 
 static TypeInfo cpu_type_info = {
     .name = TYPE_CPU,
-    .parent = TYPE_OBJECT,
+    .parent = TYPE_DEVICE,
     .instance_size = sizeof(CPUState),
     .abstract = true,
     .class_size = sizeof(CPUClass),
Signature · 1 line
1.7.11.7
#0 lore raw

cover CPU DeviceState v7

Changes on v7:
- Use the new QEMU_WEAK_ALIAS mechanism instead of the (now extinct) GCC_WEAK attribute (patches 20 and 21)

v6:
- Simple rebase against latest qemu.git master
- Patch 13: some new typedefs were added and others were removed
- Patch 19: trivial rebase
v5:
- Tons of header cleanups just to eliminate qlist.h <-> cpu-common.h circular dependency (patches 1-17)
- Add copyright/license information to qdev-properties.c (patch 17)
- Add copyright/license information to qdev-properties-system.c (patch 22)
- use error_report()+abort() instead of hw_error() on qdev.c (patch 18)
- Move qemu_[un]register_reset() and qemu_devices_reset() to qdev-core.c (patch 19)
- Make vmstate_[un]register() weak stubs, instead of a new function (patch 20)
- Make sysbus_get_default() weak stub, instead of new qbus reset (un)register functions (patch 21)
- Eliminate qdev-system.c (all code is kept on qdev.c, now) (patch 22)
v4:
- Add GCC_WEAK_DECL to functions that have GCC_WEAK versions
- Updated the qdev_init_gpio_in() code on qdev-system.c to current version
- Patch description updates (moved changelog below "---" and/or move info about changes made by different authors between SoB lines)
v3 (submitted by Igor):
- rebased on top of 8b4a3df (today's master)
- slight code reshuffling in (see commit's changelog)
"qdev: separate core from the code used only by qemu-system-*" "move qemu_irq typedef out of cpu-common.h"
- commit messages cleanup
v2:
Removes the CONFIG_USER_ONLY ifdefs, and use weak symbols to move the vmstate and qemu_register_reset() handling to qdev-system.c

git tree for testing:
https://github.com/ehabkost/qemu-hacks/tree/cpu_qdev.v7

References to previous versions:
v6: http://article.gmane.org/gmane.comp.emulators.qemu/179918
v5: http://article.gmane.org/gmane.comp.emulators.qemu/177426
v4: http://article.gmane.org/gmane.comp.emulators.qemu/176127
v3: http://article.gmane.org/gmane.comp.emulators.qemu/175980
v2: http://article.gmane.org/gmane.comp.emulators.qemu/173909
v1: http://article.gmane.org/gmane.comp.emulators.qemu/166630

Anthony Liguori (1):
qdev: split up header so it can be used in cpu.h

Eduardo Habkost (20):
user: move *-user/qemu-types.h to main directory
user: rename qemu-types.h to qemu-user-types.h qemu-common.h: comment about usage rules
move I/O-related definitions from qemu-common.h to a new header

    (qemu-stdio.h)

qemu-fsdev-dummy.c: include module.h
vnc-palette.h: include <stdbool.h> ui/vnc-pallete.c: include headers it needs qemu-config.h: include headers it needs qapi/qmp-registry.c: include headers it needs qga/channel-posix.c: include headers it needs create qemu-types.h for struct typedefs
sysemu.h: include qemu-types.h instead of qemu-common.h qlist.h: do not include qemu-common.h qdev-properties.c: add copyright/license information
qdev: qdev_create(): use error_report() instead of hw_error()
qdev: move reset handler list from vl.c to qdev.c
qdev: add weak aliases for vmstate handling on qdev.c
qdev: add weak alias to sysbus_get_default() on qdev.c qdev-properties.c: separate core from the code used only by
qemu-system-*
include qdev code into *-user, too

Igor Mammedov (3):
move qemu_irq typedef out of cpu-common.h
qapi-types.h: don't include qemu-common.h
qom: make CPU a child of DeviceState

 Makefile.objs                                |   8 +
 bsd-user/qemu-types.h                        |  24 --
 bsd-user/qemu.h                              |   2 +-
 cpu-all.h                                    |   2 +-
 fsdev/qemu-fsdev-dummy.c                     |   1 +
 hw/Makefile.objs                             |   9 +-
 hw/arm-misc.h                                |   1 +
 hw/bt.h                                      |   2 +
 hw/devices.h                                 |   2 +
 hw/hw.h                                      |   6 +-
 hw/irq.h                                     |   2 +
 hw/mc146818rtc.c                             |   1 +
 hw/omap.h                                    |   1 +
 hw/qdev-addr.c                               |   1 +
 hw/qdev-core.h                               | 232 +++++++++++++++++
 hw/qdev-monitor.h                            |  16 ++
 hw/qdev-properties-system.c                  | 371 +++++++++++++++++++++++++++
 hw/qdev-properties.c                         | 352 +++----------------------
 hw/qdev-properties.h                         | 131 ++++++++++
 hw/qdev-reset.h                              |  11 +
 hw/qdev.c                                    | 100 ++++++--
 hw/qdev.h                                    | 371 +--------------------------
 hw/soc_dma.h                                 |   1 +
 hw/xen.h                                     |   1 +
 include/qemu/cpu.h                           |   6 +-
 linux-user/qemu.h                            |   2 +-
 qapi/qmp-registry.c                          |   2 +
 qemu-common.h                                | 123 +--------
 qemu-config.h                                |   2 +
 qemu-stdio.h                                 |  76 ++++++
 qemu-types.h                                 |  61 +++++
 linux-user/qemu-types.h => qemu-user-types.h |   0
 qga/channel-posix.c                          |   4 +
 qlist.h                                      |   1 -
 qom/cpu.c                                    |   3 +-
 scripts/qapi-types.py                        |   3 +-
 sysemu.h                                     |   3 +-
 ui/vnc-palette.c                             |   2 +
 ui/vnc-palette.h                             |   1 +
 vl.c                                         |  40 ---
 vmstate.h                                    |   2 +
 41 files changed, 1085 insertions(+), 894 deletions(-)
 delete mode 100644 bsd-user/qemu-types.h
 create mode 100644 hw/qdev-core.h
 create mode 100644 hw/qdev-monitor.h
 create mode 100644 hw/qdev-properties-system.c
 create mode 100644 hw/qdev-properties.h
 create mode 100644 hw/qdev-reset.h
 create mode 100644 qemu-stdio.h
 create mode 100644 qemu-types.h
 rename linux-user/qemu-types.h => qemu-user-types.h (100%)
Signature · 1 line
1.7.11.7
#41 lore raw

PATCH 16/24 qapi-types.h: don't include qemu-common.h

From: Igor Mammedov <[email protected]>

needed to prevent build breakage when CPU becomes a child of DeviceState

[ehabkost: include <stdbool.h> too]

---
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(-)
scripts/qapi-types.py +2 -1
index 1b84834..6bc2391 100644
@@ -273,7 +273,8 @@ fdecl.write(mcgen('''
 #ifndef %(guard)s
 #define %(guard)s
 
-#include "qemu-common.h"
+#include <stdbool.h>
+#include <stdint.h>
 
 ''',
                   guard=guardname(h_file)))
Signature · 1 line
1.7.11.7
#9 lore raw

PATCH 4/24 move qemu_irq typedef out of cpu-common.h

In reply to Eduardo Habkost

From: Igor Mammedov <[email protected]>

it's necessary for making CPU child of DEVICE without causing circular header deps.

[ehabkost: re-added the typedef to hw/irq.h after rebasing]

---
Changes v1 (from Igor) -> v2 (sent by Eduardo):
- Chunk adding typedef on hw/irq.h was not present, because of patch rebase against qdev header split patch

Changes v2 -> v3 (from Igor):
- sysemu.h doesn't need irq.h since 013c2f150

Changes v3 -> v4 (from Eduardo):
- re-added the typedef code to hw/irq.h, after rebasing the patch

---
 hw/arm-misc.h | 1 +
 hw/bt.h       | 2 ++
 hw/devices.h  | 2 ++
 hw/irq.h      | 2 ++
 hw/omap.h     | 1 +
 hw/soc_dma.h  | 1 +
 hw/xen.h      | 1 +
 qemu-common.h | 1 -
 8 files changed, 10 insertions(+), 1 deletion(-)
hw/arm-misc.h +1 -0
index adb1665..d129678 100644
@@ -12,6 +12,7 @@
 #define ARM_MISC_H 1
 
 #include "memory.h"
+#include "hw/irq.h"
 
 /* The CPU is also modeled as an interrupt controller.  */
 #define ARM_PIC_CPU_IRQ 0
hw/bt.h +2 -0
index a48b8d4..ebf6a37 100644
@@ -23,6 +23,8 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "hw/irq.h"
+
 /* BD Address */
 typedef struct {
     uint8_t b[6];
hw/devices.h +2 -0
index 1a55c1e..c60bcab 100644
@@ -1,6 +1,8 @@
 #ifndef QEMU_DEVICES_H
 #define QEMU_DEVICES_H
 
+#include "hw/irq.h"
+
 /* ??? Not all users of this file can include cpu-common.h.  */
 struct MemoryRegion;
 
hw/irq.h +2 -0
index e640c10..610e6b7 100644
@@ -3,6 +3,8 @@
 
 /* Generic IRQ/GPIO pin infrastructure.  */
 
+typedef struct IRQState *qemu_irq;
+
 typedef void (*qemu_irq_handler)(void *opaque, int n, int level);
 
 void qemu_set_irq(qemu_irq irq, int level);
hw/omap.h +1 -0
index 8bd7c73..2b383ff 100644
@@ -19,6 +19,7 @@
 #ifndef hw_omap_h
 #include "memory.h"
 # define hw_omap_h		"omap.h"
+#include "hw/irq.h"
 
 # define OMAP_EMIFS_BASE	0x00000000
 # define OMAP2_Q0_BASE		0x00000000
hw/soc_dma.h +1 -0
index 9340b8f..5948489 100644
@@ -19,6 +19,7 @@
  */
 
 #include "memory.h"
+#include "hw/irq.h"
 
 struct soc_dma_s;
 struct soc_dma_ch_s;
hw/xen.h +1 -0
index d14e92d..e3cca7f 100644
@@ -8,6 +8,7 @@
  */
 #include <inttypes.h>
 
+#include "hw/irq.h"
 #include "qemu-common.h"
 
 /* xen-machine.c */
qemu-common.h +0 -1
index ea43bfa..6441bee 100644
@@ -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;
Signature · 1 line
1.7.11.7
#14 lore raw

PATCH 6/24 move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h)

In reply to Eduardo Habkost

This will help reduce the qemu-common.h dependency hell.

--
Changes v1 -> v2:
- move qemu_open() & qemu_close() to qemu-stdio.h, too

---
 qemu-common.h | 59 ++--------------------------------------------
 qemu-stdio.h  | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+), 57 deletions(-)
 create mode 100644 qemu-stdio.h
qemu-common.h +2 -57
index 6441bee..5080382 100644
@@ -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)
qemu-stdio.h new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#56 lore raw

PATCH 21/24 qdev: add weak alias to sysbus_get_default() on qdev.c

In reply to Eduardo Habkost

This version will be used on cases where sysbus.c is not compiled in (e.g. *-user).

---
Changes v1 -> v2:
- Use the new QEMU_WEAK_ALIAS mechanism, instead of GCC_WEAK

---
 hw/qdev-core.h |  5 ++++-
 hw/qdev.c      | 13 +++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
hw/qdev-core.h +4 -1
index 494b687..b64daf0 100644
@@ -193,7 +193,10 @@ 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 */
+/* This should go away once we get rid of the NULL bus hack.
+ * This has a weak alias for a stub function on qdev.c (for *-user, that
+ * doesn't have a main system bus).
+ */
 BusState *sysbus_get_default(void);
 
 char *qdev_get_fw_dev_path(DeviceState *dev);
hw/qdev.c +13 -0
index 94ae1cd..0702659 100644
@@ -100,6 +100,19 @@ static void stub_vmstate_unregister(DeviceState *dev,
 }
 QEMU_WEAK_ALIAS(vmstate_unregister, stub_vmstate_unregister);
 
+
+/* 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).
+ */
+
+static BusState *sysbus_get_none(void)
+{
+    return NULL;
+}
+QEMU_WEAK_ALIAS(sysbus_get_default, sysbus_get_none);
+
 const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH 1/24 user: move *-user/qemu-types.h to main directory

In reply to Eduardo Habkost

The bsd-user/qemu-types.h and linux-user/qemu-types.h files are almost the same, but linux-user have the additional definitions of tswapal().

This moves the linux-user file to the main directory, so the same file can be used by linux-user and bsd-user.

---
Cc: Blue Swirl <[email protected]>
Cc: Riku Voipio <[email protected]>

---
 bsd-user/qemu-types.h                   | 24 ------------------------
 linux-user/qemu-types.h => qemu-types.h |  0
 2 files changed, 24 deletions(-)
 delete mode 100644 bsd-user/qemu-types.h
 rename linux-user/qemu-types.h => qemu-types.h (100%)
bsd-user/qemu-types.h deleted +0 -24
deleted file mode 100644
index 1adda9f..0000000
@@ -1,24 +0,0 @@
-#ifndef QEMU_TYPES_H
-#define QEMU_TYPES_H
-#include "cpu.h"
-
-#ifdef TARGET_ABI32
-typedef uint32_t abi_ulong;
-typedef int32_t abi_long;
-#define TARGET_ABI_FMT_lx "%08x"
-#define TARGET_ABI_FMT_ld "%d"
-#define TARGET_ABI_FMT_lu "%u"
-#define TARGET_ABI_BITS 32
-#else
-typedef target_ulong abi_ulong;
-typedef target_long abi_long;
-#define TARGET_ABI_FMT_lx TARGET_FMT_lx
-#define TARGET_ABI_FMT_ld TARGET_FMT_ld
-#define TARGET_ABI_FMT_lu TARGET_FMT_lu
-#define TARGET_ABI_BITS TARGET_LONG_BITS
-/* for consistency, define ABI32 too */
-#if TARGET_ABI_BITS == 32
-#define TARGET_ABI32 1
-#endif
-#endif
-#endif
qemu-types.h renamed from linux-user/qemu-types.h +0 -0
similarity index 100%
rename from linux-user/qemu-types.h
rename to qemu-types.h
Signature · 1 line
1.7.11.7
#28 lore raw

PATCH 11/24 qapi/qmp-registry.c: include headers it needs

In reply to Eduardo Habkost

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.

---
 qapi/qmp-registry.c | 2 ++
 1 file changed, 2 insertions(+)
qapi/qmp-registry.c +2 -0
index 5414613..c2c31b4 100644
@@ -12,6 +12,8 @@
  *
  */
 
+#include <glib.h>
+#include <string.h>
 #include "qapi/qmp-core.h"
 
 static QTAILQ_HEAD(QmpCommandList, QmpCommand) qmp_commands =
Signature · 1 line
1.7.11.7
#32 lore raw

PATCH 13/24 create qemu-types.h for struct typedefs

In reply to Eduardo Habkost

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.

---
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
hw/qdev-core.h +1 -10
index fce9e22..494b687 100644
@@ -3,20 +3,11 @@
 
 #include "qemu-queue.h"
 #include "qemu-option.h"
+#include "qemu-types.h"
 #include "qemu/object.h"
 #include "hw/irq.h"
 #include "error.h"
 
-typedef struct Property Property;
-
-typedef struct PropertyInfo PropertyInfo;
-
-typedef struct CompatProperty CompatProperty;
-
-typedef struct BusState BusState;
-
-typedef struct BusClass BusClass;
-
 enum DevState {
     DEV_STATE_CREATED = 1,
     DEV_STATE_INITIALIZED,
qemu-common.h +1 -51

70 lines not on this page · raw message

qemu-types.h new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#26 lore raw

PATCH 10/24 qemu-config.h: include headers it needs

In reply to Eduardo Habkost

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.

---
 qemu-config.h | 2 ++
 1 file changed, 2 insertions(+)
qemu-config.h +2 -0
index 5557562..812c4c5 100644
@@ -1,6 +1,8 @@
 #ifndef QEMU_CONFIG_H
 #define QEMU_CONFIG_H
 
+#include <stdio.h>
+#include "qemu-option.h"
 #include "error.h"
 
 extern QemuOptsList qemu_fsdev_opts;
Signature · 1 line
1.7.11.7
#43 lore raw

PATCH 17/24 qdev-properties.c: add copyright/license information

In reply to Eduardo Habkost

Add copyright and license information, based on git log, and discussion at:

http://article.gmane.org/gmane.comp.emulators.qemu/176405
Message-ID: <[email protected]>

The list of Copyright owners is huge, but I didn't think I really could leave any of the authors out of the list.

---
The only reason I am doing this is because:
- I am going to mvoe some of the qdev-properties.c file to another file
- I need to add a copyright/license header to the new file. See http://article.gmane.org/gmane.comp.emulators.qemu/176367
- So, I need to document the copyright/license of the current qdev-properties.c code

I would really love to avoid this whole archaeology/legalese work, because I am not a lawyer. I am only doing that because of the "new files should have a copyright header" requirement.

Cc Amit Shah <[email protected]>
Cc Anthony Liguori <[email protected]>
Cc Anthony PERARD <[email protected]>
Cc Blue Swirl <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Christoph Egger <[email protected]>
Cc David 'Digit' Turner <[email protected]>
Cc Donald Dutile <[email protected]>
Cc dunrong huang <[email protected]>
Cc Gerd Hoffmann <[email protected]>
Cc Isaku Yamahata <[email protected]>
Cc Jan Kiszka <[email protected]>
Cc Jan Kiszka <[email protected]>
Cc Juan Quintela <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Kusanagi Kouichi <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Michael Roth <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Stefan Weil <[email protected]>
Cc Stefan Weil <[email protected]>
Cc Zhi Yong Wu <[email protected]>
---
 hw/qdev-properties.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
hw/qdev-properties.c +30 -0
index 81d901c..ff5aa0a 100644
@@ -1,3 +1,33 @@
+/*
+ * qdev property parsing and global properties
+ *
+ * Copyright (c) 2009-2010 Gerd Hoffmann <[email protected]>
+ * Copyright (c) 2009 Christoph Egger <[email protected]>
+ * Copyright (c) 2009-2010 Blue Swirl <[email protected]>
+ * Copyright (c) 2009 Juan Quintela <[email protected]>
+ * Copyright (c) 2010 Michael S. Tsirkin <[email protected]>
+ * Copyright (c) 2010,2012 Stefan Weil <[email protected]>
+ * Copyright (c) 2010-2012 Markus Armbruster <[email protected]>
+ * Copyright (c) 2010 Kevin Wolf <[email protected]>
+ * Copyright (c) 2010 Isaku Yamahata <[email protected]>
+ * Copyright (c) 2011 David 'Digit' Turner <[email protected]>
+ * Copyright (c) 2011-2012 Amit Shah <[email protected]>
+ * Copyright (c) 2011 Kusanagi Kouichi <[email protected]>
+ * Copyright (c) 2011-2012 Anthony Liguori <[email protected]>
+ * Copyright (c) 2011 Donald Dutile <[email protected]>
+ * Copyright (c) 2011-2012 Jan Kiszka <[email protected]>
+ * Copyright (c) 2011-2012 Paolo Bonzini <[email protected]>
+ * Copyright (c) 2012 Stefan Hajnoczi <[email protected]>
+ * Copyright (c) 2012 dunrong huang <[email protected]>
+ * Copyright (c) 2012 Michael Roth <[email protected]>
+ * Copyright (c) 2012 Anthony PERARD <[email protected]>
+ * Copyright (c) 2012 Christian Borntraeger <[email protected]>
+ * Copyright (c) 2012 Zhi Yong Wu <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
 #include "net.h"
 #include "qdev.h"
 #include "qerror.h"
Signature · 1 line
1.7.11.7
#44 lore raw

PATCH 18/24 qdev: qdev_create(): use error_report() instead of hw_error()

In reply to Eduardo Habkost

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).

---
 hw/qdev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
hw/qdev.c +5 -3
index 7ddcd24..2cc6434 100644
@@ -109,10 +109,12 @@ DeviceState *qdev_create(BusState *bus, const char *name)
     dev = qdev_try_create(bus, name);
     if (!dev) {
         if (bus) {
-            hw_error("Unknown device '%s' for bus '%s'\n", name,
-                     object_get_typename(OBJECT(bus)));
+            error_report("Unknown device '%s' for bus '%s'\n", name,
+                         object_get_typename(OBJECT(bus)));
+            abort();
         } else {
-            hw_error("Unknown device '%s' for default sysbus\n", name);
+            error_report("Unknown device '%s' for default sysbus\n", name);
+            abort();
         }
     }
 
Signature · 1 line
1.7.11.7
#57 lore raw

PATCH 22/24 qdev-properties.c: separate core from the code used only by qemu-system-*

In reply to Eduardo Habkost

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.

[imammedo: keep qdev_get_child_bus() in hw/qdev.c]
[imammedo: put qdev_set_nic_properties() in hw/qdev-properties-system.c]

[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]

---
Yes, there is "changelog" data before the "---" mark, but I believe that in this case they are important to indicate authorship and the scope of the Signed-off-by lines (so they need to get into the git commit message).

Detailed changelog:

Changes v1 (ehabkost) -> v2 (imammedo):
- keep qdev_get_child_bus() in hw/qdev.c
- put qdev_set_nic_properties() in hw/qdev-properties-system.c

Changes v2 -> v3 (ehabkost):
- updated the qdev_init_gpio_in() code on qdev-system.c to current version

Changes v3 -> v4 (ehabkost):
- Added copyright/license information to qdev-properties-system.c (based on copyright/license of qdev-properties.c)
- Whitespace change at the end of qdev-properties.c
- Don't create qdev-system.c, now we can keep the qdev.c code as-is as the qdev.c dependencies were reduced
- Rewrite patch description

---
 hw/Makefile.objs            |   1 +
 hw/qdev-properties-system.c | 371 ++++++++++++++++++++++++++++++++++++++++++++
 hw/qdev-properties.c        | 321 +-------------------------------------
 hw/qdev-properties.h        |   1 +
 hw/qdev.c                   |  13 --
 5 files changed, 374 insertions(+), 333 deletions(-)
 create mode 100644 hw/qdev-properties-system.c
hw/Makefile.objs +1 -0
index af4ab0c..4833b90 100644
@@ -182,6 +182,7 @@ common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += msmouse.o ps2.o
 common-obj-y += qdev.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-properties-system.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 
 # xen backend driver support
hw/qdev-properties-system.c new file +371 -0

371 lines not on this page · raw message

hw/qdev-properties.c +1 -320

348 lines not on this page · raw message

hw/qdev-properties.h +1 -0
index 5b046ab..ddcf774 100644
@@ -116,6 +116,7 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 /* FIXME: Remove opaque pointer properties.  */
 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
 
+void qdev_prop_register_global(GlobalProperty *prop);
 void qdev_prop_register_global_list(GlobalProperty *props);
 void qdev_prop_set_globals(DeviceState *dev);
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
hw/qdev.c +0 -13
index 0702659..f00c029 100644
@@ -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"
@@ -390,18 +389,6 @@ void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin)
     dev->gpio_out[n] = pin;
 }
 
-void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
-{
-    qdev_prop_set_macaddr(dev, "mac", nd->macaddr.a);
-    if (nd->netdev)
-        qdev_prop_set_netdev(dev, "netdev", nd->netdev);
-    if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&
-        object_property_find(OBJECT(dev), "vectors", NULL)) {
-        qdev_prop_set_uint32(dev, "vectors", nd->nvectors);
-    }
-    nd->instantiated = 1;
-}
-
 BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
 {
     BusState *bus;
Signature · 1 line
1.7.11.7
#6 lore raw

PATCH 3/24 qemu-common.h: comment about usage rules

In reply to Eduardo Habkost

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.

---
 qemu-common.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
qemu-common.h +10 -1
index ac9985c..ea43bfa 100644
@@ -1,5 +1,14 @@
 
-/* Common header file that is included by all of qemu.  */
+/* Common header file that is included by all of qemu.
+ *
+ * This file is supposed to be included only by .c files. No header file should
+ * depend on qemu-common.h, as this would easily lead to circular header
+ * dependencies.
+ *
+ * If a header files uses a definition from qemu-common.h, that definition
+ * must be moved to a separate header file, and the header that uses it
+ * must include that header.
+ */
 #ifndef QEMU_COMMON_H
 #define QEMU_COMMON_H
 
Signature · 1 line
1.7.11.7
#46 lore raw

PATCH 19/24 qdev: move reset handler list from vl.c to qdev.c

In reply to Eduardo Habkost

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().

---
 hw/hw.h         |  6 +-----
 hw/qdev-reset.h | 11 +++++++++++
 hw/qdev.c       | 41 +++++++++++++++++++++++++++++++++++++++++
 hw/qdev.h       |  1 +
 sysemu.h        |  1 -
 vl.c            | 40 ----------------------------------------
 6 files changed, 54 insertions(+), 46 deletions(-)
 create mode 100644 hw/qdev-reset.h
hw/hw.h +1 -5
index f530f6f..622a157 100644
@@ -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);
hw/qdev-reset.h new file +11 -0
new file mode 100644
index 0000000..40ae9a5
@@ -0,0 +1,11 @@
+/* Device reset handler function registration, used by qdev */
+#ifndef QDEV_RESET_H
+#define QDEV_RESET_H
+
+typedef void QEMUResetHandler(void *opaque);
+
+void qemu_register_reset(QEMUResetHandler *func, void *opaque);
+void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
+void qemu_devices_reset(void);
+
+#endif /* QDEV_RESET_H */
hw/qdev.c +41 -0

47 lines not on this page · raw message

hw/qdev.h +1 -0
index 365b8d6..2487b3b 100644
@@ -5,5 +5,6 @@
 #include "qdev-core.h"
 #include "qdev-properties.h"
 #include "qdev-monitor.h"
+#include "qdev-reset.h"
 
 #endif
sysemu.h +0 -1
index ab1ef8b..51f19cc 100644
@@ -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);
vl.c +0 -40
index 4f03a72..c7448a2 100644
@@ -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) {
Signature · 1 line
1.7.11.7
#12 lore raw

PATCH 5/24 qdev: split up header so it can be used in cpu.h

In reply to Eduardo Habkost

From: Anthony Liguori <[email protected]>

Header file dependency is a frickin' nightmare right now. cpu.h tends to get included in our 'include everything' header files but qdev also needs to include those headers mainly for qdev-properties since it knows about CharDriverState and friends.

We can solve this for now by splitting out qdev.h along the same lines that we previously split the C file. Then cpu.h just needs to include qdev-core.h

hw/qdev.h is split into following new headers:
hw/qdev-core.h
hw/qdev-properties.h
hw/qdev-monitor.h

[ehabkost: re-add DEFINE_PROP_PCI_HOST_DEVADDR, that was removed on the
original patch (by mistake, I guess)]
[ehabkost: kill qdev_prop_set_vlan() declaration]
[ehabkost: moved get_fw_dev_path() comment to the original location
(I don't know why it was moved)]
[ehabkost: removed qdev_exists() declaration]
[ehabkost: keep using 'QemuOpts' instead of 'struct QemuOpts', as
qdev-core.h includes qemu-option.h]

---
Yes, there is "changelog" data before the "---" mark, but I believe that in this case they are important to indicate authorship and the scope of the Signed-off-by lines (so they need to get into the git commit message)

Detailed changelog:

Changes v1 (from Anthony) -> v2 (from Eduardo):
- re-add DEFINE_PROP_PCI_HOST_DEVADDR, that was removed on the original patch (by mistake, I guess)
- kill qdev_prop_set_vlan() declaration

Changes v2 -> v3 (from Eduardo):
- moved get_fw_dev_path() comment to the original location (I don't know why it was moved)
- removed qdev_exists() declaration
- keep using 'QemuOpts' instead of 'struct QemuOpts', as qdev-core.h includes qemu-option.h

Changes v3 -> v4 (from Eduardo):
- Edited commit message to include additional information about the specific files being created

---
 hw/mc146818rtc.c     |   1 +
 hw/qdev-addr.c       |   1 +
 hw/qdev-core.h       | 238 +++++++++++++++++++++++++++++++++
 hw/qdev-monitor.h    |  16 +++
 hw/qdev-properties.c |   1 +
 hw/qdev-properties.h | 130 ++++++++++++++++++
 hw/qdev.c            |   1 +
 hw/qdev.h            | 370 +--------------------------------------------------
 8 files changed, 392 insertions(+), 366 deletions(-)
 create mode 100644 hw/qdev-core.h
 create mode 100644 hw/qdev-monitor.h
 create mode 100644 hw/qdev-properties.h
hw/mc146818rtc.c +1 -0
index 98839f2..7d84ce3 100644
@@ -25,6 +25,7 @@
 #include "qemu-timer.h"
 #include "sysemu.h"
 #include "mc146818rtc.h"
+#include "qapi/qapi-visit-core.h"
 
 #ifdef TARGET_I386
 #include "apic.h"
hw/qdev-addr.c +1 -0
index de0ba87..ea32c31 100644
@@ -1,6 +1,7 @@
 #include "qdev.h"
 #include "qdev-addr.h"
 #include "hwaddr.h"
+#include "qapi/qapi-visit-core.h"
 
 /* --- target physical address --- */
 
hw/qdev-core.h new file +238 -0

238 lines not on this page · raw message

hw/qdev-monitor.h new file +16 -0
new file mode 100644
index 0000000..220ceba
@@ -0,0 +1,16 @@
+#ifndef QEMU_QDEV_MONITOR_H
+#define QEMU_QDEV_MONITOR_H
+
+#include "qdev-core.h"
+#include "monitor.h"
+
+/*** monitor commands ***/
+
+void do_info_qtree(Monitor *mon);
+void do_info_qdm(Monitor *mon);
+int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
+int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
+int qdev_device_help(QemuOpts *opts);
+DeviceState *qdev_device_add(QemuOpts *opts);
+
+#endif
hw/qdev-properties.c +1 -0
index 8aca0d4..81d901c 100644
@@ -4,6 +4,7 @@
 #include "blockdev.h"
 #include "hw/block-common.h"
 #include "net/hub.h"
+#include "qapi/qapi-visit-core.h"
 
 void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
 {
hw/qdev-properties.h new file +130 -0

130 lines not on this page · raw message

hw/qdev.c +1 -0
index 9b9aba3..7ddcd24 100644
@@ -29,6 +29,7 @@
 #include "qdev.h"
 #include "sysemu.h"
 #include "error.h"
+#include "qapi/qapi-visit-core.h"
 
 int qdev_hotplug = 0;
 static bool qdev_hot_added = false;
hw/qdev.h +4 -366

375 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#21 lore raw

PATCH 8/24 vnc-palette.h: include <stdbool.h>

In reply to Eduardo Habkost

<stdbool.h> is needed for the 'bool' type, used in the header.

The header is probably being included by accident because some other headers are including qemu-common.h, but those headers should eventually stop including qemu-common.h.

---
 ui/vnc-palette.h | 1 +
 1 file changed, 1 insertion(+)
ui/vnc-palette.h +1 -0
index 3260885..b82dc5d 100644
@@ -32,6 +32,7 @@
 #include "qlist.h"
 #include "qemu-queue.h"
 #include <stdint.h>
+#include <stdbool.h>
 
 #define VNC_PALETTE_HASH_SIZE 256
 #define VNC_PALETTE_MAX_SIZE  256
Signature · 1 line
1.7.11.7
#23 lore raw

PATCH 9/24 ui/vnc-pallete.c: include headers it needs

In reply to Eduardo Habkost

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.

---
 ui/vnc-palette.c | 2 ++
 1 file changed, 2 insertions(+)
ui/vnc-palette.c +2 -0
index 63d5f64..c130dee 100644
@@ -27,6 +27,8 @@
  */
 
 #include "vnc-palette.h"
+#include <glib.h>
+#include <string.h>
 
 static VncPaletteEntry *palette_find(const VncPalette *palette,
                                      uint32_t color, unsigned int hash)
Signature · 1 line
1.7.11.7
#24 lore raw

Re: [Qemu-devel] [PATCH 09/24] ui/vnc-pallete.c: include headers it needs

Quoted 7 lines · Eduardo Habkost

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.

Typo in subject: should be 'palette'.

-- PMM

Acked-by on v1 1/24
#2 lore raw

Re: [Qemu-devel] [PATCH 01/24] user: move *-user/qemu-types.h to main directory

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 7 lines

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.

A quick diff -u confirms that this is (still) the case. I had suggested unifying these files long time ago when I tried fixing darwin-user, but hit resistance in favor of having the *-users separate. I'm still in favor of not duplicating identical code, so

Riku, do you agree?

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Acked-by on v1 2/24
#5 lore raw

Re: [Qemu-devel] [PATCH 02/24] user: rename qemu-types.h to qemu-user-types.h

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 4 lines

The header file is specific for *-user, but I plan to introduce a more generic qemu-types.h file, so I'm renaming it.

linux-user builds okay and the bsd-user change looks fine, too. git-grep shows no more occurrences of qemu-types.h.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#7 lore raw

Re: [Qemu-devel] [PATCH 03/24] qemu-common.h: comment about usage rules

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 3 lines

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

"from other headers" as below?

Quoted 6 lines

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.

This reminds me that I had once posted a patch moving a declaration I had once added for Cocoa to a new ui/ui.h... seems it never made it to master, I'll go search, maybe we can smuggle that in now. ;)

Quoted 11 lines
---
 qemu-common.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
qemu-common.h +0 -0
index ac9985c..ea43bfa 100644

qemu-common.h line 2

Quoted 3 lines
qemu-common.h +1 -1
@@ -1,5 +1,14 @@
 
-/* Common header file that is included by all of qemu.  */
+/* Common header file that is included by all of qemu.

"QEMU", while at it.

qemu-common.h line 8

Quoted 6 lines
qemu-common.h +6 -0
+ *
+ * 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

"a header file"

qemu-common.h line 14

Quoted 6 lines
qemu-common.h +3 -0
+ * 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
 

I'll fix this up myself to spare you a resend and me another full review.

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#8 lore raw

Re: [Qemu-devel] [PATCH 03/24] qemu-common.h: comment about usage rules

Quoted 6 lines · Andreas Färber

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 3 lines

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

"from other headers" as below?

Both forms sounds equivalent, to my non-native-speaker ears. :-)

But I guess "including from other headers" is better.

Quoted 29 lines
Quoted 7 lines

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.

This reminds me that I had once posted a patch moving a declaration I had once added for Cocoa to a new ui/ui.h... seems it never made it to master, I'll go search, maybe we can smuggle that in now. ;)

Quoted 11 lines
---
 qemu-common.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
qemu-common.h +0 -0
index ac9985c..ea43bfa 100644

qemu-common.h line 2

Quoted 3 lines
qemu-common.h +1 -1
@@ -1,5 +1,14 @@
 
-/* Common header file that is included by all of qemu.  */
+/* Common header file that is included by all of qemu.

"QEMU", while at it.

Quoted 8 lines

qemu-common.h line 8

Quoted 6 lines
qemu-common.h +6 -0
+ *
+ * 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

"a header file"

Oops. Thanks.

Quoted 9 lines

qemu-common.h line 14

Quoted 7 lines
qemu-common.h +3 -0
+ * 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
 

I'll fix this up myself to spare you a resend and me another full review.

Thanks!

Quoted 8 lines

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Signature · 1 line
Eduardo
#16 lore raw

Re: [Qemu-devel] [PATCH 06/24] move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h)

In reply to Igor Mammedov
Quoted 70 lines · Igor Mammedov
Quoted 67 lines · On Fri, 9 Nov 2012 12:56:34 -0200 Eduardo Habkost <[email protected]> wrote:

This will help reduce the qemu-common.h dependency hell.

--
Changes v1 -> v2:
- move qemu_open() & qemu_close() to qemu-stdio.h, too

---
 qemu-common.h | 59 ++--------------------------------------------
 qemu-stdio.h  | 76

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 57 deletions(-) create mode 100644 qemu-stdio.h

qemu-common.h +2 -0
index 6441bee..5080382 100644
@@ -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

qemu-common.h +0 -31
@@ -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.
- */
Quoted 8 lines

qemu-common.h typedef struct MigrationParams MigrationParams; · line 107

Quoted 7 lines
qemu-common.h +0 -7
-#define IOV_MAX		1024
-#else
-#include <sys/uio.h>
-#endif
-
-typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
-    GCC_FMT_ATTR(2, 3);

Is there any particular reason to move fprintf_function from qemu-common.h?

Yes: the reason is that qemu-common.h should die. ;-)

Long explanation:
1) qemu-common.h has too much stuff inside it;
2) Due to (1), having headers that include qemu-common.h easily lead to circular header dependencies;
3) Due to (2), header files should not include qemu-common.h;
4) Headers that use fprintf_function can't make sure fprintf_function is defined, because of (3).

Quoted 23 lines
Quoted 23 lines
qemu-common.h +0 -17
-
-#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);
 
Quoted 8 lines

qemu-common.h const char *path(const char *pathname); · line 169

Quoted 7 lines
qemu-common.h +0 -2
 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)

2 above funcs could be moved along with qemu_open() to osdep.h

I would happily move them, if somebody gave me an one-line description of what's the purpose of osdep.h (so I know what is supposed to be there, and what's not supposed to be there).

Quoted 77 lines
Quoted 77 lines
qemu-stdio.h new file +70 -0
new file mode 100644
index 0000000..b2e8eda
@@ -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;
+}
Quoted 8 lines

qemu-stdio.h line 74

Quoted 4 lines
qemu-stdio.h new file +4 -0
+#endif
+
+int qemu_open(const char *name, int flags, ...);
+int qemu_close(int fd);

qemu_open() and qemu_close() are defined in osdep.c so perhaps it would be better to move their declaration to osdep.h.
The rest looks like it fits a purpose of osdep.h as well, so probably it could be moved there and we could avoid creating a new header.

Maybe, but I really would like to have a good description of what's the meaning/purpose of osdep.h, first. osdep.h seems to have lots of unrelated stuff inside it, already, and I don't want to risk making osdep.h become a new catchall header file, like qemu-common.h is today.

Quoted 4 lines
Quoted 3 lines
qemu-stdio.h new file +2 -0
+
+#endif /* QEMU_STDIO_H */
Signature · 1 line
Eduardo
#15 lore raw

Re: [Qemu-devel] [PATCH 06/24] move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h)

In reply to Eduardo Habkost
Quoted 64 lines · On Fri, 9 Nov 2012 12:56:34 -0200 Eduardo Habkost <[email protected]> wrote:

This will help reduce the qemu-common.h dependency hell.

--
Changes v1 -> v2:
- move qemu_open() & qemu_close() to qemu-stdio.h, too

---
 qemu-common.h | 59 ++--------------------------------------------
 qemu-stdio.h  | 76

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 57 deletions(-) create mode 100644 qemu-stdio.h

qemu-common.h +2 -0
index 6441bee..5080382 100644
@@ -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

qemu-common.h +0 -28
@@ -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;
-};

qemu-common.h typedef struct MigrationParams MigrationParams; · line 107

Quoted 10 lines
qemu-common.h +0 -10
-/*
- * 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);

Is there any particular reason to move fprintf_function from qemu-common.h?

Quoted 21 lines
qemu-common.h +0 -17
-
-#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);

qemu-common.h const char *path(const char *pathname); · line 169

Quoted 8 lines
qemu-common.h +0 -2
@@ -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)

2 above funcs could be moved along with qemu_open() to osdep.h

Quoted 70 lines
qemu-stdio.h new file +64 -0
new file mode 100644
index 0000000..b2e8eda
@@ -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

qemu-stdio.h line 74

Quoted 10 lines
qemu-stdio.h new file +10 -0
+
+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);

qemu_open() and qemu_close() are defined in osdep.c so perhaps it would be better to move their declaration to osdep.h.
The rest looks like it fits a purpose of osdep.h as well, so probably it could be moved there and we could avoid creating a new header.

Quoted 2 lines
qemu-stdio.h new file +2 -0
+
+#endif /* QEMU_STDIO_H */
#17 lore raw

Re: [Qemu-devel] [PATCH 06/24] move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h)

In reply to Eduardo Habkost
Quoted 84 lines · On Tue, 13 Nov 2012 13:52:16 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 72 lines · Igor Mammedov
Quoted 69 lines · On Fri, 9 Nov 2012 12:56:34 -0200 Eduardo Habkost <[email protected]> wrote:

This will help reduce the qemu-common.h dependency hell.

--
Changes v1 -> v2:
- move qemu_open() & qemu_close() to qemu-stdio.h, too

---
 qemu-common.h | 59 ++--------------------------------------------
 qemu-stdio.h  | 76

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 57 deletions(-) create mode 100644 qemu-stdio.h

qemu-common.h +2 -0
index 6441bee..5080382 100644
@@ -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

qemu-common.h +0 -32
@@ -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
Quoted 8 lines

qemu-common.h typedef struct MigrationParams MigrationParams; · line 107

Quoted 6 lines
qemu-common.h +0 -6
-#else
-#include <sys/uio.h>
-#endif
-
-typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
-    GCC_FMT_ATTR(2, 3);

Is there any particular reason to move fprintf_function from qemu-common.h?

Yes: the reason is that qemu-common.h should die. ;-)

Quoted 7 lines

Long explanation:
1) qemu-common.h has too much stuff inside it;
2) Due to (1), having headers that include qemu-common.h easily lead to circular header dependencies;
3) Due to (2), header files should not include qemu-common.h;
4) Headers that use fprintf_function can't make sure fprintf_function is defined, because of (3).

Strictly speaking this movement is not related/required for this series to work, it compiles without it.
But if there is no complaints it's fine by me.

Quoted 34 lines
Quoted 26 lines
Quoted 26 lines
qemu-common.h +0 -17
-
-#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);
 
Quoted 7 lines
Quoted 6 lines
qemu-common.h +0 -2
-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)

2 above funcs could be moved along with qemu_open() to osdep.h

Quoted 3 lines

I would happily move them, if somebody gave me an one-line description of what's the purpose of osdep.h (so I know what is supposed to be there, and what's not supposed to be there).

they are defined in osdep.c, it's logical to have declarations in osdep.h

Quoted 87 lines
Quoted 78 lines
Quoted 78 lines
qemu-stdio.h new file +70 -0
new file mode 100644
index 0000000..b2e8eda
@@ -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;
+}
Quoted 8 lines

qemu-stdio.h line 74

Quoted 4 lines
qemu-stdio.h new file +4 -0
+#endif
+
+int qemu_open(const char *name, int flags, ...);
+int qemu_close(int fd);

qemu_open() and qemu_close() are defined in osdep.c so perhaps it would be better to move their declaration to osdep.h.
The rest looks like it fits a purpose of osdep.h as well, so probably it could be moved there and we could avoid creating a new header.

Quoted 2 lines

Maybe, but I really would like to have a good description of what's the meaning/purpose of osdep.h, first. osdep.h seems to have lots of

Judging from commit logs its purpose is in abstracting/unifying OS depended features to some common denominator. And the code you are moving is exactly does this.

Quoted 3 lines

unrelated stuff inside it, already, and I don't want to risk making osdep.h become a new catchall header file, like qemu-common.h is today.

So far osdep.h is pretty simple in terms of header dependences and doesn't include catch-all headers, moving this declarations and defines there doesn't complicate it in this aspect.

Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
qemu-stdio.h new file +2 -0
+
+#endif /* QEMU_STDIO_H */
#18 lore raw

Re: [Qemu-devel] [PATCH 06/24] move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h)

Quoted 94 lines · Igor Mammedov
Quoted 84 lines · On Tue, 13 Nov 2012 13:52:16 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 72 lines · Igor Mammedov
Quoted 69 lines · On Fri, 9 Nov 2012 12:56:34 -0200 Eduardo Habkost <[email protected]> wrote:

This will help reduce the qemu-common.h dependency hell.

--
Changes v1 -> v2:
- move qemu_open() & qemu_close() to qemu-stdio.h, too

---
 qemu-common.h | 59 ++--------------------------------------------
 qemu-stdio.h  | 76

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 57 deletions(-) create mode 100644 qemu-stdio.h

qemu-common.h +2 -0
index 6441bee..5080382 100644
@@ -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

qemu-common.h +0 -32
@@ -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
Quoted 8 lines

qemu-common.h typedef struct MigrationParams MigrationParams; · line 107

Quoted 6 lines
qemu-common.h +0 -6
-#else
-#include <sys/uio.h>
-#endif
-
-typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
-    GCC_FMT_ATTR(2, 3);

Is there any particular reason to move fprintf_function from qemu-common.h?

Yes: the reason is that qemu-common.h should die. ;-)

Quoted 7 lines

Long explanation:
1) qemu-common.h has too much stuff inside it;
2) Due to (1), having headers that include qemu-common.h easily lead to circular header dependencies;
3) Due to (2), header files should not include qemu-common.h;
4) Headers that use fprintf_function can't make sure fprintf_function is defined, because of (3).

Quoted 2 lines

Strictly speaking this movement is not related/required for this series to work, it compiles without it.

I think it was necessary when we were adding a new '#include "cpu.h"' line somewhere, on previous versions of the series, but it may be not necessary anymore.

Quoted 1 line

But if there is no complaints it's fine by me.

If the code compiles fine without the patch, I'm OK with dropping it by now. Then I can send a new version later that moves that code to osdep.h.

Quoted 133 lines
Quoted 35 lines
Quoted 27 lines
Quoted 27 lines
qemu-common.h +0 -17
-
-#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);
 
Quoted 7 lines
Quoted 6 lines
qemu-common.h +0 -2
-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)

2 above funcs could be moved along with qemu_open() to osdep.h

Quoted 3 lines

I would happily move them, if somebody gave me an one-line description of what's the purpose of osdep.h (so I know what is supposed to be there, and what's not supposed to be there).

they are defined in osdep.c, it's logical to have declarations in osdep.h

Quoted 87 lines
Quoted 78 lines
Quoted 78 lines
qemu-stdio.h new file +70 -0
new file mode 100644
index 0000000..b2e8eda
@@ -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;
+}
Quoted 8 lines

qemu-stdio.h line 74

Quoted 4 lines
qemu-stdio.h new file +4 -0
+#endif
+
+int qemu_open(const char *name, int flags, ...);
+int qemu_close(int fd);

qemu_open() and qemu_close() are defined in osdep.c so perhaps it would be better to move their declaration to osdep.h.
The rest looks like it fits a purpose of osdep.h as well, so probably it could be moved there and we could avoid creating a new header.

Quoted 2 lines

Maybe, but I really would like to have a good description of what's the meaning/purpose of osdep.h, first. osdep.h seems to have lots of

Judging from commit logs its purpose is in abstracting/unifying OS depended features to some common denominator. And the code you are moving is exactly does this.

Quoted 6 lines
Quoted 3 lines

unrelated stuff inside it, already, and I don't want to risk making osdep.h become a new catchall header file, like qemu-common.h is today.

So far osdep.h is pretty simple in terms of header dependences and doesn't include catch-all headers, moving this declarations and defines there doesn't complicate it in this aspect.

Sounds good to me. I guess the description you put above makes sure osdep.h won't start including every single header out there, like qemu-common.h does.

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
qemu-stdio.h new file +2 -0
+
+#endif /* QEMU_STDIO_H */
Signature · 1 line
Eduardo
Acked-by on v1 4/24
#10 lore raw

Re: [Qemu-devel] [PATCH 04/24] move qemu_irq typedef out of cpu-common.h

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 8 lines

From: Igor Mammedov <[email protected]>

it's necessary for making CPU child of DEVICE without causing circular header deps.

[ehabkost: re-added the typedef to hw/irq.h after rebasing]

but obviously qemu-common.h. ;)

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#11 lore raw

Re: [Qemu-devel] [PATCH 04/24] move qemu_irq typedef out of cpu-common.h

Quoted 11 lines · Andreas Färber

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 8 lines

From: Igor Mammedov <[email protected]>

it's necessary for making CPU child of DEVICE without causing circular header deps.

[ehabkost: re-added the typedef to hw/irq.h after rebasing]

Thanks!

Quoted 2 lines

but obviously qemu-common.h. ;)

Not the first commit message error in this series. I need to pay more attention to my commit messages. :-)

Signature · 1 line
Eduardo
Acked-by on v1 5/24
#13 lore raw

Re: [Qemu-devel] [PATCH 05/24] qdev: split up header so it can be used in cpu.h

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 26 lines

From: Anthony Liguori <[email protected]>

Header file dependency is a frickin' nightmare right now. cpu.h tends to get included in our 'include everything' header files but qdev also needs to include those headers mainly for qdev-properties since it knows about CharDriverState and friends.

We can solve this for now by splitting out qdev.h along the same lines that we previously split the C file. Then cpu.h just needs to include qdev-core.h

hw/qdev.h is split into following new headers:
hw/qdev-core.h
hw/qdev-properties.h
hw/qdev-monitor.h

[ehabkost: re-add DEFINE_PROP_PCI_HOST_DEVADDR, that was removed on the
original patch (by mistake, I guess)]
[ehabkost: kill qdev_prop_set_vlan() declaration]
[ehabkost: moved get_fw_dev_path() comment to the original location
(I don't know why it was moved)]
[ehabkost: removed qdev_exists() declaration]
[ehabkost: keep using 'QemuOpts' instead of 'struct QemuOpts', as
qdev-core.h includes qemu-option.h]

Quoted 1 line

Yay, I made it through this patch line by line! Perfect now,

Thanks,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Acked-by on v1 7/24
#20 lore raw

Re: [Qemu-devel] [PATCH 07/24] qemu-fsdev-dummy.c: include module.h

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 8 lines

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.

I'm surprised about this machine_init() use case outside a machine though...

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Acked-by on v1 8/24
#22 lore raw

Re: [Qemu-devel] [PATCH 08/24] vnc-palette.h: include <stdbool.h>

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 7 lines

<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.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Acked-by on v1 9/24
#25 lore raw

Re: [Qemu-devel] [PATCH 09/24] ui/vnc-pallete.c: include headers it needs

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 9 lines

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.

Subject fixed.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Acked-by on v1 10/24
#27 lore raw

Re: [Qemu-devel] [PATCH 10/24] qemu-config.h: include headers it needs

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 9 lines

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.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Acked-by on v1 11/24
#29 lore raw

Re: [Qemu-devel] [PATCH 11/24] qapi/qmp-registry.c: include headers it needs

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 9 lines

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.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#31 lore raw

Re: [Qemu-devel] [PATCH 12/24] qga/channel-posix.c: include headers it needs

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 19 lines

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.

---
 qga/channel-posix.c | 4 ++++
 1 file changed, 4 insertions(+)
qga/channel-posix.c +0 -0
index d152827..2a68451 100644

qga/channel-posix.c line 9

Quoted 9 lines
qga/channel-posix.c +4 -0
@@ -1,5 +1,9 @@
 #include <glib.h>
 #include <termios.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "qemu-stdio.h"
 #include "qemu_socket.h"
 #include "qga/channel.h"
 

Since the qemu-stdio.h patch was under debate, I've posted a patch moving qemu_open() and its companion qemu_close() to osdep.h as suggested by Igor - uses osdep.h here works fine then. Rest looks good.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#58 lore raw

PATCH v5 22/24 qdev-properties.c: separate core from the code used only by qemu-system-*

In reply to Eduardo Habkost

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.

[imammedo: keep qdev_get_child_bus() in hw/qdev.c]
[imammedo: put qdev_set_nic_properties() in hw/qdev-properties-system.c]

[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]

---
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

Changes v4 -> v5 (ehabkost):
- Remove large copyright header and instead just point to the original file it was based on

---
 hw/Makefile.objs            |   1 +
 hw/qdev-properties-system.c | 352 ++++++++++++++++++++++++++++++++++++++++++++
 hw/qdev-properties.c        | 321 +---------------------------------------
 hw/qdev-properties.h        |   1 +
 hw/qdev.c                   |  13 --
 5 files changed, 355 insertions(+), 333 deletions(-)
 create mode 100644 hw/qdev-properties-system.c
hw/Makefile.objs +1 -0
index af4ab0c..4833b90 100644
@@ -182,6 +182,7 @@ common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += msmouse.o ps2.o
 common-obj-y += qdev.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-properties-system.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 
 # xen backend driver support
hw/qdev-properties-system.c new file +352 -0

352 lines not on this page · raw message

hw/qdev-properties.c +1 -320

348 lines not on this page · raw message

hw/qdev-properties.h +1 -0
index 5b046ab..ddcf774 100644
@@ -116,6 +116,7 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 /* FIXME: Remove opaque pointer properties.  */
 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
 
+void qdev_prop_register_global(GlobalProperty *prop);
 void qdev_prop_register_global_list(GlobalProperty *props);
 void qdev_prop_set_globals(DeviceState *dev);
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
hw/qdev.c +0 -13
index 0702659..f00c029 100644
@@ -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"
@@ -390,18 +389,6 @@ void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin)
     dev->gpio_out[n] = pin;
 }
 
-void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
-{
-    qdev_prop_set_macaddr(dev, "mac", nd->macaddr.a);
-    if (nd->netdev)
-        qdev_prop_set_netdev(dev, "netdev", nd->netdev);
-    if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&
-        object_property_find(OBJECT(dev), "vectors", NULL)) {
-        qdev_prop_set_uint32(dev, "vectors", nd->nvectors);
-    }
-    nd->instantiated = 1;
-}
-
 BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
 {
     BusState *bus;
Signature · 1 line
1.7.11.7
Acked-by on v1 13/24
#33 lore raw

Re: [Qemu-devel] [PATCH 13/24] create qemu-types.h for struct typedefs

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 4 lines

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.

Quoted 8 lines

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.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#35 lore raw

Re: [Qemu-devel] [PATCH 14/24] sysemu.h: include qemu-types.h instead of qemu-common.h

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 13 lines

It just needs the Monitor and DeviceState typedefs, so it doesn't need all of qemu-common.h.

---
 sysemu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sysemu.h +0 -0
index f5ac664..ab1ef8b 100644

sysemu.h line 8

Quoted 8 lines
sysemu.h +1 -1
@@ -2,7 +2,7 @@
 #define SYSEMU_H
 /* Misc. things related to the system emulator.  */
 
-#include "qemu-common.h"
+#include "qemu-types.h"
 #include "qemu-option.h"
 #include "qemu-queue.h"
 #include "qemu-timer.h"

CC i386-softmmu/hw/i386/../kvmvapic.o
In file included from /home/andreas/QEMU/qemu-rcar/target-i386/cpu.h:839:0,

                 from /home/andreas/QEMU/qemu-rcar/qemu-common.h:130,
                 from ../qapi-types.h:19,
                 from /home/andreas/QEMU/qemu-rcar/error.h:16,
                 from /home/andreas/QEMU/qemu-rcar/qemu-option.h:31,
                 from /home/andreas/QEMU/qemu-rcar/sysemu.h:6,
                 from /home/andreas/QEMU/qemu-rcar/hw/i386/../kvmvapic.c:11:

/home/andreas/QEMU/qemu-rcar/target-i386/cpu-qom.h:76:35: error: unknown type name ‘Error’
make[1]: *** [hw/i386/../kvmvapic.o] Fehler 1
make: *** [subdir-i386-softmmu] Fehler 2

Probably "error.h" needed, too.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Acked-by on v1 16/24
#42 lore raw

Re: [Qemu-devel] [PATCH 16/24] qapi-types.h: don't include qemu-common.h

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 7 lines

From: Igor Mammedov <[email protected]>

needed to prevent build breakage when CPU becomes a child of DeviceState

[ehabkost: include <stdbool.h> too]

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#36 lore raw

Re: [Qemu-devel] [PATCH 14/24] sysemu.h: include qemu-types.h instead of qemu-common.h

In reply to Andreas Färber

Am 14.11.2012 22:56, schrieb Andreas Färber:

Quoted 31 lines

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 13 lines

It just needs the Monitor and DeviceState typedefs, so it doesn't need all of qemu-common.h.

---
 sysemu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sysemu.h +0 -0
index f5ac664..ab1ef8b 100644

sysemu.h line 8

Quoted 8 lines
sysemu.h +1 -1
@@ -2,7 +2,7 @@
 #define SYSEMU_H
 /* Misc. things related to the system emulator.  */
 
-#include "qemu-common.h"
+#include "qemu-types.h"
 #include "qemu-option.h"
 #include "qemu-queue.h"
 #include "qemu-timer.h"

CC i386-softmmu/hw/i386/../kvmvapic.o
In file included from /home/andreas/QEMU/qemu-rcar/target-i386/cpu.h:839:0,

                 from /home/andreas/QEMU/qemu-rcar/qemu-common.h:130,
                 from ../qapi-types.h:19,
                 from /home/andreas/QEMU/qemu-rcar/error.h:16,
                 from /home/andreas/QEMU/qemu-rcar/qemu-option.h:31,
                 from /home/andreas/QEMU/qemu-rcar/sysemu.h:6,
                 from /home/andreas/QEMU/qemu-rcar/hw/i386/../kvmvapic.c:11:
Quoted 6 lines

/home/andreas/QEMU/qemu-rcar/target-i386/cpu-qom.h:76:35: error: unknown type name ‘Error’
make[1]: *** [hw/i386/../kvmvapic.o] Fehler 1
make: *** [subdir-i386-softmmu] Fehler 2

Probably "error.h" needed, too.

Scratch that last part. There's a cyclic inclusion of qemu-common.h, solved by the qapi-types.h patch 16/24. Reordering solves this issue. Given that,

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#38 lore raw

Re: [Qemu-devel] [PATCH 15/24] qlist.h: do not include qemu-common.h

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 13 lines

I don't know why it was including it, as I don't see any code that depends on anything from qemu-common.h.

---
 qlist.h | 1 -
 1 file changed, 1 deletion(-)
qlist.h +0 -0
index ae776f9..7408947 100644

qlist.h line 20

Quoted 7 lines
qlist.h +0 -1
@@ -15,7 +15,6 @@
 
 #include "qobject.h"
 #include "qemu-queue.h"
-#include "qemu-common.h"
 #include "qemu-queue.h"
 
 typedef struct QListEntry {

CC qga/channel-posix.o
/home/andreas/QEMU/qemu-rcar/qga/channel-posix.c: In function ‘ga_channel_open’:
/home/andreas/QEMU/qemu-rcar/qga/channel-posix.c:141:13: error: implicit declaration of function ‘exit’ [-Werror=implicit-function-declaration] /home/andreas/QEMU/qemu-rcar/qga/channel-posix.c:141:13: error:
incompatible implicit declaration of built-in function ‘exit’ [-Werror] /home/andreas/QEMU/qemu-rcar/qga/channel-posix.c:141:18: error:
‘EXIT_FAILURE’ undeclared (first use in this function) /home/andreas/QEMU/qemu-rcar/qga/channel-posix.c:141:18: note: each undeclared identifier is reported only once for each function it appears in /home/andreas/QEMU/qemu-rcar/qga/channel-posix.c:163:13: error:
incompatible implicit declaration of built-in function ‘exit’ [-Werror]
cc1: all warnings being treated as errors
make: *** [qga/channel-posix.o] Fehler 1

Sounds related to not doing qemu-stdio.h...

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#39 lore raw

PATCH v2 1/1 qga/channel-posix.c: include headers it needs

From: Eduardo Habkost <[email protected]>

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.

---
v2
- include qemu-common.h for EXIT_FAILURE, exit and qemu_open definitions

---
 qga/channel-posix.c | 4 ++++
 1 file changed, 4 insertions(+)
qga/channel-posix.c +4 -0
index d152827..bbbbcc9 100644
@@ -1,7 +1,11 @@
 #include <glib.h>
 #include <termios.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
 #include "qemu_socket.h"
 #include "qga/channel.h"
+#include "qemu-common.h"
 
 #ifdef CONFIG_SOLARIS
 #include <stropts.h>
Signature · 1 line
1.7.11.7
#47 lore raw

Re: [Qemu-devel] [PATCH 19/24] qdev: move reset handler list from vl.c to qdev.c

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 88 lines

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().

---
 hw/hw.h         |  6 +-----
 hw/qdev-reset.h | 11 +++++++++++
 hw/qdev.c       | 41 +++++++++++++++++++++++++++++++++++++++++
 hw/qdev.h       |  1 +
 sysemu.h        |  1 -
 vl.c            | 40 ----------------------------------------
 6 files changed, 54 insertions(+), 46 deletions(-)
 create mode 100644 hw/qdev-reset.h
hw/hw.h +1 -5
index f530f6f..622a157 100644
@@ -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);
hw/qdev-reset.h new file +11 -0
new file mode 100644
index 0000000..40ae9a5
@@ -0,0 +1,11 @@
+/* Device reset handler function registration, used by qdev */
+#ifndef QDEV_RESET_H
+#define QDEV_RESET_H
+
+typedef void QEMUResetHandler(void *opaque);
+
+void qemu_register_reset(QEMUResetHandler *func, void *opaque);
+void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
+void qemu_devices_reset(void);
+
+#endif /* QDEV_RESET_H */
hw/qdev.c +20 -0
index 2cc6434..c242097 100644
@@ -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)
+{

hw/qdev.c int qdev_hotplug = 0; · line 67

Quoted 10 lines
hw/qdev.c +10 -0
+    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;
+        }
+    }
+}

My tired mind does not like this move and the naming qdev-reset.h. The reset handling infrastructure is not limited to DeviceState (qdev), it takes an opaque and is limited to softmmu whereas qdev prefers its own DeviceClass::reset hook.

Andreas

Quoted 96 lines
hw/qdev.c +11 -0
+
+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);
hw/qdev.h +1 -0
index 365b8d6..2487b3b 100644
@@ -5,5 +5,6 @@
 #include "qdev-core.h"
 #include "qdev-properties.h"
 #include "qdev-monitor.h"
+#include "qdev-reset.h"
 
 #endif
sysemu.h +0 -1
index ab1ef8b..51f19cc 100644
@@ -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);
vl.c +0 -40
index 4f03a72..c7448a2 100644
@@ -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) {
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#40 lore raw

Re: [Qemu-devel] [PATCH v2] qga/channel-posix.c: include headers it needs

In reply to Igor Mammedov
Quoted 11 lines · Igor Mammedov

From: Eduardo Habkost <[email protected]>

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.

Quoted 5 lines

---
v2
- include qemu-common.h for EXIT_FAILURE, exit and qemu_open definitions

Thanks! The commit message above needs to be edited, too. :-)

Quoted 23 lines
---
 qga/channel-posix.c | 4 ++++
 1 file changed, 4 insertions(+)
qga/channel-posix.c +4 -0
index d152827..bbbbcc9 100644
@@ -1,7 +1,11 @@
 #include <glib.h>
 #include <termios.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
 #include "qemu_socket.h"
 #include "qga/channel.h"
+#include "qemu-common.h"
 
 #ifdef CONFIG_SOLARIS
 #include <stropts.h>
Signature · 1 line
1.7.11.7
Signature · 1 line
Eduardo
#48 lore raw

Re: [Qemu-devel] [PATCH 19/24] qdev: move reset handler list from vl.c to qdev.c

In reply to Andreas Färber
Quoted 96 lines · Andreas Färber

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 95 lines

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().

---
 hw/hw.h         |  6 +-----
 hw/qdev-reset.h | 11 +++++++++++
 hw/qdev.c       | 41 +++++++++++++++++++++++++++++++++++++++++
 hw/qdev.h       |  1 +
 sysemu.h        |  1 -
 vl.c            | 40 ----------------------------------------
 6 files changed, 54 insertions(+), 46 deletions(-)
 create mode 100644 hw/qdev-reset.h
hw/hw.h +1 -5
index f530f6f..622a157 100644
@@ -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);
hw/qdev-reset.h new file +11 -0
new file mode 100644
index 0000000..40ae9a5
@@ -0,0 +1,11 @@
+/* Device reset handler function registration, used by qdev */
+#ifndef QDEV_RESET_H
+#define QDEV_RESET_H
+
+typedef void QEMUResetHandler(void *opaque);
+
+void qemu_register_reset(QEMUResetHandler *func, void *opaque);
+void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
+void qemu_devices_reset(void);
+
+#endif /* QDEV_RESET_H */
hw/qdev.c +27 -0
index 2cc6434..c242097 100644
@@ -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;
Quoted 8 lines

hw/qdev.c int qdev_hotplug = 0; · line 66

Quoted 3 lines
hw/qdev.c +3 -0
+        }
+    }
+}

My tired mind does not like this move and the naming qdev-reset.h. The reset handling infrastructure is not limited to DeviceState (qdev), it takes an opaque and is limited to softmmu whereas qdev prefers its own DeviceClass::reset hook.

True, it isn't qdev-specific. But it doesn't belong to vl.c either. Should we create a reset.o file just for those few lines of code, or is there any obvious place where this code can go?

DeviceState CPUs have to be reset too, and DeviceState uses the reset-handler system to make sure DeviceState objects are reset, so it won't be softmmu-specific.

An alternative is to make empty stubs for qemu_[un]register_reset(), and not move the reset-handler system to *-user. But somehow I feel better having a working qemu_register_reset() function (and then adding a qemu_devices_reset() call to *-user) than having a fake qemu_register_reset() function and having to use a different API to reset the CPUs on on *-user.

Quoted 104 lines

Andreas

Quoted 96 lines
hw/qdev.c +11 -0
+
+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);
hw/qdev.h +1 -0
index 365b8d6..2487b3b 100644
@@ -5,5 +5,6 @@
 #include "qdev-core.h"
 #include "qdev-properties.h"
 #include "qdev-monitor.h"
+#include "qdev-reset.h"
 
 #endif
sysemu.h +0 -1
index ab1ef8b..51f19cc 100644
@@ -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);
vl.c +0 -40
index 4f03a72..c7448a2 100644
@@ -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) {
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Signature · 1 line
Eduardo
#49 lore raw

Re: [Qemu-devel] [PATCH 19/24] qdev: move reset handler list from vl.c to qdev.c

Quoted 10 lines · Eduardo Habkost

DeviceState CPUs have to be reset too, and DeviceState uses the reset-handler system to make sure DeviceState objects are reset, so it won't be softmmu-specific.

An alternative is to make empty stubs for qemu_[un]register_reset(), and not move the reset-handler system to *-user. But somehow I feel better having a working qemu_register_reset() function (and then adding a qemu_devices_reset() call to *-user) than having a fake qemu_register_reset() function and having to use a different API to reset the CPUs on on *-user.

cf the pretty nasty stuff in linux-user/main.c which currently calls cpu_reset() but only for some targets.

-- PMM

#3 lore raw

Re: [Qemu-devel] [PATCH 01/24] user: move *-user/qemu-types.h to main directory

In reply to Andreas Färber
Quoted 7 lines · Andreas Färber

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 6 lines

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.

Quoted 6 lines
Quoted 1 line

A quick diff -u confirms that this is (still) the case. I had suggested unifying these files long time ago when I tried fixing darwin-user, but hit resistance in favor of having the *-users separate. I'm still in favor of not duplicating identical code, so

The problem in general with merging user emulator code is that the changes may cause regressions since there are subtle differences. In this specific case it should be OK.

Quoted 10 lines

Riku, do you agree?

Andreas

--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

#50 lore raw

Re: [Qemu-devel] [PATCH 19/24] qdev: move reset handler list from vl.c to qdev.c

In reply to Eduardo Habkost
Quoted 114 lines · On Thu, 15 Nov 2012 16:42:41 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 96 lines · Andreas Färber

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 95 lines

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().

---
 hw/hw.h         |  6 +-----
 hw/qdev-reset.h | 11 +++++++++++
 hw/qdev.c       | 41 +++++++++++++++++++++++++++++++++++++++++
 hw/qdev.h       |  1 +
 sysemu.h        |  1 -
 vl.c            | 40 ----------------------------------------
 6 files changed, 54 insertions(+), 46 deletions(-)
 create mode 100644 hw/qdev-reset.h
hw/hw.h +1 -5
index f530f6f..622a157 100644
@@ -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);

hw/qdev-reset.h new file +11 -0
new file mode 100644
index 0000000..40ae9a5
@@ -0,0 +1,11 @@
+/* Device reset handler function registration, used by qdev */
+#ifndef QDEV_RESET_H
+#define QDEV_RESET_H
+
+typedef void QEMUResetHandler(void *opaque);
+
+void qemu_register_reset(QEMUResetHandler *func, void *opaque);
+void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
+void qemu_devices_reset(void);
+
+#endif /* QDEV_RESET_H */
hw/qdev.c +27 -0
index 2cc6434..c242097 100644
@@ -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;
Quoted 8 lines

hw/qdev.c int qdev_hotplug = 0; · line 66

Quoted 3 lines
hw/qdev.c +3 -0
+        }
+    }
+}

My tired mind does not like this move and the naming qdev-reset.h. The reset handling infrastructure is not limited to DeviceState (qdev), it takes an opaque and is limited to softmmu whereas qdev prefers its own DeviceClass::reset hook.

True, it isn't qdev-specific. But it doesn't belong to vl.c either. Should we create a reset.o file just for those few lines of code, or is there any obvious place where this code can go?

DeviceState CPUs have to be reset too, and DeviceState uses the reset-handler system to make sure DeviceState objects are reset, so it won't be softmmu-specific.

Quoted 6 lines

An alternative is to make empty stubs for qemu_[un]register_reset(), and not move the reset-handler system to *-user. But somehow I feel better having a working qemu_register_reset() function (and then adding a qemu_devices_reset() call to *-user) than having a fake qemu_register_reset() function and having to use a different API to reset the CPUs on on *-user.

There is no real need to add anything, *-user uses pretty much well defined cpu_reset() and doesn't need anything else to improve it.

PS:
reset-handler callbacks is not much loved thing in qemu, and people would like to get rid of it eventually. If one checks target-i386/cpu.c:

/* TODO: remove me, when reset over QOM tree is implemented */ static void x86_cpu_machine_reset_cb(void *opaque)

some day in far far (or maybe not far) future there won't be reset cb for x86-cpu.
Could you just leave reset-handler be a *-softmmu only part.

Quoted 106 lines
Quoted 105 lines

Andreas

Quoted 96 lines
hw/qdev.c +11 -0
+
+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);
hw/qdev.h +1 -0
index 365b8d6..2487b3b 100644
@@ -5,5 +5,6 @@
 #include "qdev-core.h"
 #include "qdev-properties.h"
 #include "qdev-monitor.h"
+#include "qdev-reset.h"
 
 #endif
sysemu.h +0 -1
index ab1ef8b..51f19cc 100644
@@ -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);
vl.c +0 -40
index 4f03a72..c7448a2 100644
@@ -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) {
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#51 lore raw

Re: [Qemu-devel] [PATCH 19/24] qdev: move reset handler list from vl.c to qdev.c

Quoted 117 lines · Igor Mammedov
Quoted 114 lines · On Thu, 15 Nov 2012 16:42:41 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 96 lines · Andreas Färber

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 95 lines

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().

---
 hw/hw.h         |  6 +-----
 hw/qdev-reset.h | 11 +++++++++++
 hw/qdev.c       | 41 +++++++++++++++++++++++++++++++++++++++++
 hw/qdev.h       |  1 +
 sysemu.h        |  1 -
 vl.c            | 40 ----------------------------------------
 6 files changed, 54 insertions(+), 46 deletions(-)
 create mode 100644 hw/qdev-reset.h
hw/hw.h +1 -5
index f530f6f..622a157 100644
@@ -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);

hw/qdev-reset.h new file +11 -0
new file mode 100644
index 0000000..40ae9a5
@@ -0,0 +1,11 @@
+/* Device reset handler function registration, used by qdev */
+#ifndef QDEV_RESET_H
+#define QDEV_RESET_H
+
+typedef void QEMUResetHandler(void *opaque);
+
+void qemu_register_reset(QEMUResetHandler *func, void *opaque);
+void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
+void qemu_devices_reset(void);
+
+#endif /* QDEV_RESET_H */
hw/qdev.c +27 -0
index 2cc6434..c242097 100644
@@ -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;
Quoted 8 lines

hw/qdev.c int qdev_hotplug = 0; · line 66

Quoted 3 lines
hw/qdev.c +3 -0
+        }
+    }
+}

My tired mind does not like this move and the naming qdev-reset.h. The reset handling infrastructure is not limited to DeviceState (qdev), it takes an opaque and is limited to softmmu whereas qdev prefers its own DeviceClass::reset hook.

True, it isn't qdev-specific. But it doesn't belong to vl.c either. Should we create a reset.o file just for those few lines of code, or is there any obvious place where this code can go?

DeviceState CPUs have to be reset too, and DeviceState uses the reset-handler system to make sure DeviceState objects are reset, so it won't be softmmu-specific.

Quoted 8 lines
Quoted 6 lines

An alternative is to make empty stubs for qemu_[un]register_reset(), and not move the reset-handler system to *-user. But somehow I feel better having a working qemu_register_reset() function (and then adding a qemu_devices_reset() call to *-user) than having a fake qemu_register_reset() function and having to use a different API to reset the CPUs on on *-user.

There is no real need to add anything, *-user uses pretty much well defined cpu_reset() and doesn't need anything else to improve it.

cpu_reset() is not that well-defined, otherwise we wouldn't have this on linux-user:

#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)
    cpu_reset(ENV_GET_CPU(env));

#endif

(I have no idea why we have that #ifdef).

But that can be fixed, eventually, and:

Quoted 11 lines

PS:
reset-handler callbacks is not much loved thing in qemu, and people would like to get rid of it eventually. If one checks target-i386/cpu.c:

/* TODO: remove me, when reset over QOM tree is implemented */ static void x86_cpu_machine_reset_cb(void *opaque)

some day in far far (or maybe not far) future there won't be reset cb for x86-cpu.
Could you just leave reset-handler be a *-softmmu only part.

I was considering this as well: even if cpu_reset() is not in great shape, qemu_register_reset() is something we would like to kill as well.

I sent a v8 DeviceState series including reset.o on *-user, already, but I will try removing it on a v9 series, next week.

Quoted 107 lines
Quoted 106 lines
Quoted 105 lines

Andreas

Quoted 96 lines
hw/qdev.c +11 -0
+
+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);
hw/qdev.h +1 -0
index 365b8d6..2487b3b 100644
@@ -5,5 +5,6 @@
 #include "qdev-core.h"
 #include "qdev-properties.h"
 #include "qdev-monitor.h"
+#include "qdev-reset.h"
 
 #endif
sysemu.h +0 -1
index ab1ef8b..51f19cc 100644
@@ -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);
vl.c +0 -40
index 4f03a72..c7448a2 100644
@@ -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) {
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Signature · 1 line
Eduardo
#52 lore raw

Re: [Qemu-devel] [PATCH 19/24] qdev: move reset handler list from vl.c to qdev.c

Quoted 8 lines · Eduardo Habkost

cpu_reset() is not that well-defined, otherwise we wouldn't have this on linux-user:

#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)
    cpu_reset(ENV_GET_CPU(env));

#endif

(I have no idea why we have that #ifdef).

I think this is because the different targets disagree about whether the CPU should be reset on initial construction or whether it needs a specific reset call. (The current setup with #ifdefs is among other things a historical effect as a result of various refactorings in the past; you can trace the git history if you're interested.)

-- PMM

#53 lore raw

Re: [Qemu-devel] [PATCH 19/24] qdev: move reset handler list from vl.c to qdev.c

Am 01.12.2012 12:26, schrieb Peter Maydell:

Quoted 8 lines · Eduardo Habkost
Quoted 7 lines

cpu_reset() is not that well-defined, otherwise we wouldn't have this on linux-user:

#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)
    cpu_reset(ENV_GET_CPU(env));

#endif

Quoted 7 lines
Quoted 1 line

(I have no idea why we have that #ifdef).

I think this is because the different targets disagree about whether the CPU should be reset on initial construction or whether it needs a specific reset call. (The current setup with #ifdefs is among other things a historical effect as a result of various refactorings in the past; you can trace the git history if you're interested.)

Peter and me had long IRC discussions about how to fix this in the past:

* On my qom-cpu-copy branch I have a patch queued that drops the #ifdef above, accepting that CPUs may get reset twice then. => Dispels doubt for target authors; doubts about correctness though.

* PMM suggested to move cpu_clone_regs() from target-*/cpu.h to *-user/. => Would lead to duplication between linux-user and bsd-user; ABI?

* PMM suggested to replace cpu_copy() with ABI-specific code in *-user/. Unfortunately I don't quite remember the details of how... ;)

The x86 APIC refactorings that Iguardo have done do bring us very close to sane cpu_reset() semantics (ignoring the two hands full of hard/soft/... reset variants that ppc and other architectures feature).

Declaring cpu_reset() inferior to reset handlers due to the linux-user mess is going into the wrong direction - some targets seem to ignore reset or fork/clone completely at the moment, so the state we see cannot be considered fully correct.
In particular the above reset is being performed *after* cpu_copy() memcpy()'ed random memory contents (which for some targets may contain pointers), undoing the copying in large parts. Therefore, when all targets reset as part of cpu_init() (or by moving the cpu_reset() call into early cpu_copy()?) we could get rid of it in do_fork() and of its weird conditions.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#54 lore raw

Re: [Qemu-devel] [PATCH 19/24] qdev: move reset handler list from vl.c to qdev.c

Quoted 17 lines · Andreas Färber

Am 01.12.2012 12:26, schrieb Peter Maydell:

Quoted 8 lines · Eduardo Habkost
Quoted 7 lines

cpu_reset() is not that well-defined, otherwise we wouldn't have this on linux-user:

#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)
    cpu_reset(ENV_GET_CPU(env));

#endif

Quoted 7 lines
Quoted 1 line

(I have no idea why we have that #ifdef).

I think this is because the different targets disagree about whether the CPU should be reset on initial construction or whether it needs a specific reset call. (The current setup with #ifdefs is among other things a historical effect as a result of various refactorings in the past; you can trace the git history if you're interested.)

Quoted 5 lines

Peter and me had long IRC discussions about how to fix this in the past:

* On my qom-cpu-copy branch I have a patch queued that drops the #ifdef above, accepting that CPUs may get reset twice then. => Dispels doubt for target authors; doubts about correctness though.

So on its own, this will break things, because the cpu_reset() happens after the cpu_copy, so we'll end up not in fact copying most of the registers across from the original thread. In fact this looks broken for i386/sparc/ppc at the moment, and is probably only working to the extent that user programs don't actually care about the register state across the clone() syscall. [and i386 threads are busted anyhow.] If we want to retain cpu_copy for the moment, the correct place for the cpu_reset() is in cpu_copy() itself, after the cpu_init but before the memcpy. [I see actually you mention this later in your email.]

Quoted 2 lines

* PMM suggested to move cpu_clone_regs() from target-*/cpu.h to *-user/. => Would lead to duplication between linux-user and bsd-user; ABI?

clone_regs should definitely be in *-user/, because it is in fact ABI dependent -- which register the 0 return value from the clone() syscall ends up in is up to the ABI. Also, there won't in fact be any duplication problem here because bsd-user doesn't implement threads and doesn't call cpu_clone_regs().

Quoted 2 lines

* PMM suggested to replace cpu_copy() with ABI-specific code in *-user/. Unfortunately I don't quite remember the details of how... ;)

I don't know that I got as far as the details, but the general idea is that the CPU state that needs to be propagated to the CPU in the new thread is only the user-space-facing bits, which *-user/ already needs to know about (and fish directly in CPUState for) to get things like signal handlers right. So rather than doing a huge memcpy of all the CPU's internal state, we just create and reset a CPU as normal, and then have the *-user/ code copy across those bits of register state which matter to userspace. I think this is much cleaner because it means the CPU emulation itself has a simple interface ("create cpu" and "reset cpu") and the details of copying thread state across are restricted to the user-mode code.

-- PMM

#45 lore raw

Re: [Qemu-devel] [PATCH 18/24] qdev: qdev_create(): use error_report() instead of hw_error()

In reply to Eduardo Habkost

Am 09.11.2012 15:56, schrieb Eduardo Habkost:

Quoted 10 lines

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).

Thanks, applied to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg