Skip to contentSkip to conversation

qemu-common.h header cleanups

PATCH Applied Eduardo Habkost 3 participants 13 messages Nov 22, 2012 – Dec 4, 2012

lore
Share & tools
lore
#1 lore raw

PATCH 1/8 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 has 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.

---
 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
#7 lore raw

PATCH 7/8 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.

---
 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
#3 lore raw

PATCH 3/8 ui/vnc-palette.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
#5 lore raw

PATCH 5/8 qga/channel-posix.c: Include headers it needs

In reply to Eduardo Habkost

Include:
- <errno.h> for errno
- <unistd.h> & <fcntl.h> for fcntl()
- "osdep.h" for qemu_open()
- <stdlib.h> for exit()

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:
qemu-common.h indirectly provided definition for exit(), so when replacing it with "osdep.h" add explicitly <stdlib.h> for exit()

---
 qga/channel-posix.c | 5 +++++
 1 file changed, 5 insertions(+)
qga/channel-posix.c +5 -0
index d152827..769a559 100644
@@ -1,5 +1,10 @@
 #include <glib.h>
 #include <termios.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include "osdep.h"
 #include "qemu_socket.h"
 #include "qga/channel.h"
 
Signature · 1 line
1.7.11.7
#6 lore raw

PATCH 6/8 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
#4 lore raw

PATCH 4/8 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
#8 lore raw

PATCH 8/8 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
#0 lore raw

cover qemu-common.h header cleanups

Hi,

These are the remaining header cleanups that didn't enter the tree yet. They should help breaking some circular header dependencies involving qemu-common.h.

Basically they were reordered by Igor to keep the tree bisectable, and some changes were made on the qga/channel-posix.c patch to eliminate the qemu-common.h dependency.

Eduardo Habkost (8):
user: Move *-user/qemu-types.h to main directory
user: Rename qemu-types.h to qemu-user-types.h ui/vnc-palette.c: Include headers it needs qapi/qmp-registry.c: Include headers it needs qga/channel-posix.c: Include headers it needs qlist.h: do not include qemu-common.h
create qemu-types.h for struct typedefs sysemu.h: include qemu-types.h instead of qemu-common.h

 bsd-user/qemu-types.h                        | 24 -----------
 bsd-user/qemu.h                              |  2 +-
 cpu-all.h                                    |  2 +-
 hw/qdev-core.h                               | 11 +----
 linux-user/qemu.h                            |  2 +-
 qapi/qmp-registry.c                          |  2 +
 qemu-common.h                                | 52 +-----------------------
 qemu-types.h                                 | 61 ++++++++++++++++++++++++++++
 linux-user/qemu-types.h => qemu-user-types.h |  0
 qga/channel-posix.c                          |  5 +++
 qlist.h                                      |  1 -
 sysemu.h                                     |  2 +-
 ui/vnc-palette.c                             |  2 +
 13 files changed, 76 insertions(+), 90 deletions(-)
 delete mode 100644 bsd-user/qemu-types.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
#2 lore raw

PATCH 2/8 user: Rename qemu-types.h to qemu-user-types.h

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

---
 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
#9 lore raw
In reply to Eduardo Habkost

Hi,

Am 22.11.2012 18:27, schrieb Eduardo Habkost:

Quoted 7 lines

These are the remaining header cleanups that didn't enter the tree yet. They should help breaking some circular header dependencies involving qemu-common.h.

Basically they were reordered by Igor to keep the tree bisectable, and some changes were made on the qga/channel-posix.c patch to eliminate the qemu-common.h dependency.

Quoted 5 lines

Eduardo Habkost (8):
user: Move *-user/qemu-types.h to main directory
user: Rename qemu-types.h to qemu-user-types.h ui/vnc-palette.c: Include headers it needs qapi/qmp-registry.c: Include headers it needs

Patches 1-4 seem to match exactly what I had previously queued for 1.3. Thanks, merged them into qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

I'll continue reviewing the changed parts later today.

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
#10 lore raw
In reply to Eduardo Habkost

Am 22.11.2012 18:27, schrieb Eduardo Habkost:

Quoted 7 lines

These are the remaining header cleanups that didn't enter the tree yet. They should help breaking some circular header dependencies involving qemu-common.h.

Basically they were reordered by Igor to keep the tree bisectable, and some changes were made on the qga/channel-posix.c patch to eliminate the qemu-common.h dependency.

Quoted 9 lines

Eduardo Habkost (8):
user: Move *-user/qemu-types.h to main directory
user: Rename qemu-types.h to qemu-user-types.h ui/vnc-palette.c: Include headers it needs qapi/qmp-registry.c: Include headers it needs qga/channel-posix.c: Include headers it needs qlist.h: do not include qemu-common.h
create qemu-types.h for struct typedefs sysemu.h: include qemu-types.h instead of qemu-common.h

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

I had already re-verified that qemu-types.h didn't loose anything but didn't push until now. Sorry.

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

Il 30/11/2012 21:53, Andreas Färber ha scritto:

Quoted 5 lines

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

I had already re-verified that qemu-types.h didn't loose anything but didn't push until now. Sorry.

Hi Andreas,

I would like to get the header file renaming in as soon as possible, can you make a pull request of this for me to rebase onto?

Paolo

#12 lore raw

Hi Paolo,

Am 04.12.2012 09:50, schrieb Paolo Bonzini:

Quoted 11 lines

Il 30/11/2012 21:53, Andreas Färber ha scritto:

Quoted 5 lines

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

I had already re-verified that qemu-types.h didn't loose anything but didn't push until now. Sorry.

Hi Andreas,

I would like to get the header file renaming in as soon as possible, can you make a pull request of this for me to rebase onto?

I have one or two patches ready to add to that, then I'll flush it!

And I was about to ask you: Do you have a tree ready that I could rebase my QOM realize / ISA work on?

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