Merge remote-tracking branch 'bonzini/migration-writev' into staging

# By Paolo Bonzini
# Via Paolo Bonzini
* bonzini/migration-writev:
  win32: add readv/writev emulation
  win32: generate console executable again
  win32: move Makefile dependencies on version-obj-y to rules.mak
  win32: add generic RC rules to rules.mak

Message-id: 1367230284-24612-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Anthony Liguori 2013-04-29 08:26:47 -05:00
commit b48df71c91
7 changed files with 72 additions and 26 deletions

View file

@ -167,13 +167,10 @@ recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
version.o: $(SRC_PATH)/version.rc config-host.h | version.lo
$(call quiet-command,$(WINDRES) -I. -o $@ $<," RC $(TARGET_DIR)$@")
version.lo: $(SRC_PATH)/version.rc config-host.h
$(call quiet-command,$(LIBTOOL) --mode=compile --tag=RC $(WINDRES) -I. -o $@ $<,"lt RC $(TARGET_DIR)$@")
version-obj-$(CONFIG_WIN32) += version.o
version-lobj-$(CONFIG_WIN32) += $(if $(LIBTOOL),version.lo)
Makefile: $(version-obj-y) $(version-lobj-y)
version-lobj-$(CONFIG_WIN32) += version.lo
######################################################################

View file

@ -18,7 +18,7 @@ ifdef CONFIG_USER_ONLY
QEMU_PROG=qemu-$(TARGET_ARCH2)
else
# system emulator name
ifneq (,$(findstring -mwindows,$(LIBS)))
ifneq (,$(findstring -mwindows,$(libs_softmmu)))
# Terminate program name with a 'w' because the linker builds a windows executable.
QEMU_PROGW=qemu-system-$(TARGET_ARCH2)w$(EXESUF)
endif # windows executable

View file

@ -84,20 +84,6 @@
# 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);
@ -122,16 +108,12 @@ static inline char *realpath(const char *path, char *resolved_path)
void configure_icount(const char *option);
extern int use_icount;
/* FIXME: Remove NEED_CPU_H. */
#ifndef NEED_CPU_H
#include "qemu/osdep.h"
#include "qemu/bswap.h"
#else
/* FIXME: Remove NEED_CPU_H. */
#ifdef NEED_CPU_H
#include "cpu.h"
#endif /* !defined(NEED_CPU_H) */
/* main function, renamed */

View file

@ -1,6 +1,7 @@
#ifndef QEMU_OSDEP_H
#define QEMU_OSDEP_H
#include "config-host.h"
#include <stdarg.h>
#include <stddef.h>
#include <stdbool.h>
@ -161,6 +162,22 @@ int qemu_close(int fd);
int qemu_create_pidfile(const char *filename);
int qemu_get_thread_id(void);
#ifndef CONFIG_IOVEC
struct iovec {
void *iov_base;
size_t iov_len;
};
/*
* Use the same value as Linux for now.
*/
#define IOV_MAX 1024
ssize_t readv(int fd, const struct iovec *iov, int iov_cnt);
ssize_t writev(int fd, const struct iovec *iov, int iov_cnt);
#else
#include <sys/uio.h>
#endif
#ifdef _WIN32
static inline void qemu_timersub(const struct timeval *val1,
const struct timeval *val2,

View file

@ -19,6 +19,10 @@ QEMU_CFLAGS += -I$(<D) -I$(@D)
%.o: %.c
$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@")
%.o: %.rc
$(call quiet-command,$(WINDRES) -I. -o $@ $<," RC $(TARGET_DIR)$@")
Makefile: $(version-obj-y)
ifeq ($(LIBTOOL),)
LIBTOOL = /bin/false
@ -26,9 +30,12 @@ LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \
$(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
$(LIBS)," LINK $(TARGET_DIR)$@")
else
Makefile: $(version-lobj-y)
LIBTOOL += $(if $(V),,--quiet)
%.lo: %.c
$(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@")
%.lo: %.rc
$(call quiet-command,$(LIBTOOL) --mode=compile --tag=RC $(WINDRES) -I. -o $@ $<,"lt RC $(TARGET_DIR)$@")
%.lo: %.dtrace
$(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC dtrace -o $@ -G -s $<, " lt GEN $(TARGET_DIR)$@")

View file

@ -99,7 +99,7 @@ size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt)
static ssize_t
do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
{
#if defined CONFIG_IOVEC && defined CONFIG_POSIX
#ifdef CONFIG_POSIX
ssize_t ret;
struct msghdr msg;
memset(&msg, 0, sizeof(msg));

View file

@ -429,3 +429,46 @@ int socket_init(void)
#endif
return 0;
}
#ifndef CONFIG_IOVEC
/* helper function for iov_send_recv() */
static ssize_t
readv_writev(int fd, const struct iovec *iov, int iov_cnt, bool do_write)
{
unsigned i = 0;
ssize_t ret = 0;
while (i < iov_cnt) {
ssize_t r = do_write
? write(fd, iov[i].iov_base, iov[i].iov_len)
: read(fd, iov[i].iov_base, iov[i].iov_len);
if (r > 0) {
ret += r;
} else if (!r) {
break;
} else if (errno == EINTR) {
continue;
} else {
/* else it is some "other" error,
* only return if there was no data processed. */
if (ret == 0) {
ret = -1;
}
break;
}
i++;
}
return ret;
}
ssize_t
readv(int fd, const struct iovec *iov, int iov_cnt)
{
return readv_writev(fd, iov, iov_cnt, false);
}
ssize_t
writev(int fd, const struct iovec *iov, int iov_cnt)
{
return readv_writev(fd, iov, iov_cnt, true);
}
#endif