Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / sysutils / xentools3-hvm / patches / patch-ar
blobec57cd497064bdbd90d7e3183a58dfbbf1ebc37a
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
5 @@ -37,14 +37,17 @@
6  #include <sys/poll.h>
7  #include <sys/mman.h>
8  #include <sys/ioctl.h>
9 +#include <sys/resource.h>
10  #include <sys/socket.h>
11  #include <netinet/in.h>
12 +#include <net/if.h>
13 +#include <net/if_tap.h>
14  #include <arpa/inet.h>
15  #include <dirent.h>
16  #include <netdb.h>
17  #ifdef _BSD
18  #include <sys/stat.h>
19 -#ifndef __APPLE__
20 +#ifndef _BSD
21  #include <libutil.h>
22  #endif
23  #else
24 @@ -89,8 +92,8 @@
25  #include "exec-all.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
35 @@ -1683,7 +1686,7 @@
36      return 0;
37  }
39 -#if defined(__linux__)
40 +#if defined(__linux__) || defined(__NetBSD__)
41  CharDriverState *qemu_chr_open_pty(void)
42  {
43      struct termios tty;
44 @@ -1696,7 +1699,12 @@
45      
46      /* Set raw attributes on the pty. */
47      cfmakeraw(&tty);
48 +#if defined(__NetBSD__)
49 +    tcsetattr(master_fd, TCSAFLUSH, &tty);
50 +    close(slave_fd);
51 +#else
52      tcsetattr(slave_fd, TCSAFLUSH, &tty);
53 +#endif
54      
55      fprintf(stderr, "char device redirected to %s\n", ptsname(master_fd));
57 @@ -1834,7 +1842,7 @@
58      chr->chr_ioctl = tty_serial_ioctl;
59      return chr;
60  }
62 +#if defined(__linux__)
63  static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
64  {
65      int fd = (int)chr->opaque;
66 @@ -1897,13 +1905,14 @@
67      chr->chr_ioctl = pp_ioctl;
68      return chr;
69  }
70 +#endif /* __linux__ */
72  #else
73  CharDriverState *qemu_chr_open_pty(void)
74  {
75      return NULL;
76  }
77 -#endif
78 +#endif /* __linux__ || __NetBSD__ */
80  #endif /* !defined(_WIN32) */
82 @@ -3146,7 +3155,7 @@
83      fclose(f);
84      atexit(smb_exit);
86 -    snprintf(smb_cmdline, sizeof(smb_cmdline), "/usr/sbin/smbd -s %s",
87 +    snprintf(smb_cmdline, sizeof(smb_cmdline), "@PREFIX@/sbin/smbd -s %s",
88               smb_conf);
89      
90      slirp_add_exec(0, smb_cmdline, 4, 139);
91 @@ -3210,16 +3219,26 @@
92      int fd;
93      char *dev;
94      struct stat s;
95 +    struct ifreq ifr;
97      fd = open("/dev/tap", O_RDWR);
98      if (fd < 0) {
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));
101          return -1;
102      }
104 +#ifdef TAPGIFNAME
105 +    if (ioctl (fd, TAPGIFNAME, (void*)&ifr) < 0) {
106 +       fprintf(stderr, "warning: could not open get tap name: %s\n",
107 +           strerror(errno));
108 +       return -1;
109 +    }
110 +    pstrcpy(ifname, ifname_size, ifr.ifr_name);
111 +#else
112      fstat(fd, &s);
113      dev = devname(s.st_rdev, S_IFCHR);
114      pstrcpy(ifname, ifname_size, dev);
115 +#endif
117      fcntl(fd, F_SETFL, O_NONBLOCK);
118      return fd;
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);
125      /*
126       * Use mmap() directly: lets us allocate a big hash table with no up-front
127 @@ -5981,8 +5999,9 @@
128       */
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) {
136          errno = ENOMEM;
137          return -1;
138 @@ -6119,6 +6138,7 @@
139      unsigned long ioreq_pfn;
140      extern void *shared_page;
141      extern void *buffered_io_page;
142 +    struct rlimit rl;
143  #ifdef __ia64__
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)
152 +       perror("setenv");
153 +    if (getrlimit(RLIMIT_STACK, &rl) != 0) {
154 +       perror("getrlimit(RLIMIT_STACK)");
155 +       exit(1);
156 +    }
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)");
162 +       exit(1);
163 +    }
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);
177  #ifndef _WIN32
178      {