Fix sys-queue.h conflict for good
Problem: Our file sys-queue.h is a copy of the BSD file, but there are
some additions and it's not entirely compatible. Because of that, there have
been conflicts with system headers on BSD systems. Some hacks have been
introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,
f40d753718c72693c5f520f0d9899f6e50395e94,
96555a96d724016e13190b28cffa3bc929ac60dc and
3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile.
Solution: Avoid the conflict entirely by renaming the functions and the
file. Revert the previous hacks.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
diff --git a/vl.c b/vl.c
index 1f95a37..0e61333 100644
--- a/vl.c
+++ b/vl.c
@@ -31,8 +31,6 @@
/* Needed early for CONFIG_BSD etc. */
#include "config-host.h"
-/* Needed early to override system queue definitions on BSD */
-#include "sys-queue.h"
#ifndef _WIN32
#include <libgen.h>
@@ -168,6 +166,8 @@
#include "slirp/libslirp.h"
+#include "qemu-queue.h"
+
//#define DEBUG_NET
//#define DEBUG_SLIRP
@@ -180,8 +180,8 @@
const char *bios_name = NULL;
/* Note: drives_table[MAX_DRIVES] is a dummy block driver if none available
to store the VM snapshots */
-struct drivelist drives = TAILQ_HEAD_INITIALIZER(drives);
-struct driveoptlist driveopts = TAILQ_HEAD_INITIALIZER(driveopts);
+struct drivelist drives = QTAILQ_HEAD_INITIALIZER(drives);
+struct driveoptlist driveopts = QTAILQ_HEAD_INITIALIZER(driveopts);
enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
static DisplayState *display_state;
DisplayType display_type = DT_DEFAULT;
@@ -1810,7 +1810,7 @@
/* seek interface, bus and unit */
- TAILQ_FOREACH(dinfo, &drives, next) {
+ QTAILQ_FOREACH(dinfo, &drives, next) {
if (dinfo->type == type &&
dinfo->bus == bus &&
dinfo->unit == unit)
@@ -1824,7 +1824,7 @@
{
DriveInfo *dinfo;
- TAILQ_FOREACH(dinfo, &drives, next) {
+ QTAILQ_FOREACH(dinfo, &drives, next) {
if (strcmp(id, dinfo->id))
continue;
return dinfo;
@@ -1838,7 +1838,7 @@
DriveInfo *dinfo;
max_bus = -1;
- TAILQ_FOREACH(dinfo, &drives, next) {
+ QTAILQ_FOREACH(dinfo, &drives, next) {
if(dinfo->type == type &&
dinfo->bus > max_bus)
max_bus = dinfo->bus;
@@ -1850,7 +1850,7 @@
{
DriveInfo *dinfo;
- TAILQ_FOREACH(dinfo, &drives, next) {
+ QTAILQ_FOREACH(dinfo, &drives, next) {
if (dinfo->bdrv == bdrv)
return dinfo->serial;
}
@@ -1862,7 +1862,7 @@
{
DriveInfo *dinfo;
- TAILQ_FOREACH(dinfo, &drives, next) {
+ QTAILQ_FOREACH(dinfo, &drives, next) {
if (dinfo->bdrv == bdrv)
return dinfo->onerror;
}
@@ -1879,11 +1879,11 @@
{
DriveInfo *dinfo;
- TAILQ_FOREACH(dinfo, &drives, next) {
+ QTAILQ_FOREACH(dinfo, &drives, next) {
if (dinfo->bdrv != bdrv)
continue;
qemu_opts_del(dinfo->opts);
- TAILQ_REMOVE(&drives, dinfo, next);
+ QTAILQ_REMOVE(&drives, dinfo, next);
qemu_free(dinfo);
break;
}
@@ -2170,7 +2170,7 @@
dinfo->opts = opts;
if (serial)
strncpy(dinfo->serial, serial, sizeof(serial));
- TAILQ_INSERT_TAIL(&drives, dinfo, next);
+ QTAILQ_INSERT_TAIL(&drives, dinfo, next);
switch(type) {
case IF_IDE:
@@ -3145,10 +3145,10 @@
struct vm_change_state_entry {
VMChangeStateHandler *cb;
void *opaque;
- LIST_ENTRY (vm_change_state_entry) entries;
+ QLIST_ENTRY (vm_change_state_entry) entries;
};
-static LIST_HEAD(vm_change_state_head, vm_change_state_entry) vm_change_state_head;
+static QLIST_HEAD(vm_change_state_head, vm_change_state_entry) vm_change_state_head;
VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
void *opaque)
@@ -3159,13 +3159,13 @@
e->cb = cb;
e->opaque = opaque;
- LIST_INSERT_HEAD(&vm_change_state_head, e, entries);
+ QLIST_INSERT_HEAD(&vm_change_state_head, e, entries);
return e;
}
void qemu_del_vm_change_state_handler(VMChangeStateEntry *e)
{
- LIST_REMOVE (e, entries);
+ QLIST_REMOVE (e, entries);
qemu_free (e);
}
@@ -3195,13 +3195,13 @@
/* reset/shutdown handler */
typedef struct QEMUResetEntry {
- TAILQ_ENTRY(QEMUResetEntry) entry;
+ QTAILQ_ENTRY(QEMUResetEntry) entry;
QEMUResetHandler *func;
void *opaque;
} QEMUResetEntry;
-static TAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
- TAILQ_HEAD_INITIALIZER(reset_handlers);
+static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
+ QTAILQ_HEAD_INITIALIZER(reset_handlers);
static int reset_requested;
static int shutdown_requested;
static int powerdown_requested;
@@ -3259,16 +3259,16 @@
re->func = func;
re->opaque = opaque;
- TAILQ_INSERT_TAIL(&reset_handlers, re, entry);
+ QTAILQ_INSERT_TAIL(&reset_handlers, re, entry);
}
void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
{
QEMUResetEntry *re;
- TAILQ_FOREACH(re, &reset_handlers, entry) {
+ QTAILQ_FOREACH(re, &reset_handlers, entry) {
if (re->func == func && re->opaque == opaque) {
- TAILQ_REMOVE(&reset_handlers, re, entry);
+ QTAILQ_REMOVE(&reset_handlers, re, entry);
qemu_free(re);
return;
}
@@ -3280,7 +3280,7 @@
QEMUResetEntry *re, *nre;
/* reset all devices */
- TAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) {
+ QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) {
re->func(re->opaque);
}
}
@@ -4579,9 +4579,9 @@
DEV_BT, /* -bt */
} type;
const char *cmdline;
- TAILQ_ENTRY(device_config) next;
+ QTAILQ_ENTRY(device_config) next;
};
-TAILQ_HEAD(, device_config) device_configs = TAILQ_HEAD_INITIALIZER(device_configs);
+QTAILQ_HEAD(, device_config) device_configs = QTAILQ_HEAD_INITIALIZER(device_configs);
static void add_device_config(int type, const char *cmdline)
{
@@ -4590,7 +4590,7 @@
conf = qemu_mallocz(sizeof(*conf));
conf->type = type;
conf->cmdline = cmdline;
- TAILQ_INSERT_TAIL(&device_configs, conf, next);
+ QTAILQ_INSERT_TAIL(&device_configs, conf, next);
}
static int foreach_device_config(int type, int (*func)(const char *cmdline))
@@ -4598,7 +4598,7 @@
struct device_config *conf;
int rc;
- TAILQ_FOREACH(conf, &device_configs, next) {
+ QTAILQ_FOREACH(conf, &device_configs, next) {
if (conf->type != type)
continue;
rc = func(conf->cmdline);
@@ -4655,7 +4655,7 @@
qemu_errors_to_file(stderr);
qemu_cache_utils_init(envp);
- LIST_INIT (&vm_change_state_head);
+ QLIST_INIT (&vm_change_state_head);
#ifndef _WIN32
{
struct sigaction act;