aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKeir Fraser <keir@xensource.com>2007-09-27 16:36:23 +0100
committerKeir Fraser <keir@xensource.com>2007-09-27 16:36:23 +0100
commit67c97dc9f7e8bda9947dae8bf5d26f09d895033a (patch)
treebc846b16ad2d0de580559b1bab13d382d39e2d38 /tools
parenta0d123d8045fcd2acb911969cb14ee4b2e106b01 (diff)
downloadxen-67c97dc9f7e8bda9947dae8bf5d26f09d895033a.tar.gz
xen-67c97dc9f7e8bda9947dae8bf5d26f09d895033a.tar.bz2
xen-67c97dc9f7e8bda9947dae8bf5d26f09d895033a.zip
ioemu: Fixes for BSD.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/ioemu/audio/audio.c4
-rw-r--r--tools/ioemu/audio/mixeng.c4
-rw-r--r--tools/ioemu/audio/ossaudio.c7
-rw-r--r--tools/ioemu/block-raw.c25
-rw-r--r--tools/ioemu/block-vvfat.c2
-rw-r--r--tools/ioemu/bswap.h7
-rw-r--r--tools/ioemu/cutils.c6
-rw-r--r--tools/ioemu/monitor.c38
-rw-r--r--tools/ioemu/osdep.h4
-rw-r--r--tools/ioemu/target-i386-dm/exec-dm.c4
-rw-r--r--tools/ioemu/usb-linux.c2
-rw-r--r--tools/ioemu/vl.c84
-rw-r--r--tools/ioemu/vl.h4
-rw-r--r--tools/ioemu/vnc.c3
14 files changed, 148 insertions, 46 deletions
diff --git a/tools/ioemu/audio/audio.c b/tools/ioemu/audio/audio.c
index 556e6fdbcb..65e1de8118 100644
--- a/tools/ioemu/audio/audio.c
+++ b/tools/ioemu/audio/audio.c
@@ -207,7 +207,7 @@ static char *audio_alloc_prefix (const char *s)
strcat (r, s);
for (i = 0; i < len; ++i) {
- u[i] = toupper (u[i]);
+ u[i] = toupper ((uint8_t)u[i]);
}
}
return r;
@@ -446,7 +446,7 @@ static void audio_process_options (const char *prefix,
/* copy while upper-casing, including trailing zero */
for (i = 0; i <= preflen; ++i) {
- optname[i + sizeof (qemu_prefix) - 1] = toupper (prefix[i]);
+ optname[i + sizeof (qemu_prefix) - 1] = toupper ((uint8_t)prefix[i]);
}
strcat (optname, "_");
strcat (optname, opt->name);
diff --git a/tools/ioemu/audio/mixeng.c b/tools/ioemu/audio/mixeng.c
index 6308d41004..74f79958a3 100644
--- a/tools/ioemu/audio/mixeng.c
+++ b/tools/ioemu/audio/mixeng.c
@@ -102,6 +102,7 @@
#undef SHIFT
t_sample *mixeng_conv[2][2][2][2] = {
+#ifndef _BSD
{
{
{
@@ -146,9 +147,11 @@ t_sample *mixeng_conv[2][2][2][2] = {
}
}
}
+#endif /* !_BSD */
};
f_sample *mixeng_clip[2][2][2][2] = {
+#ifndef _BSD
{
{
{
@@ -193,6 +196,7 @@ f_sample *mixeng_clip[2][2][2][2] = {
}
}
}
+#endif /* !_BSD */
};
/*
diff --git a/tools/ioemu/audio/ossaudio.c b/tools/ioemu/audio/ossaudio.c
index 125e4c8ff7..bf5932e114 100644
--- a/tools/ioemu/audio/ossaudio.c
+++ b/tools/ioemu/audio/ossaudio.c
@@ -21,10 +21,15 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include <stdlib.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/ioctl.h>
+#if defined(__OpenBSD__)
+#include <soundcard.h>
+#else
#include <sys/soundcard.h>
+#endif
#include "vl.h"
#define AUDIO_CAP "oss"
@@ -231,7 +236,7 @@ static int oss_open (int in, struct oss_params *req,
goto err;
}
- if (ioctl (fd, SNDCTL_DSP_NONBLOCK)) {
+ if (ioctl (fd, SNDCTL_DSP_NONBLOCK, NULL)) {
oss_logerr2 (errno, typ, "Failed to set non-blocking mode\n");
goto err;
}
diff --git a/tools/ioemu/block-raw.c b/tools/ioemu/block-raw.c
index 50ef4f5b11..68e8a370ca 100644
--- a/tools/ioemu/block-raw.c
+++ b/tools/ioemu/block-raw.c
@@ -53,9 +53,14 @@
#include <linux/cdrom.h>
#include <linux/fd.h>
#endif
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__)
#include <sys/disk.h>
#endif
+#if defined(__OpenBSD__)
+#include <sys/ioctl.h>
+#include <sys/disklabel.h>
+#include <sys/dkio.h>
+#endif
//#define DEBUG_FLOPPY
@@ -496,6 +501,23 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset)
return 0;
}
+#ifdef __OpenBSD__
+static int64_t raw_getlength(BlockDriverState *bs)
+{
+ int fd = ((BDRVRawState*)bs->opaque)->fd;
+ struct stat st;
+ if(fstat(fd, &st))
+ return -1;
+ if(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)){
+ struct disklabel dl;
+ if(ioctl(fd, DIOCGDINFO, &dl))
+ return -1;
+ return (uint64_t)dl.d_secsize *
+ dl.d_partitions[DISKPART(st.st_rdev)].p_size;
+ }else
+ return st.st_size;
+}
+#else /* !__OpenBSD__ */
static int64_t raw_getlength(BlockDriverState *bs)
{
BDRVRawState *s = bs->opaque;
@@ -542,6 +564,7 @@ static int64_t raw_getlength(BlockDriverState *bs)
}
return size;
}
+#endif
static int raw_create(const char *filename, int64_t total_size,
const char *backing_file, int flags)
diff --git a/tools/ioemu/block-vvfat.c b/tools/ioemu/block-vvfat.c
index 48a52e3116..faa53a5ac2 100644
--- a/tools/ioemu/block-vvfat.c
+++ b/tools/ioemu/block-vvfat.c
@@ -1017,7 +1017,7 @@ DLOG(if (stderr == NULL) {
i = strrchr(dirname, ':') - dirname;
assert(i >= 3);
- if (dirname[i-2] == ':' && isalpha(dirname[i-1]))
+ if (dirname[i-2] == ':' && isalpha((uint8_t)dirname[i-1]))
/* workaround for DOS drive names */
dirname += i-1;
else
diff --git a/tools/ioemu/bswap.h b/tools/ioemu/bswap.h
index 37fb04ed97..f0d77f591c 100644
--- a/tools/ioemu/bswap.h
+++ b/tools/ioemu/bswap.h
@@ -5,6 +5,11 @@
#include <inttypes.h>
+#ifdef _BSD
+#include <sys/endian.h>
+#include <sys/types.h>
+#else
+
#ifdef HAVE_BYTESWAP_H
#include <byteswap.h>
#else
@@ -73,6 +78,8 @@ static inline void bswap64s(uint64_t *s)
*s = bswap64(*s);
}
+#endif /* _BSD */
+
#if defined(WORDS_BIGENDIAN)
#define be_bswap(v, size) (v)
#define le_bswap(v, size) bswap ## size(v)
diff --git a/tools/ioemu/cutils.c b/tools/ioemu/cutils.c
index 352c47e211..dc51e67235 100644
--- a/tools/ioemu/cutils.c
+++ b/tools/ioemu/cutils.c
@@ -23,7 +23,7 @@
*/
#include "vl.h"
-void pstrcpy(char *buf, int buf_size, const char *str)
+void pstrcpy(char *buf, size_t buf_size, const char *str)
{
int c;
char *q = buf;
@@ -41,7 +41,7 @@ void pstrcpy(char *buf, int buf_size, const char *str)
}
/* strcat and truncate. */
-char *pstrcat(char *buf, int buf_size, const char *s)
+char *pstrcat(char *buf, size_t buf_size, const char *s)
{
int len;
len = strlen(buf);
@@ -72,7 +72,7 @@ int stristart(const char *str, const char *val, const char **ptr)
p = str;
q = val;
while (*q != '\0') {
- if (toupper(*p) != toupper(*q))
+ if (toupper((uint8_t)*p) != toupper((uint8_t)*q))
return 0;
p++;
q++;
diff --git a/tools/ioemu/monitor.c b/tools/ioemu/monitor.c
index f3bfe0fbf1..5f0a69af27 100644
--- a/tools/ioemu/monitor.c
+++ b/tools/ioemu/monitor.c
@@ -1698,7 +1698,7 @@ static void next(void)
{
if (pch != '\0') {
pch++;
- while (isspace(*pch))
+ while (isspace((uint8_t)*pch))
pch++;
}
}
@@ -1756,7 +1756,7 @@ static target_long expr_unary(void)
*q++ = *pch;
pch++;
}
- while (isspace(*pch))
+ while (isspace((uint8_t)*pch))
pch++;
*q = 0;
ret = get_monitor_def(&n, buf);
@@ -1780,7 +1780,7 @@ static target_long expr_unary(void)
expr_error("invalid char in expression");
}
pch = p;
- while (isspace(*pch))
+ while (isspace((uint8_t)*pch))
pch++;
break;
}
@@ -1874,7 +1874,7 @@ static int get_expr(target_long *pval, const char **pp)
*pp = pch;
return -1;
}
- while (isspace(*pch))
+ while (isspace((uint8_t)*pch))
pch++;
*pval = expr_sum();
*pp = pch;
@@ -1890,7 +1890,7 @@ static int get_str(char *buf, int buf_size, const char **pp)
q = buf;
p = *pp;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*p == '\0') {
fail:
@@ -1935,7 +1935,7 @@ static int get_str(char *buf, int buf_size, const char **pp)
}
p++;
} else {
- while (*p != '\0' && !isspace(*p)) {
+ while (*p != '\0' && !isspace((uint8_t)*p)) {
if ((q - buf) < buf_size - 1) {
*q++ = *p;
}
@@ -1975,12 +1975,12 @@ static void monitor_handle_command(const char *cmdline)
/* extract the command name */
p = cmdline;
q = cmdname;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*p == '\0')
return;
pstart = p;
- while (*p != '\0' && *p != '/' && !isspace(*p))
+ while (*p != '\0' && *p != '/' && !isspace((uint8_t)*p))
p++;
len = p - pstart;
if (len > sizeof(cmdname) - 1)
@@ -2016,7 +2016,7 @@ static void monitor_handle_command(const char *cmdline)
int ret;
char *str;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*typestr == '?') {
typestr++;
@@ -2058,15 +2058,15 @@ static void monitor_handle_command(const char *cmdline)
{
int count, format, size;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*p == '/') {
/* format found */
p++;
count = 1;
- if (isdigit(*p)) {
+ if (isdigit((uint8_t)*p)) {
count = 0;
- while (isdigit(*p)) {
+ while (isdigit((uint8_t)*p)) {
count = count * 10 + (*p - '0');
p++;
}
@@ -2105,7 +2105,7 @@ static void monitor_handle_command(const char *cmdline)
}
}
next:
- if (*p != '\0' && !isspace(*p)) {
+ if (*p != '\0' && !isspace((uint8_t)*p)) {
term_printf("invalid char in format: '%c'\n", *p);
goto fail;
}
@@ -2138,7 +2138,7 @@ static void monitor_handle_command(const char *cmdline)
case 'l':
{
target_long val;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*typestr == '?' || *typestr == '.') {
if (*typestr == '?') {
@@ -2149,7 +2149,7 @@ static void monitor_handle_command(const char *cmdline)
} else {
if (*p == '.') {
p++;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
has_arg = 1;
} else {
@@ -2195,7 +2195,7 @@ static void monitor_handle_command(const char *cmdline)
c = *typestr++;
if (c == '\0')
goto bad_type;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
has_option = 0;
if (*p == '-') {
@@ -2225,7 +2225,7 @@ static void monitor_handle_command(const char *cmdline)
}
}
/* check that all arguments were parsed */
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*p != '\0') {
term_printf("%s: extraneous characters at the end of line\n",
@@ -2364,7 +2364,7 @@ static void parse_cmdline(const char *cmdline,
p = cmdline;
nb_args = 0;
for(;;) {
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*p == '\0')
break;
@@ -2398,7 +2398,7 @@ void readline_find_completion(const char *cmdline)
/* if the line ends with a space, it means we want to complete the
next arg */
len = strlen(cmdline);
- if (len > 0 && isspace(cmdline[len - 1])) {
+ if (len > 0 && isspace((uint8_t)cmdline[len - 1])) {
if (nb_args >= MAX_ARGS)
return;
args[nb_args++] = qemu_strdup("");
diff --git a/tools/ioemu/osdep.h b/tools/ioemu/osdep.h
index 325baf14eb..bd6ffc1713 100644
--- a/tools/ioemu/osdep.h
+++ b/tools/ioemu/osdep.h
@@ -2,6 +2,10 @@
#define QEMU_OSDEP_H
#include <stdarg.h>
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <sys/signal.h>
+#endif
#define qemu_printf printf
diff --git a/tools/ioemu/target-i386-dm/exec-dm.c b/tools/ioemu/target-i386-dm/exec-dm.c
index b67c55414d..f7525b1f20 100644
--- a/tools/ioemu/target-i386-dm/exec-dm.c
+++ b/tools/ioemu/target-i386-dm/exec-dm.c
@@ -168,8 +168,8 @@ void cpu_set_log_filename(const char *filename)
#else
setvbuf(logfile, NULL, _IOLBF, 0);
#endif
- stdout = logfile;
- stderr = logfile;
+ dup2(fileno(logfile), 1);
+ dup2(fileno(logfile), 2);
}
/* mask must never be zero, except for A20 change call */
diff --git a/tools/ioemu/usb-linux.c b/tools/ioemu/usb-linux.c
index d0a75d8cdc..b757066ae6 100644
--- a/tools/ioemu/usb-linux.c
+++ b/tools/ioemu/usb-linux.c
@@ -268,7 +268,7 @@ static int get_tag_value(char *buf, int buf_size,
if (!p)
return -1;
p += strlen(tag);
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
q = buf;
while (*p != '\0' && !strchr(stopchars, *p)) {
diff --git a/tools/ioemu/vl.c b/tools/ioemu/vl.c
index a6d0b948f2..369769090a 100644
--- a/tools/ioemu/vl.c
+++ b/tools/ioemu/vl.c
@@ -24,6 +24,7 @@
#include "vl.h"
#include <unistd.h>
+#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
@@ -38,22 +39,29 @@
#include <sys/poll.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
+#include <sys/resource.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <net/if.h>
+#if defined(__NetBSD__)
+#include <net/if_tap.h>
+#endif
+#if defined(__linux__) || defined(__Linux__)
+#include <linux/if_tun.h>
+#endif
#include <arpa/inet.h>
#include <dirent.h>
#include <netdb.h>
#ifdef _BSD
#include <sys/stat.h>
-#ifndef __APPLE__
+#ifndef _BSD
#include <libutil.h>
+#else
+#include <util.h>
#endif
#else
#ifndef __sun__
-#include <linux/if.h>
-#include <linux/if_tun.h>
#include <pty.h>
-#include <malloc.h>
#include <linux/rtc.h>
#include <linux/ppdev.h>
#endif
@@ -65,7 +73,6 @@
#endif
#ifdef _WIN32
-#include <malloc.h>
#include <sys/timeb.h>
#include <windows.h>
#define getopt_long_only getopt_long
@@ -91,7 +98,11 @@
#include <xen/hvm/params.h>
#define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup"
+#ifdef _BSD
+#define DEFAULT_BRIDGE "bridge0"
+#else
#define DEFAULT_BRIDGE "xenbr0"
+#endif
#ifdef __sun__
#define SMBD_COMMAND "/usr/sfw/sbin/smbd"
#else
@@ -1794,7 +1805,7 @@ static int store_dev_info(char *devName, int domid,
return 0;
}
-#if defined(__linux__)
+#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
static CharDriverState *qemu_chr_open_pty(void)
{
struct termios tty;
@@ -1949,6 +1960,7 @@ static CharDriverState *qemu_chr_open_tty(const char *filename)
return chr;
}
+#if defined(__linux__)
static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
{
int fd = (int)chr->opaque;
@@ -2013,13 +2025,14 @@ static CharDriverState *qemu_chr_open_pp(const char *filename)
return chr;
}
+#endif /* __linux__ */
#else
static CharDriverState *qemu_chr_open_pty(void)
{
return NULL;
}
-#endif
+#endif /* __linux__ || __NetBSD__ || __OpenBSD__ */
#endif /* !defined(_WIN32) */
@@ -2958,7 +2971,7 @@ static int parse_macaddr(uint8_t *macaddr, const char *p)
return 0;
}
-static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
+static int get_str_sep(char *buf, size_t buf_size, const char **pp, int sep)
{
const char *p, *p1;
int len;
@@ -3031,7 +3044,7 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str)
if (buf[0] == '\0') {
saddr->sin_addr.s_addr = 0;
} else {
- if (isdigit(buf[0])) {
+ if (isdigit((uint8_t)buf[0])) {
if (!inet_aton(buf, &saddr->sin_addr))
return -1;
} else {
@@ -3373,18 +3386,30 @@ static TAPState *net_tap_fd_init(VLANState *vlan, int fd)
static int tap_open(char *ifname, int ifname_size)
{
int fd;
+#ifndef TAPGIFNAME
char *dev;
struct stat s;
+#endif
+ struct ifreq ifr;
fd = open("/dev/tap", O_RDWR);
if (fd < 0) {
- fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
+ fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation %s\n", strerror(errno));
return -1;
}
+#ifdef TAPGIFNAME
+ if (ioctl (fd, TAPGIFNAME, (void*)&ifr) < 0) {
+ fprintf(stderr, "warning: could not open get tap name: %s\n",
+ strerror(errno));
+ return -1;
+ }
+ pstrcpy(ifname, ifname_size, ifr.ifr_name);
+#else
fstat(fd, &s);
dev = devname(s.st_rdev, S_IFCHR);
pstrcpy(ifname, ifname_size, dev);
+#endif
fcntl(fd, F_SETFL, O_NONBLOCK);
return fd;
@@ -3435,6 +3460,8 @@ static int net_tap_init(VLANState *vlan, const char *ifname1,
char **parg;
char ifname[128];
+ memset(ifname, 0, sizeof(ifname));
+
if (ifname1 != NULL)
pstrcpy(ifname, sizeof(ifname), ifname1);
else
@@ -3611,7 +3638,7 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr)
val = 1;
ret=setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
- (const char *)&val, sizeof(val));
+ (const char *)&val, sizeof(char));
if (ret < 0) {
perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)");
goto fail;
@@ -3893,7 +3920,7 @@ static int net_socket_mcast_init(VLANState *vlan, const char *host_str)
}
-static int get_param_value(char *buf, int buf_size,
+static int get_param_value(char *buf, size_t buf_size,
const char *tag, const char *str)
{
const char *p;
@@ -4019,6 +4046,10 @@ static int net_client_init(const char *str)
char setup_script[1024];
char bridge[16];
int fd;
+
+ memset(ifname, 0, sizeof(ifname));
+ memset(setup_script, 0, sizeof(setup_script));
+
if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {
fd = strtol(buf, NULL, 0);
ret = -1;
@@ -6914,7 +6945,6 @@ static int qemu_map_cache_init(void)
nr_buckets = (((MAX_MCACHE_SIZE >> PAGE_SHIFT) +
(1UL << (MCACHE_BUCKET_SHIFT - PAGE_SHIFT)) - 1) >>
(MCACHE_BUCKET_SHIFT - PAGE_SHIFT));
- fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx\n", nr_buckets);
/*
* Use mmap() directly: lets us allocate a big hash table with no up-front
@@ -6923,8 +6953,9 @@ static int qemu_map_cache_init(void)
*/
size = nr_buckets * sizeof(struct map_cache);
size = (size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+ fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx size %lu\n", nr_buckets, size);
mapcache_entry = mmap(NULL, size, PROT_READ|PROT_WRITE,
- MAP_SHARED|MAP_ANONYMOUS, 0, 0);
+ MAP_SHARED|MAP_ANON, -1, 0);
if (mapcache_entry == MAP_FAILED) {
errno = ENOMEM;
return -1;
@@ -7061,6 +7092,7 @@ int main(int argc, char **argv)
unsigned long ioreq_pfn;
extern void *shared_page;
extern void *buffered_io_page;
+ struct rlimit rl;
#ifdef __ia64__
unsigned long nr_pages;
xen_pfn_t *page_array;
@@ -7070,6 +7102,30 @@ int main(int argc, char **argv)
char qemu_dm_logfilename[128];
const char *direct_pci = NULL;
+ /* Maximise rlimits. Needed where default constraints are tight (*BSD). */
+ if (getrlimit(RLIMIT_STACK, &rl) != 0) {
+ perror("getrlimit(RLIMIT_STACK)");
+ exit(1);
+ }
+ rl.rlim_cur = rl.rlim_max;
+ if (setrlimit(RLIMIT_STACK, &rl) != 0)
+ perror("setrlimit(RLIMIT_STACK)");
+ if (getrlimit(RLIMIT_DATA, &rl) != 0) {
+ perror("getrlimit(RLIMIT_DATA)");
+ exit(1);
+ }
+ rl.rlim_cur = rl.rlim_max;
+ if (setrlimit(RLIMIT_DATA, &rl) != 0)
+ perror("setrlimit(RLIMIT_DATA)");
+ rl.rlim_cur = RLIM_INFINITY;
+ rl.rlim_max = RLIM_INFINITY;
+ if (setrlimit(RLIMIT_RSS, &rl) != 0)
+ perror("setrlimit(RLIMIT_RSS)");
+ rl.rlim_cur = RLIM_INFINITY;
+ rl.rlim_max = RLIM_INFINITY;
+ if (setrlimit(RLIMIT_MEMLOCK, &rl) != 0)
+ perror("setrlimit(RLIMIT_MEMLOCK)");
+
/* Ensure that SIGUSR2 is blocked by default when a new thread is created,
then only the threads that use the signal unblock it -- this fixes a
race condition in Qcow support where the AIO signal is misdelivered. */
diff --git a/tools/ioemu/vl.h b/tools/ioemu/vl.h
index 7b4cff58a9..b087e20c00 100644
--- a/tools/ioemu/vl.h
+++ b/tools/ioemu/vl.h
@@ -103,8 +103,8 @@ static inline char *realpath(const char *path, char *resolved_path)
#endif
/* cutils.c */
-void pstrcpy(char *buf, int buf_size, const char *str);
-char *pstrcat(char *buf, int buf_size, const char *s);
+void pstrcpy(char *buf, size_t buf_size, const char *str);
+char *pstrcat(char *buf, size_t buf_size, const char *s);
int strstart(const char *str, const char *val, const char **ptr);
int stristart(const char *str, const char *val, const char **ptr);
diff --git a/tools/ioemu/vnc.c b/tools/ioemu/vnc.c
index 0473042820..ca697e64d2 100644
--- a/tools/ioemu/vnc.c
+++ b/tools/ioemu/vnc.c
@@ -24,6 +24,9 @@
* THE SOFTWARE.
*/
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include "vl.h"
#include "qemu_socket.h"
#include <assert.h>