* [PATCH][TOOLS] ioemu: Build fixes for BSD and bug fixes from BSD
@ 2007-09-27 11:35 Christoph Egger
2007-09-27 14:19 ` Keir Fraser
2007-09-27 15:39 ` Keir Fraser
0 siblings, 2 replies; 6+ messages in thread
From: Christoph Egger @ 2007-09-27 11:35 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: Type: text/plain, Size: 696 bytes --]
Hi!
Attached patch makes ioemu build on *BSD.
It also applies bug fixes from *BSD for Linux and *BSD :-)
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
P.S.: Could someone with contact to qemu people make this patch
go upstream to qemu, please?
--
AMD Saxony, Dresden, Germany
Operating System Research Center
Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
Dr. Hans-R. Deppe, Thomas McCoy
[-- Attachment #2: tools_ioemu.diff --]
[-- Type: text/plain, Size: 20898 bytes --]
diff -r 0b04a48f65cc tools/ioemu/aes.c
--- a/tools/ioemu/aes.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/aes.c Thu Sep 27 11:50:43 2007 +0000
@@ -30,7 +30,9 @@
#include "vl.h"
#include "aes.h"
+#ifndef NDEBUG
#define NDEBUG
+#endif
#include <assert.h>
typedef uint32_t u32;
diff -r 0b04a48f65cc tools/ioemu/audio/audio.c
--- a/tools/ioemu/audio/audio.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/audio/audio.c Thu Sep 27 11:50:43 2007 +0000
@@ -207,7 +207,7 @@ static char *audio_alloc_prefix (const c
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
/* 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 -r 0b04a48f65cc tools/ioemu/audio/mixeng.c
--- a/tools/ioemu/audio/mixeng.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/audio/mixeng.c Thu Sep 27 11:50:43 2007 +0000
@@ -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 -r 0b04a48f65cc tools/ioemu/audio/ossaudio.c
--- a/tools/ioemu/audio/ossaudio.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/audio/ossaudio.c Thu Sep 27 11:50:43 2007 +0000
@@ -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_
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 -r 0b04a48f65cc tools/ioemu/block-qcow2.c
--- a/tools/ioemu/block-qcow2.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/block-qcow2.c Thu Sep 27 11:50:43 2007 +0000
@@ -1884,6 +1884,8 @@ static int grow_refcount_table(BlockDriv
int new_table_size, new_table_size2, refcount_table_clusters, i, ret;
uint64_t *new_table;
int64_t table_offset;
+ int old_table_size;
+ int64_t old_table_offset;
uint64_t data64;
uint32_t data32;
@@ -1931,10 +1933,14 @@ static int grow_refcount_table(BlockDriv
&data32, sizeof(data32)) != sizeof(data32))
goto fail;
qemu_free(s->refcount_table);
+ old_table_offset = s->refcount_table_offset;
+ old_table_size = s->refcount_table_size;
s->refcount_table = new_table;
s->refcount_table_size = new_table_size;
+ s->refcount_table_offset = table_offset;
update_refcount(bs, table_offset, new_table_size2, 1);
+ free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
return 0;
fail:
free_clusters(bs, table_offset, new_table_size2);
diff -r 0b04a48f65cc tools/ioemu/block-raw.c
--- a/tools/ioemu/block-raw.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/block-raw.c Thu Sep 27 11:50:43 2007 +0000
@@ -53,8 +53,13 @@
#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
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(BlockDrive
}
return size;
}
+#endif
static int raw_create(const char *filename, int64_t total_size,
const char *backing_file, int flags)
diff -r 0b04a48f65cc tools/ioemu/block-vvfat.c
--- a/tools/ioemu/block-vvfat.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/block-vvfat.c Thu Sep 27 11:50:43 2007 +0000
@@ -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 -r 0b04a48f65cc tools/ioemu/bswap.h
--- a/tools/ioemu/bswap.h Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/bswap.h Thu Sep 27 11:50:43 2007 +0000
@@ -4,6 +4,11 @@
#include "config-host.h"
#include <inttypes.h>
+
+#ifdef _BSD
+#include <sys/endian.h>
+#include <sys/types.h>
+#else
#ifdef HAVE_BYTESWAP_H
#include <byteswap.h>
@@ -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 -r 0b04a48f65cc tools/ioemu/cpu-all.h
--- a/tools/ioemu/cpu-all.h Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/cpu-all.h Thu Sep 27 11:50:43 2007 +0000
@@ -1010,13 +1010,22 @@ static inline int64_t cpu_get_real_ticks
#endif
}
#else
-/* The host CPU doesn't have an easily accessible cycle counter.
- Just return a monotonically increasing vlue. This will be totally wrong,
- but hopefully better than nothing. */
+
+#include <sys/time.h>
+#include <time.h>
+
static inline int64_t cpu_get_real_ticks (void)
{
- static int64_t ticks = 0;
- return ticks++;
+ struct timeval tv;
+ static int64_t i = 0;
+ int64_t j;
+
+ gettimeofday(&tv, NULL);
+ do {
+ j = (tv.tv_sec * (uint64_t) 1000000) + tv.tv_usec;
+ } while (i == j);
+ i = j;
+ return j;
}
#endif
diff -r 0b04a48f65cc tools/ioemu/cutils.c
--- a/tools/ioemu/cutils.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/cutils.c Thu Sep 27 11:50:43 2007 +0000
@@ -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, co
}
/* 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 cha
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 -r 0b04a48f65cc tools/ioemu/dis-asm.h
--- a/tools/ioemu/dis-asm.h Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/dis-asm.h Thu Sep 27 11:50:43 2007 +0000
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
+#include "config.h"
#define PARAMS(x) x
typedef void *PTR;
diff -r 0b04a48f65cc tools/ioemu/hw/acpi.c
--- a/tools/ioemu/hw/acpi.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/hw/acpi.c Thu Sep 27 11:50:43 2007 +0000
@@ -473,7 +473,7 @@ void piix4_pm_init(PCIBus *bus, int devf
{
PIIX4PMState *s;
uint8_t *pci_conf;
- uint32_t pm_io_base, smb_io_base;
+ uint32_t smb_io_base;
s = (PIIX4PMState *)pci_register_device(bus,
"PM", sizeof(PIIX4PMState),
diff -r 0b04a48f65cc tools/ioemu/hw/fdc.c
--- a/tools/ioemu/hw/fdc.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/hw/fdc.c Thu Sep 27 11:50:43 2007 +0000
@@ -176,7 +176,7 @@ typedef struct fd_format_t {
uint8_t last_sect;
uint8_t max_track;
uint8_t max_head;
- const unsigned char *str;
+ const char *str;
} fd_format_t;
static fd_format_t fd_formats[] = {
diff -r 0b04a48f65cc tools/ioemu/hw/ne2000.c
--- a/tools/ioemu/hw/ne2000.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/hw/ne2000.c Thu Sep 27 11:50:43 2007 +0000
@@ -207,7 +207,7 @@ static int ne2000_buffer_full(NE2000Stat
index = s->curpag << 8;
boundary = s->boundary << 8;
- if (index <= boundary)
+ if (index < boundary)
avail = boundary - index;
else
avail = (s->stop - s->start) - (index - boundary);
diff -r 0b04a48f65cc tools/ioemu/hw/pc.c
--- a/tools/ioemu/hw/pc.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/hw/pc.c Thu Sep 27 11:50:43 2007 +0000
@@ -480,7 +480,9 @@ static void pc_init1(uint64_t ram_size,
int piix3_devfn = -1;
CPUState *env;
NICInfo *nd;
+#ifdef CONFIG_PASSTHROUGH
int rc;
+#endif
linux_boot = (kernel_filename != NULL);
@@ -782,7 +784,7 @@ static void pc_init1(uint64_t ram_size,
#if 0
/* ??? Need to figure out some way for the user to
specify SCSI devices. */
- if (pci_enabled) {
+ if (pci_enabled && scsi_enabled) {
void *scsi;
BlockDriverState *bdrv;
diff -r 0b04a48f65cc tools/ioemu/monitor.c
--- a/tools/ioemu/monitor.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/monitor.c Thu Sep 27 11:50:43 2007 +0000
@@ -1890,7 +1890,7 @@ static int get_str(char *buf, int buf_si
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_si
}
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
/* 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
int ret;
char *str;
- while (isspace(*p))
+ while (isspace((uint8_t)*p))
p++;
if (*typestr == '?') {
typestr++;
@@ -2195,7 +2195,7 @@ static void monitor_handle_command(const
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
}
}
/* 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",
diff -r 0b04a48f65cc tools/ioemu/osdep.h
--- a/tools/ioemu/osdep.h Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/osdep.h Thu Sep 27 11:50:43 2007 +0000
@@ -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 -r 0b04a48f65cc tools/ioemu/target-i386-dm/exec-dm.c
--- a/tools/ioemu/target-i386-dm/exec-dm.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/target-i386-dm/exec-dm.c Thu Sep 27 11:50:43 2007 +0000
@@ -168,8 +168,8 @@ void cpu_set_log_filename(const char *fi
#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 -r 0b04a48f65cc tools/ioemu/vl.c
--- a/tools/ioemu/vl.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/vl.c Thu Sep 27 11:50:43 2007 +0000
@@ -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,
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_tt
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
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 *macadd
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 *
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 int tap_open(char *ifname, int if
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;
@@ -3434,6 +3459,8 @@ static int net_tap_init(VLANState *vlan,
char *args[4];
char **parg;
char ifname[128];
+
+ memset(ifname, 0, sizeof(ifname));
if (ifname1 != NULL)
pstrcpy(ifname, sizeof(ifname), ifname1);
@@ -3611,7 +3638,7 @@ static int net_socket_mcast_create(struc
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(VLANSta
}
-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 *s
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;
@@ -7069,6 +7101,32 @@ int main(int argc, char **argv)
sigset_t set;
char qemu_dm_logfilename[128];
const char *direct_pci = NULL;
+
+ /* 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)");
/* 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
diff -r 0b04a48f65cc tools/ioemu/vl.h
--- a/tools/ioemu/vl.h Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/vl.h Thu Sep 27 11:50:43 2007 +0000
@@ -103,8 +103,8 @@ static inline char *realpath(const char
#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 -r 0b04a48f65cc tools/ioemu/vnc.c
--- a/tools/ioemu/vnc.c Wed Sep 26 17:11:07 2007 +0100
+++ b/tools/ioemu/vnc.c Thu Sep 27 11:50:43 2007 +0000
@@ -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>
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][TOOLS] ioemu: Build fixes for BSD and bug fixes from BSD
2007-09-27 11:35 [PATCH][TOOLS] ioemu: Build fixes for BSD and bug fixes from BSD Christoph Egger
@ 2007-09-27 14:19 ` Keir Fraser
2007-09-27 14:35 ` Christoph Egger
2007-09-27 15:39 ` Keir Fraser
1 sibling, 1 reply; 6+ messages in thread
From: Keir Fraser @ 2007-09-27 14:19 UTC (permalink / raw)
To: Christoph Egger, xen-devel
On 27/9/07 12:35, "Christoph Egger" <Christoph.Egger@amd.com> wrote:
> Attached patch makes ioemu build on *BSD.
> It also applies bug fixes from *BSD for Linux and *BSD :-)
>
> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
>
> P.S.: Could someone with contact to qemu people make this patch
> go upstream to qemu, please?
Why the setenv PTHREAD_DIAGASSERT? There is very little pthread usage at all
in ioemu. In fact basically none.
And why do you need to fiddle with {get,set}rlimit()? Is ioemu stack usage
excessive?
-- Keir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][TOOLS] ioemu: Build fixes for BSD and bug fixes from BSD
2007-09-27 14:19 ` Keir Fraser
@ 2007-09-27 14:35 ` Christoph Egger
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Egger @ 2007-09-27 14:35 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel
On Thursday 27 September 2007 16:19:42 Keir Fraser wrote:
> On 27/9/07 12:35, "Christoph Egger" <Christoph.Egger@amd.com> wrote:
> > Attached patch makes ioemu build on *BSD.
> > It also applies bug fixes from *BSD for Linux and *BSD :-)
> >
> > Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
> >
> > P.S.: Could someone with contact to qemu people make this patch
> > go upstream to qemu, please?
>
> Why the setenv PTHREAD_DIAGASSERT? There is very little pthread usage at
> all in ioemu. In fact basically none.
Oh, a debugging leftover. You may kill that.
> And why do you need to fiddle with {get,set}rlimit()? Is ioemu stack usage
> excessive?
The resource limits on BSD are more limited than on Linux.
Look:
NetBSD: ulimit -a
-----------------
time(cpu-seconds) unlimited
file(blocks) unlimited
coredump(blocks) unlimited
data(kbytes) 262144
stack(kbytes) 2048
lockedmem(kbytes) 1111329
memory(kbytes) 3333988
nofiles(descriptors) 64
processes 160
sbsize(bytes) unlimited
-----------------
OpenBSD: ulimit -a
--------------------
time(cpu-seconds) unlimited
file(blocks) unlimited
coredump(blocks) unlimited
data(kbytes) 524288
stack(kbytes) 4096
lockedmem(kbytes) 335258
memory(kbytes) 1004356
nofiles(descriptors) 128
processes 128
----------------------
Linux: ulimit -a
-----------------------
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 20
file size (blocks, -f) unlimited
pending signals (-i) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) unlimited
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) unlimited
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
-----------------------
--
AMD Saxony, Dresden, Germany
Operating System Research Center
Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
Dr. Hans-R. Deppe, Thomas McCoy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][TOOLS] ioemu: Build fixes for BSD and bug fixes from BSD
2007-09-27 11:35 [PATCH][TOOLS] ioemu: Build fixes for BSD and bug fixes from BSD Christoph Egger
2007-09-27 14:19 ` Keir Fraser
@ 2007-09-27 15:39 ` Keir Fraser
2007-09-28 8:07 ` Christoph Egger
1 sibling, 1 reply; 6+ messages in thread
From: Keir Fraser @ 2007-09-27 15:39 UTC (permalink / raw)
To: Christoph Egger, xen-devel
On 27/9/07 12:35, "Christoph Egger" <Christoph.Egger@amd.com> wrote:
> Hi!
>
> Attached patch makes ioemu build on *BSD.
> It also applies bug fixes from *BSD for Linux and *BSD :-)
>
> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
I checked in all the bits that look like they are there just to make ioemu
build and run on *BSD (that's about 90-95% of the patch). The remainder I
rejected -- that's generic bug fixes to ioemu (belongs upstream and/or as
separate patches to xen-devel) and anything that looked like it merely fixes
a build warning (we don't build ioemu with -Werror, and we tolerate build
warnings because they should really be fixed upstream first). You may want
to check that I didn't cut too hard, and resubmit a few bits.
-- Keir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][TOOLS] ioemu: Build fixes for BSD and bug fixes from BSD
2007-09-27 15:39 ` Keir Fraser
@ 2007-09-28 8:07 ` Christoph Egger
2007-09-28 10:31 ` Ian Campbell
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Egger @ 2007-09-28 8:07 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel
[-- Attachment #1: Type: text/plain, Size: 1929 bytes --]
On Thursday 27 September 2007 17:39:18 Keir Fraser wrote:
> On 27/9/07 12:35, "Christoph Egger" <Christoph.Egger@amd.com> wrote:
> > Hi!
> >
> > Attached patch makes ioemu build on *BSD.
> > It also applies bug fixes from *BSD for Linux and *BSD :-)
> >
> > Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
>
> I checked in all the bits that look like they are there just to make ioemu
> build and run on *BSD (that's about 90-95% of the patch). The remainder I
> rejected -- that's generic bug fixes to ioemu (belongs upstream and/or as
> separate patches to xen-devel) and anything that looked like it merely
> fixes a build warning (we don't build ioemu with -Werror, and we tolerate
> build warnings because they should really be fixed upstream first).
I agree with you, this also should go into qemu. But I don't have contact to
the qemu people. That's why I asked in the first signed-off mail, if there is
someone with contact to qemu.
Maybe someone from qemu is subscribed on xen-devel, so I resubmit
the remainder as separate patch.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
> You may want to check that I didn't cut too hard, and resubmit a few bits.
>
> -- Keir
I just checked. I can live with that what you committed. But I resubmit
the remainder for the case someone from qemu is on xen-devel or
someone with contact to qemu people is on xen-devel, in hope the
*full* patch goes into qemu the one or the other way.
Christoph
--
AMD Saxony, Dresden, Germany
Operating System Research Center
Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
Dr. Hans-R. Deppe, Thomas McCoy
[-- Attachment #2: tools_ioemu2.diff --]
[-- Type: text/plain, Size: 4149 bytes --]
diff -r 8817a53c030f tools/ioemu/aes.c
--- a/tools/ioemu/aes.c Thu Sep 27 18:08:11 2007 +0100
+++ b/tools/ioemu/aes.c Fri Sep 28 09:48:44 2007 +0000
@@ -30,7 +30,9 @@
#include "vl.h"
#include "aes.h"
+#ifndef NDEBUG
#define NDEBUG
+#endif
#include <assert.h>
typedef uint32_t u32;
diff -r 8817a53c030f tools/ioemu/block-qcow2.c
--- a/tools/ioemu/block-qcow2.c Thu Sep 27 18:08:11 2007 +0100
+++ b/tools/ioemu/block-qcow2.c Fri Sep 28 09:48:44 2007 +0000
@@ -1884,6 +1884,8 @@ static int grow_refcount_table(BlockDriv
int new_table_size, new_table_size2, refcount_table_clusters, i, ret;
uint64_t *new_table;
int64_t table_offset;
+ int old_table_size;
+ int64_t old_table_offset;
uint64_t data64;
uint32_t data32;
@@ -1931,10 +1933,14 @@ static int grow_refcount_table(BlockDriv
&data32, sizeof(data32)) != sizeof(data32))
goto fail;
qemu_free(s->refcount_table);
+ old_table_offset = s->refcount_table_offset;
+ old_table_size = s->refcount_table_size;
s->refcount_table = new_table;
s->refcount_table_size = new_table_size;
+ s->refcount_table_offset = table_offset;
update_refcount(bs, table_offset, new_table_size2, 1);
+ free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
return 0;
fail:
free_clusters(bs, table_offset, new_table_size2);
diff -r 8817a53c030f tools/ioemu/cpu-all.h
--- a/tools/ioemu/cpu-all.h Thu Sep 27 18:08:11 2007 +0100
+++ b/tools/ioemu/cpu-all.h Fri Sep 28 09:48:44 2007 +0000
@@ -1010,13 +1010,22 @@ static inline int64_t cpu_get_real_ticks
#endif
}
#else
-/* The host CPU doesn't have an easily accessible cycle counter.
- Just return a monotonically increasing vlue. This will be totally wrong,
- but hopefully better than nothing. */
+
+#include <sys/time.h>
+#include <time.h>
+
static inline int64_t cpu_get_real_ticks (void)
{
- static int64_t ticks = 0;
- return ticks++;
+ struct timeval tv;
+ static int64_t i = 0;
+ int64_t j;
+
+ gettimeofday(&tv, NULL);
+ do {
+ j = (tv.tv_sec * (uint64_t) 1000000) + tv.tv_usec;
+ } while (i == j);
+ i = j;
+ return j;
}
#endif
diff -r 8817a53c030f tools/ioemu/dis-asm.h
--- a/tools/ioemu/dis-asm.h Thu Sep 27 18:08:11 2007 +0100
+++ b/tools/ioemu/dis-asm.h Fri Sep 28 09:48:44 2007 +0000
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
+#include "config.h"
#define PARAMS(x) x
typedef void *PTR;
diff -r 8817a53c030f tools/ioemu/hw/acpi.c
--- a/tools/ioemu/hw/acpi.c Thu Sep 27 18:08:11 2007 +0100
+++ b/tools/ioemu/hw/acpi.c Fri Sep 28 09:48:44 2007 +0000
@@ -473,7 +473,7 @@ void piix4_pm_init(PCIBus *bus, int devf
{
PIIX4PMState *s;
uint8_t *pci_conf;
- uint32_t pm_io_base, smb_io_base;
+ uint32_t smb_io_base;
s = (PIIX4PMState *)pci_register_device(bus,
"PM", sizeof(PIIX4PMState),
diff -r 8817a53c030f tools/ioemu/hw/fdc.c
--- a/tools/ioemu/hw/fdc.c Thu Sep 27 18:08:11 2007 +0100
+++ b/tools/ioemu/hw/fdc.c Fri Sep 28 09:48:44 2007 +0000
@@ -176,7 +176,7 @@ typedef struct fd_format_t {
uint8_t last_sect;
uint8_t max_track;
uint8_t max_head;
- const unsigned char *str;
+ const char *str;
} fd_format_t;
static fd_format_t fd_formats[] = {
diff -r 8817a53c030f tools/ioemu/hw/ne2000.c
--- a/tools/ioemu/hw/ne2000.c Thu Sep 27 18:08:11 2007 +0100
+++ b/tools/ioemu/hw/ne2000.c Fri Sep 28 09:48:44 2007 +0000
@@ -207,7 +207,7 @@ static int ne2000_buffer_full(NE2000Stat
index = s->curpag << 8;
boundary = s->boundary << 8;
- if (index <= boundary)
+ if (index < boundary)
avail = boundary - index;
else
avail = (s->stop - s->start) - (index - boundary);
diff -r 8817a53c030f tools/ioemu/hw/pc.c
--- a/tools/ioemu/hw/pc.c Thu Sep 27 18:08:11 2007 +0100
+++ b/tools/ioemu/hw/pc.c Fri Sep 28 09:48:44 2007 +0000
@@ -480,7 +480,9 @@ static void pc_init1(uint64_t ram_size,
int piix3_devfn = -1;
CPUState *env;
NICInfo *nd;
+#ifdef CONFIG_PASSTHROUGH
int rc;
+#endif
linux_boot = (kernel_filename != NULL);
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][TOOLS] ioemu: Build fixes for BSD and bug fixes from BSD
2007-09-28 8:07 ` Christoph Egger
@ 2007-09-28 10:31 ` Ian Campbell
0 siblings, 0 replies; 6+ messages in thread
From: Ian Campbell @ 2007-09-28 10:31 UTC (permalink / raw)
To: Christoph Egger; +Cc: xen-devel
On Fri, 2007-09-28 at 10:07 +0200, Christoph Egger wrote:
> I agree with you, this also should go into qemu. But I don't have
> contact to the qemu people.
You could post to qemu-devel.
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Ian.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-09-28 10:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-27 11:35 [PATCH][TOOLS] ioemu: Build fixes for BSD and bug fixes from BSD Christoph Egger
2007-09-27 14:19 ` Keir Fraser
2007-09-27 14:35 ` Christoph Egger
2007-09-27 15:39 ` Keir Fraser
2007-09-28 8:07 ` Christoph Egger
2007-09-28 10:31 ` Ian Campbell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.