1 $NetBSD: patch-ar,v 1.1.1.1 2007/06/14 19:42:12 bouyer Exp $
3 --- ioemu/vl.c.orig 2008-04-25 15:03:12.000000000 +0200
4 +++ ioemu/vl.c 2009-10-18 22:22:56.000000000 +0200
9 +#include <sys/resource.h>
10 #include <sys/socket.h>
11 #include <netinet/in.h>
13 +#include <net/if_tap.h>
14 #include <arpa/inet.h>
27 #include <xen/hvm/params.h>
28 -#define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup"
29 -#define DEFAULT_BRIDGE "xenbr0"
30 +#define DEFAULT_NETWORK_SCRIPT "@XENDCONFDIR@/scripts/qemu-ifup"
31 +#define DEFAULT_BRIDGE "bridge0"
33 //#define DEBUG_UNUSED_IOPORT
34 //#define DEBUG_IOPORT
39 -#if defined(__linux__)
40 +#if defined(__linux__) || defined(__NetBSD__)
41 CharDriverState *qemu_chr_open_pty(void)
44 @@ -1696,7 +1699,12 @@
46 /* Set raw attributes on the pty. */
48 +#if defined(__NetBSD__)
49 + tcsetattr(master_fd, TCSAFLUSH, &tty);
52 tcsetattr(slave_fd, TCSAFLUSH, &tty);
55 fprintf(stderr, "char device redirected to %s\n", ptsname(master_fd));
58 chr->chr_ioctl = tty_serial_ioctl;
62 +#if defined(__linux__)
63 static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
65 int fd = (int)chr->opaque;
66 @@ -1897,13 +1905,14 @@
67 chr->chr_ioctl = pp_ioctl;
70 +#endif /* __linux__ */
73 CharDriverState *qemu_chr_open_pty(void)
78 +#endif /* __linux__ || __NetBSD__ */
80 #endif /* !defined(_WIN32) */
86 - snprintf(smb_cmdline, sizeof(smb_cmdline), "/usr/sbin/smbd -s %s",
87 + snprintf(smb_cmdline, sizeof(smb_cmdline), "@PREFIX@/sbin/smbd -s %s",
90 slirp_add_exec(0, smb_cmdline, 4, 139);
91 @@ -3210,16 +3219,26 @@
97 fd = open("/dev/tap", O_RDWR);
99 - fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
100 + fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation: %s\n", strerror(errno));
105 + if (ioctl (fd, TAPGIFNAME, (void*)&ifr) < 0) {
106 + fprintf(stderr, "warning: could not open get tap name: %s\n",
110 + pstrcpy(ifname, ifname_size, ifr.ifr_name);
113 dev = devname(s.st_rdev, S_IFCHR);
114 pstrcpy(ifname, ifname_size, dev);
117 fcntl(fd, F_SETFL, O_NONBLOCK);
119 @@ -5972,7 +5991,6 @@
120 nr_buckets = (((MAX_MCACHE_SIZE >> PAGE_SHIFT) +
121 (1UL << (MCACHE_BUCKET_SHIFT - PAGE_SHIFT)) - 1) >>
122 (MCACHE_BUCKET_SHIFT - PAGE_SHIFT));
123 - fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx\n", nr_buckets);
126 * Use mmap() directly: lets us allocate a big hash table with no up-front
127 @@ -5981,8 +5999,9 @@
129 size = nr_buckets * sizeof(struct map_cache);
130 size = (size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
131 + fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx size %lu\n", nr_buckets, size);
132 mapcache_entry = mmap(NULL, size, PROT_READ|PROT_WRITE,
133 - MAP_SHARED|MAP_ANONYMOUS, 0, 0);
134 + MAP_SHARED|MAP_ANONYMOUS, -1, 0);
135 if (mapcache_entry == MAP_FAILED) {
138 @@ -6119,6 +6138,7 @@
139 unsigned long ioreq_pfn;
140 extern void *shared_page;
141 extern void *buffered_io_page;
144 unsigned long nr_pages;
145 xen_pfn_t *page_array;
146 @@ -6127,6 +6147,32 @@
148 char qemu_dm_logfilename[64];
150 + /* XXX required for now */
151 + if (setenv("PTHREAD_DIAGASSERT", "A", 1) != 0)
153 + if (getrlimit(RLIMIT_STACK, &rl) != 0) {
154 + perror("getrlimit(RLIMIT_STACK)");
157 + rl.rlim_cur = rl.rlim_max;
158 + if (setrlimit(RLIMIT_STACK, &rl) != 0)
159 + perror("setrlimit(RLIMIT_STACK)");
160 + if (getrlimit(RLIMIT_DATA, &rl) != 0) {
161 + perror("getrlimit(RLIMIT_DATA)");
164 + rl.rlim_cur = rl.rlim_max;
165 + if (setrlimit(RLIMIT_DATA, &rl) != 0)
166 + perror("setrlimit(RLIMIT_DATA)");
167 + rl.rlim_cur = RLIM_INFINITY;
168 + rl.rlim_max = RLIM_INFINITY;
169 + if (setrlimit(RLIMIT_RSS, &rl) != 0)
170 + perror("setrlimit(RLIMIT_RSS)");
171 + rl.rlim_cur = RLIM_INFINITY;
172 + rl.rlim_max = RLIM_INFINITY;
173 + if (setrlimit(RLIMIT_MEMLOCK, &rl) != 0)
174 + perror("setrlimit(RLIMIT_MEMLOCK)");
176 LIST_INIT (&vm_change_state_head);