From c609854fe18aab3216f28e1e5291b75970d398d5 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 18 Mar 2009 16:32:53 +0000 Subject: [PATCH] Post-merge compilation fixes for stubdom Much of this is very ugly. Sadly that's a consequence of the stubdom and upstream build systems and nothing much can be done about it. However on the upside with this change we discontinue use of the upstream `configure' script for stubdom (as it gives wrong answers), in favour of a new xen-setup-stubdom script. Signed-off-by: Ian Jackson --- Makefile.target | 2 - block-raw-posix.c | 5 +++ block-vbd.c | 2 +- block.c | 3 +- i386-dm/exec-dm.c | 2 +- migration-exec.c | 6 +++ migration-tcp.c | 4 +- net.c | 9 +++++ posix-aio-compat.c | 6 +++ qemu-sockets.c | 19 +++++++++ qemu_socket.h | 2 + savevm.c | 13 +++++++ xen-config-host.h | 9 +++-- xen-setup | 9 +---- xen-setup-stubdom | 97 ++++++++++++++++++++++++++++++++++++++++++++++ xenstore.c | 2 +- 16 files changed, 170 insertions(+), 20 deletions(-) create mode 100755 xen-setup-stubdom diff --git a/Makefile.target b/Makefile.target index 3cc3d341..d2023d51 100644 --- a/Makefile.target +++ b/Makefile.target @@ -135,8 +135,6 @@ default: all kvm.o: CFLAGS+=$(KVM_CFLAGS) kvm-all.o: CFLAGS+=$(KVM_CFLAGS) -all: $(PROGS) - ######################################################### # cpu emulator library LIBOBJS=exec.o kqemu.o translate-all.o cpu-exec.o\ diff --git a/block-raw-posix.c b/block-raw-posix.c index f62b7878..93bd2723 100644 --- a/block-raw-posix.c +++ b/block-raw-posix.c @@ -26,6 +26,9 @@ #include "qemu-char.h" #include "block_int.h" #include + +#ifndef CONFIG_STUBDOM + #ifdef CONFIG_AIO #include "posix-aio-compat.h" #endif @@ -1228,3 +1231,5 @@ BlockDriver bdrv_host_device = { /* generic scsi device */ .bdrv_ioctl = raw_ioctl, }; + +#endif CONFIG_STUBDOM diff --git a/block-vbd.c b/block-vbd.c index 129a1f55..8c15d65b 100644 --- a/block-vbd.c +++ b/block-vbd.c @@ -335,7 +335,7 @@ static int vbd_set_locked(BlockDriverState *bs, int locked) return -ENOTSUP; } -BlockDriver bdrv_vbd = { +BlockDriver bdrv_raw = { "vbd", sizeof(BDRVVbdState), vbd_probe, diff --git a/block.c b/block.c index a1906d0e..f59ac6f4 100644 --- a/block.c +++ b/block.c @@ -1568,9 +1568,8 @@ static BlockDriverAIOCB *bdrv_aio_flush_em(BlockDriverState *bs, void bdrv_init(void) { bdrv_register(&bdrv_raw); +#ifndef CONFIG_STUBDOM bdrv_register(&bdrv_host_device); -#ifdef CONFIG_STUBDOM - bdrv_register(&bdrv_vbd); #endif #ifndef _WIN32 bdrv_register(&bdrv_cow); diff --git a/i386-dm/exec-dm.c b/i386-dm/exec-dm.c index d035eb5c..99a32b23 100644 --- a/i386-dm/exec-dm.c +++ b/i386-dm/exec-dm.c @@ -712,7 +712,7 @@ void cpu_physical_memory_write_rom(target_phys_addr_t addr, void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size) { } void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size) { } -#if DIRECT_MMAP +#ifdef DIRECT_MMAP void *cpu_physical_memory_map(target_phys_addr_t addr, target_phys_addr_t *plen, int is_write) { diff --git a/migration-exec.c b/migration-exec.c index caeed4bb..220df0b4 100644 --- a/migration-exec.c +++ b/migration-exec.c @@ -60,6 +60,11 @@ MigrationState *exec_start_outgoing_migration(const char *command, FdMigrationState *s; FILE *f; +#ifdef CONFIG_STUBDOM + dprintf("stubdom migration? no popen!"); + return 0; +#else + s = qemu_mallocz(sizeof(*s)); if (s == NULL) { dprintf("Unable to allocate FdMigrationState\n"); @@ -111,6 +116,7 @@ err_after_alloc: qemu_free(s); err: return NULL; +#endif /*!CONFIG_STUBDOM*/ } int exec_start_incoming_migration(const char *command) diff --git a/migration-tcp.c b/migration-tcp.c index 6fc1943d..d043c86b 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -40,7 +40,7 @@ static int socket_write(FdMigrationState *s, const void * buf, size_t size) return send(s->fd, buf, size, 0); } -static int tcp_close(FdMigrationState *s) +static int tcp_close_qemu(FdMigrationState *s) { dprintf("tcp_close\n"); if (s->fd != -1) { @@ -94,7 +94,7 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port, s->get_error = socket_errno; s->write = socket_write; - s->close = tcp_close; + s->close = tcp_close_qemu; s->mig_state.cancel = migrate_fd_cancel; s->mig_state.get_status = migrate_fd_get_status; s->mig_state.release = migrate_fd_release; diff --git a/net.c b/net.c index d7bf022e..78e2e651 100644 --- a/net.c +++ b/net.c @@ -674,6 +674,7 @@ typedef struct TAPState { char script_arg[1024]; } TAPState; +#ifndef CONFIG_STUBDOM #ifdef HAVE_IOVEC static ssize_t tap_receive_iov(void *opaque, const struct iovec *iov, int iovcnt) @@ -688,6 +689,7 @@ static ssize_t tap_receive_iov(void *opaque, const struct iovec *iov, return len; } #endif +#endif /*!CONFIG_STUBDOM*/ static void tap_receive(void *opaque, const uint8_t *buf, int size) { @@ -738,8 +740,10 @@ static TAPState *net_tap_fd_init(VLANState *vlan, s->vc = qemu_new_vlan_client(vlan, model, name, tap_receive, NULL, s); s->next = head_net_tap; head_net_tap = s; +#ifndef CONFIG_STUBDOM #ifdef HAVE_IOVEC s->vc->fd_readv = tap_receive_iov; +#endif #endif qemu_set_fd_handler(s->fd, tap_send, NULL, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd); @@ -991,6 +995,10 @@ static int net_tap_init(VLANState *vlan, const char *model, const char *setup_script, const char *down_script, const char *script_arg) { +#ifdef CONFIG_STUBDOM + errno = ENOSYS; + return -1; +#else TAPState *s; int fd; char ifname[128]; @@ -1024,6 +1032,7 @@ static int net_tap_init(VLANState *vlan, const char *model, else s->script_arg[0] = '\0'; return 0; +#endif } #endif /* !_WIN32 */ diff --git a/posix-aio-compat.c b/posix-aio-compat.c index 771402dd..c2310109 100644 --- a/posix-aio-compat.c +++ b/posix-aio-compat.c @@ -18,6 +18,10 @@ #include #include "osdep.h" +#include "qemu-common.h" + +#ifndef CONFIG_STUBDOM + #include "posix-aio-compat.h" static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; @@ -201,3 +205,5 @@ int qemu_paio_cancel(int fd, struct qemu_paiocb *aiocb) return ret; } + +#endif CONFIG_STUBDOM diff --git a/qemu-sockets.c b/qemu-sockets.c index c7db5ace..9b9fa772 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -22,6 +22,8 @@ #include "qemu_socket.h" #include "qemu-common.h" /* for qemu_isdigit */ +#ifndef CONFIG_STUBDOM + #ifndef AI_ADDRCONFIG # define AI_ADDRCONFIG 0 #endif @@ -312,6 +314,23 @@ int inet_connect(const char *str, int socktype) return -1; } +#else /*!CONFIG_STUBDOM*/ + +int inet_listen(const char *str, char *ostr, int olen, + int socktype, int port_offset) +{ + fprintf(stderr, "ip sockets are not available on stubdom\n"); + return -1; +} + +int inet_connect(const char *str, int socktype) +{ + fprintf(stderr, "ip sockets are not available on stubdom\n"); + return -1; +} + +#endif /*!CONFIG_STUBDOM*/ + #ifndef NO_UNIX_SOCKETS int unix_listen(const char *str, char *ostr, int olen) diff --git a/qemu_socket.h b/qemu_socket.h index 03f895b7..7a2dc9cb 100644 --- a/qemu_socket.h +++ b/qemu_socket.h @@ -2,6 +2,8 @@ #ifndef QEMU_SOCKET_H #define QEMU_SOCKET_H +#include "config-host.h" + #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #define WINVER 0x0501 /* needed for ipv6 bits */ diff --git a/savevm.c b/savevm.c index 3dc887d2..ae880d33 100644 --- a/savevm.c +++ b/savevm.c @@ -208,6 +208,11 @@ QEMUFile *qemu_popen(FILE *popen_file, const char *mode) { QEMUFilePopen *s; +#ifdef CONFIG_STUBDOM + errno = ENOSYS; + return NULL; +#else + if (popen_file == NULL || mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) { fprintf(stderr, "qemu_popen: Argument validity check failed\n"); return NULL; @@ -228,18 +233,26 @@ QEMUFile *qemu_popen(FILE *popen_file, const char *mode) } fprintf(stderr, "qemu_popen: returning result of qemu_fopen_ops\n"); return s->file; + +#endif /*!CONFIG_STUBDOM*/ } QEMUFile *qemu_popen_cmd(const char *command, const char *mode) { FILE *popen_file; +#ifdef CONFIG_STUBDOM + errno = ENOSYS; + return NULL; +#else + popen_file = popen(command, mode); if(popen_file == NULL) { return NULL; } return qemu_popen(popen_file, mode); +#endif /*!CONFIG_STUBDOM*/ } QEMUFile *qemu_fopen_socket(int fd) diff --git a/xen-config-host.h b/xen-config-host.h index 5fd4577e..3a3d7a48 100644 --- a/xen-config-host.h +++ b/xen-config-host.h @@ -1,8 +1,7 @@ #ifndef XEN_CONFIG_HOST_H #define XEN_CONFIG_HOST_H -#ifdef __MINIOS__ -#define CONFIG_STUBDOM +#ifdef CONFIG_STUBDOM #undef CONFIG_AIO #define NO_UNIX_SOCKETS 1 #define NO_BLUETOOTH_PASSTHROUGH 1 @@ -36,7 +35,7 @@ extern int vcpus; #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/xen/qemu-ifdown" #ifdef CONFIG_STUBDOM -extern struct BlockDriver bdrv_vbd; +#define bdrv_host_device bdrv_raw #endif struct CharDriverState; void xenstore_store_serial_port_info(int i, struct CharDriverState *chr, @@ -45,4 +44,8 @@ void xenstore_store_serial_port_info(int i, struct CharDriverState *chr, extern unsigned long *logdirty_bitmap; extern unsigned long logdirty_bitmap_size; +#ifdef CONFIG_STUBDOM +#undef HAVE_IOVEC +#endif + #endif /*XEN_CONFIG_HOST_H*/ diff --git a/xen-setup b/xen-setup index ebfad966..8ca00199 100755 --- a/xen-setup +++ b/xen-setup @@ -11,14 +11,7 @@ if test -f config-host.h; then mv config-host.h config-host.h~; fi ./configure --disable-gfx-check --disable-curses --disable-slirp "$@" --prefix=/usr -if [ -n "$CONFIG_STUBDOM" ] -then - target=i386-stubdom - ln -sf ../i386-dm/hookslib.mak $target/ - (cd $target ; ln -sf ../i386-dm/*.[ch] .) -else - target=i386-dm -fi +target=i386-dm if [ "x$XEN_ROOT" != x ]; then echo "XEN_ROOT=$XEN_ROOT" >>config-host.mak diff --git a/xen-setup-stubdom b/xen-setup-stubdom new file mode 100755 index 00000000..a3cc5f9b --- /dev/null +++ b/xen-setup-stubdom @@ -0,0 +1,97 @@ +#!/bin/sh +set -e + +qemu_version=`head VERSION` + +ln -sf ../Makefile.target i386-stubdom/Makefile + +target=i386-stubdom + +#---------- +cat <$target/config.mak.new +QEMU_ROOT ?= .. +XEN_ROOT ?= \$(QEMU_ROOT)/../xen-unstable.hg + +include ../config-host.mak + +TARGET_ARCH=i386 +CONFIG_SOFTMMU=yes + +TARGET_CPPFLAGS += $TARGET_CPPFLAGS -DCONFIG_STUBDOM -D__XEN_TOOLS__ +TARGET_CFLAGS= $TARGET_CFLAGS +TARGET_LDFLAGS= $TARGET_LDFLAGS + +bindir = \${prefix}/\${LIBLEAFDIR}/xen/bin +END +mv -f $target/config.mak.new $target/config.mak +#---------- + +ln -sf ../i386-dm/hookslib.mak $target/ +(cd $target ; ln -sf ../i386-dm/*.[ch] .) + +#---------- +cat <config-host.h.new +#define CONFIG_QEMU_SHAREDIR "/usr/share/xen/qemu" +#define HOST_I386 1 +#define HOST_LONG_BITS 32 +#define HAVE_BYTESWAP_H 1 +#define AUDIO_DRIVERS /* none */ +#define QEMU_VERSION "$qemu_version" +#define CONFIG_UNAME_RELEASE "" +#include "xen-config-host.h" +END +mv -f config-host.h.new config-host.h +#---------- + +#---------- +cat <config-host.mak.new +CONFIG_STUBDOM=yes +prefix=/usr +bindir=\${prefix}/bin +mandir=\${prefix}/share/man +datadir=\${prefix}/share/qemu +docdir=\${prefix}/share/doc/qemu +MAKE=make +INSTALL=install +CC=gcc +HOST_CC=gcc +AR=ar +STRIP=strip -s -R .comment -R .note +OS_CFLAGS= +OS_LDFLAGS= +ARCH_CFLAGS=-m32 +ARCH_LDFLAGS=-m32 +EXESUF= +AIOLIBS= +ARCH=i386 +CONFIG_GDBSTUB=no +CONFIG_OSS=no +CONFIG_OSS_LIB= +VERSION=$qemu_version +SRC_PATH=`pwd` +TARGET_DIRS=$target +BUILD_DOCS=no +CONFIG_AIO=no +TOOLS= +XEN_ROOT=/volatile/iwj/builds/work/2/build/xen-unstable.hg/ +QEMU_ROOT ?= `pwd` +XEN_ROOT ?= \$(QEMU_ROOT)/../xen-unstable.hg +include \$(XEN_ROOT)/tools/Rules.mk +SUBDIR_RULES=subdir-\$(TARGET_DIRS) +subdir-\$(TARGET_DIRS): libqemu_common.a +-include \$(QEMU_ROOT)/xen-hooks.mak +HOST_USB=stub + +HOST_LDFLAGS= \$(LDFLAGS) -g -Wl,--warn-common +HOST_CFLAGS= \$(CFLAGS) +CPPFLAGS += $TARGET_CPPFLAGS -DCONFIG_STUBDOM +CFLAGS= $TARGET_CFLAGS +LDFLAGS= $TARGET_LDFLAGS + +SUBDIR_RULES=subdir-$(TARGET_DIRS) +subdir-\$(TARGET_DIRS): libqemu_common.a +-include \$(QEMU_ROOT)/xen-hooks.mak + +END +mv -f config-host.mak.new config-host.mak +#---------- diff --git a/xenstore.c b/xenstore.c index 4ee6cebb..92ee1e21 100644 --- a/xenstore.c +++ b/xenstore.c @@ -474,7 +474,7 @@ void xenstore_parse_domain_config(int hvm_domid) #ifdef CONFIG_STUBDOM if (pasprintf(&danger_buf, "%s/device/vbd/%s", danger_path, e_danger[i]) == -1) continue; - if (bdrv_open2(bs, danger_buf, BDRV_O_CACHE_WB /* snapshot and write-back */, &bdrv_vbd) == 0) { + if (bdrv_open2(bs, danger_buf, BDRV_O_CACHE_WB /* snapshot and write-back */, &bdrv_raw) == 0) { pstrcpy(bs->filename, sizeof(bs->filename), params); } else #endif -- 2.39.5