Files
pkgsrc-ng/sysutils/xentools3-hvm/patches/patch-ar
2013-09-26 17:14:40 +02:00

179 lines
4.9 KiB
Plaintext

$NetBSD: patch-ar,v 1.2 2009/10/18 21:28:10 bouyer Exp $
--- ioemu/vl.c.orig 2008-04-25 15:03:12.000000000 +0200
+++ ioemu/vl.c 2009-10-18 22:22:56.000000000 +0200
@@ -37,14 +37,17 @@
#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>
+#include <net/if_tap.h>
#include <arpa/inet.h>
#include <dirent.h>
#include <netdb.h>
#ifdef _BSD
#include <sys/stat.h>
-#ifndef __APPLE__
+#ifndef _BSD
#include <libutil.h>
#endif
#else
@@ -89,8 +92,8 @@
#include "exec-all.h"
#include <xen/hvm/params.h>
-#define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup"
-#define DEFAULT_BRIDGE "xenbr0"
+#define DEFAULT_NETWORK_SCRIPT "@XENDCONFDIR@/scripts/qemu-ifup"
+#define DEFAULT_BRIDGE "bridge0"
//#define DEBUG_UNUSED_IOPORT
//#define DEBUG_IOPORT
@@ -1683,7 +1686,7 @@
return 0;
}
-#if defined(__linux__)
+#if defined(__linux__) || defined(__NetBSD__)
CharDriverState *qemu_chr_open_pty(void)
{
struct termios tty;
@@ -1696,7 +1699,12 @@
/* Set raw attributes on the pty. */
cfmakeraw(&tty);
+#if defined(__NetBSD__)
+ tcsetattr(master_fd, TCSAFLUSH, &tty);
+ close(slave_fd);
+#else
tcsetattr(slave_fd, TCSAFLUSH, &tty);
+#endif
fprintf(stderr, "char device redirected to %s\n", ptsname(master_fd));
@@ -1834,7 +1842,7 @@
chr->chr_ioctl = tty_serial_ioctl;
return chr;
}
-
+#if defined(__linux__)
static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
{
int fd = (int)chr->opaque;
@@ -1897,13 +1905,14 @@
chr->chr_ioctl = pp_ioctl;
return chr;
}
+#endif /* __linux__ */
#else
CharDriverState *qemu_chr_open_pty(void)
{
return NULL;
}
-#endif
+#endif /* __linux__ || __NetBSD__ */
#endif /* !defined(_WIN32) */
@@ -3146,7 +3155,7 @@
fclose(f);
atexit(smb_exit);
- snprintf(smb_cmdline, sizeof(smb_cmdline), "/usr/sbin/smbd -s %s",
+ snprintf(smb_cmdline, sizeof(smb_cmdline), "@PREFIX@/sbin/smbd -s %s",
smb_conf);
slirp_add_exec(0, smb_cmdline, 4, 139);
@@ -3210,16 +3219,26 @@
int fd;
char *dev;
struct stat s;
+ 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;
@@ -5972,7 +5991,6 @@
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
@@ -5981,8 +5999,9 @@
*/
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_ANONYMOUS, -1, 0);
if (mapcache_entry == MAP_FAILED) {
errno = ENOMEM;
return -1;
@@ -6119,6 +6138,7 @@
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;
@@ -6127,6 +6147,32 @@
char qemu_dm_logfilename[64];
+ /* XXX required for now */
+ if (setenv("PTHREAD_DIAGASSERT", "A", 1) != 0)
+ perror("setenv");
+ 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)");
+
LIST_INIT (&vm_change_state_head);
#ifndef _WIN32
{