{
if (pch != '\0') {
pch++;
- while (isspace(*pch))
+ while (isspace((uint8_t)*pch))
pch++;
}
}
*q++ = *pch;
pch++;
}
- while (isspace(*pch))
+ while (isspace((uint8_t)*pch))
pch++;
*q = 0;
ret = get_monitor_def(&n, buf);
expr_error("invalid char in expression");
}
pch = p;
- while (isspace(*pch))
+ while (isspace((uint8_t)*pch))
pch++;
break;
}
*pp = pch;
return -1;
}
- while (isspace(*pch))
+ while (isspace((uint8_t)*pch))
pch++;
*pval = expr_sum();
*pp = pch;
q = buf;
p = *pp;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*p == '\0') {
fail:
}
p++;
} else {
- while (*p != '\0' && !isspace(*p)) {
+ while (*p != '\0' && !isspace((uint8_t)*p)) {
if ((q - buf) < buf_size - 1) {
*q++ = *p;
}
/* 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)
int ret;
char *str;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*typestr == '?') {
typestr++;
{
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++;
}
}
}
next:
- if (*p != '\0' && !isspace(*p)) {
+ if (*p != '\0' && !isspace((uint8_t)*p)) {
term_printf("invalid char in format: '%c'\n", *p);
goto fail;
}
case 'l':
{
target_long val;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*typestr == '?' || *typestr == '.') {
if (*typestr == '?') {
} else {
if (*p == '.') {
p++;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
has_arg = 1;
} else {
c = *typestr++;
if (c == '\0')
goto bad_type;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
has_option = 0;
if (*p == '-') {
}
}
/* 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",
p = cmdline;
nb_args = 0;
for(;;) {
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*p == '\0')
break;
/* 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("");
#include "vl.h"
#include <unistd.h>
+#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#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
#endif
#ifdef _WIN32
-#include <malloc.h>
#include <sys/timeb.h>
#include <windows.h>
#define getopt_long_only getopt_long
#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
return 0;
}
-#if defined(__linux__)
+#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
static CharDriverState *qemu_chr_open_pty(void)
{
struct termios tty;
return chr;
}
+#if defined(__linux__)
static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
{
int fd = (int)chr->opaque;
return chr;
}
+#endif /* __linux__ */
#else
static CharDriverState *qemu_chr_open_pty(void)
{
return NULL;
}
-#endif
+#endif /* __linux__ || __NetBSD__ || __OpenBSD__ */
#endif /* !defined(_WIN32) */
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;
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 {
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;
char **parg;
char ifname[128];
+ memset(ifname, 0, sizeof(ifname));
+
if (ifname1 != NULL)
pstrcpy(ifname, sizeof(ifname), ifname1);
else
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;
}
-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;
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;
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
*/
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;
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;
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. */