[Qemu-devel] [PATCH 07/15] vnc: palette: and fill and color calls.

2010-08-11 Thread Corentin Chary
These two helpers are needed for zrle and zywrle.

Signed-off-by: Corentin Chary corenti...@iksaif.net
---
 ui/vnc-palette.c |   33 +
 ui/vnc-palette.h |3 +++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/ui/vnc-palette.c b/ui/vnc-palette.c
index f93250b..d691a0c 100644
--- a/ui/vnc-palette.c
+++ b/ui/vnc-palette.c
@@ -126,3 +126,36 @@ void palette_iter(const VncPalette *palette,
 }
 }
 }
+
+uint32_t palette_color(const VncPalette *palette, int idx, bool *found)
+{
+int i;
+VncPaletteEntry *entry;
+
+for (i = 0; i  VNC_PALETTE_HASH_SIZE; i++) {
+QLIST_FOREACH(entry, palette-table[i], next) {
+if (entry-idx == idx) {
+*found = true;
+return entry-color;
+}
+}
+}
+
+*found = false;
+return -1;
+}
+
+static void palette_fill_cb(int idx, uint32_t color, void *opaque)
+{
+uint32_t *colors = opaque;
+
+colors[idx] = color;
+}
+
+size_t palette_fill(const VncPalette *palette,
+uint32_t colors[VNC_PALETTE_MAX_SIZE])
+{
+palette_iter(palette, palette_fill_cb, colors);
+return palette_size(palette);
+}
+
diff --git a/ui/vnc-palette.h b/ui/vnc-palette.h
index c646e4d..3260885 100644
--- a/ui/vnc-palette.h
+++ b/ui/vnc-palette.h
@@ -61,5 +61,8 @@ size_t palette_size(const VncPalette *palette);
 void palette_iter(const VncPalette *palette,
   void (*iter)(int idx, uint32_t color, void *opaque),
   void *opaque);
+uint32_t palette_color(const VncPalette *palette, int idx, bool *found);
+size_t palette_fill(const VncPalette *palette,
+uint32_t colors[VNC_PALETTE_MAX_SIZE]);
 
 #endif /* VNC_PALETTE_H */
-- 
1.7.1




[Qemu-devel] [PATCH 11/15] bitmap: add a generic bitmap and bitops library

2010-08-11 Thread Corentin Chary
Add most used bitmap and bitops functions into bitmap.c and bitops.c.
Theses functions are mostly copied from Linux kernel source.

Some of these functions are already redefined in the VNC server. Some
of them could be used for some block stuff. The yet yo be submitted
NUMA work also need bitmaps.

Signed-off-by: Corentin Chary corenti...@iksaif.net
---
 Makefile.objs |1 +
 bitmap.c  |  255 +
 bitmap.h  |  222 ++
 bitops.c  |  142 ++
 bitops.h  |  272 +
 osdep.h   |4 +
 6 files changed, 896 insertions(+), 0 deletions(-)
 create mode 100644 bitmap.c
 create mode 100644 bitmap.h
 create mode 100644 bitops.c
 create mode 100644 bitops.h

diff --git a/Makefile.objs b/Makefile.objs
index a6dd2ab..d4afde8 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -83,6 +83,7 @@ common-obj-y += qemu-char.o savevm.o #aio.o
 common-obj-y += msmouse.o ps2.o
 common-obj-y += qdev.o qdev-properties.o
 common-obj-y += block-migration.o
+common-obj-y += bitmap.c bitops.c
 
 common-obj-$(CONFIG_BRLAPI) += baum.o
 common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
diff --git a/bitmap.c b/bitmap.c
new file mode 100644
index 000..eaafbea
--- /dev/null
+++ b/bitmap.c
@@ -0,0 +1,255 @@
+/*
+ * Bitmap Module
+ *
+ * Stolen from linux/src/lib/bitmap.c
+ *
+ * Copyright (C) 2010 Corentin Chary
+ *
+ * This source code is licensed under the GNU General Public License,
+ * Version 2.
+ */
+
+#include bitops.h
+#include bitmap.h
+
+/*
+ * bitmaps provide an array of bits, implemented using an an
+ * array of unsigned longs.  The number of valid bits in a
+ * given bitmap does _not_ need to be an exact multiple of
+ * BITS_PER_LONG.
+ *
+ * The possible unused bits in the last, partially used word
+ * of a bitmap are 'don't care'.  The implementation makes
+ * no particular effort to keep them zero.  It ensures that
+ * their value will not affect the results of any operation.
+ * The bitmap operations that return Boolean (bitmap_empty,
+ * for example) or scalar (bitmap_weight, for example) results
+ * carefully filter out these unused bits from impacting their
+ * results.
+ *
+ * These operations actually hold to a slightly stronger rule:
+ * if you don't input any bitmaps to these ops that have some
+ * unused bits set, then they won't output any set unused bits
+ * in output bitmaps.
+ *
+ * The byte ordering of bitmaps is more natural on little
+ * endian architectures.
+ */
+
+int __bitmap_empty(const unsigned long *bitmap, int bits)
+{
+int k, lim = bits/BITS_PER_LONG;
+
+for (k = 0; k  lim; ++k) {
+if (bitmap[k]) {
+return 0;
+}
+}
+if (bits % BITS_PER_LONG) {
+if (bitmap[k]  BITMAP_LAST_WORD_MASK(bits)) {
+return 0;
+}
+}
+
+return 1;
+}
+
+int __bitmap_full(const unsigned long *bitmap, int bits)
+{
+int k, lim = bits/BITS_PER_LONG;
+
+for (k = 0; k  lim; ++k) {
+if (~bitmap[k]) {
+return 0;
+}
+}
+
+if (bits % BITS_PER_LONG) {
+if (~bitmap[k]  BITMAP_LAST_WORD_MASK(bits)) {
+return 0;
+}
+}
+
+return 1;
+}
+
+int __bitmap_equal(const unsigned long *bitmap1,
+   const unsigned long *bitmap2, int bits)
+{
+int k, lim = bits/BITS_PER_LONG;
+
+for (k = 0; k  lim; ++k) {
+if (bitmap1[k] != bitmap2[k]) {
+return 0;
+}
+}
+
+if (bits % BITS_PER_LONG) {
+if ((bitmap1[k] ^ bitmap2[k])  BITMAP_LAST_WORD_MASK(bits)) {
+return 0;
+}
+}
+
+return 1;
+}
+
+void __bitmap_complement(unsigned long *dst, const unsigned long *src, int 
bits)
+{
+int k, lim = bits/BITS_PER_LONG;
+
+for (k = 0; k  lim; ++k) {
+dst[k] = ~src[k];
+}
+
+if (bits % BITS_PER_LONG) {
+dst[k] = ~src[k]  BITMAP_LAST_WORD_MASK(bits);
+}
+}
+
+int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
+ const unsigned long *bitmap2, int bits)
+{
+int k;
+int nr = BITS_TO_LONGS(bits);
+unsigned long result = 0;
+
+for (k = 0; k  nr; k++) {
+result |= (dst[k] = bitmap1[k]  bitmap2[k]);
+}
+return result != 0;
+}
+
+void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
+   const unsigned long *bitmap2, int bits)
+{
+int k;
+int nr = BITS_TO_LONGS(bits);
+
+for (k = 0; k  nr; k++) {
+dst[k] = bitmap1[k] | bitmap2[k];
+}
+}
+
+void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
+   const unsigned long *bitmap2, int bits)
+{
+int k;
+int nr = BITS_TO_LONGS(bits);
+
+for (k = 0; k  nr; k++) {
+dst[k] = bitmap1[k] ^ bitmap2[k];
+}
+}
+
+int __bitmap_andnot(unsigned long *dst, const 

Re: [Qemu-devel] [PATCH] trace: Make trace record fields 64-bit

2010-08-11 Thread Prerna Saxena

On 08/09/2010 07:05 PM, Stefan Hajnoczi wrote:

Explicitly use 64-bit fields in trace records so that timestamps and
magic numbers work for 32-bit host builds.

Signed-off-by: Stefan Hajnoczistefa...@linux.vnet.ibm.com
---
  simpletrace.c  |   31 +--
  simpletrace.h  |   11 ++-
  simpletrace.py |2 +-
  tracetool  |6 +++---
  4 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/simpletrace.c b/simpletrace.c
index 954cc4e..01acfc5 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -9,18 +9,29 @@
   */

  #includestdlib.h
+#includestdint.h
  #includestdio.h
  #includetime.h
  #include trace.h

+/** Trace file header event ID */
+#define HEADER_EVENT_ID (~(uint64_t)0) /* avoids conflicting with 
TraceEventIDs */
+
+/** Trace file magic number */
+#define HEADER_MAGIC 0xf2b177cb0aa429b4ULL
+
+/** Trace file version number, bump if format changes */
+#define HEADER_VERSION 0
+
+/** Trace buffer entry */
  typedef struct {
-unsigned long event;
-unsigned long timestamp_ns;
-unsigned long x1;
-unsigned long x2;
-unsigned long x3;
-unsigned long x4;
-unsigned long x5;
+uint64_t event;
+uint64_t timestamp_ns;
+uint64_t x1;
+uint64_t x2;
+uint64_t x3;
+uint64_t x4;
+uint64_t x5;
  } TraceRecord;

  enum {
@@ -42,9 +53,9 @@ void st_print_trace_file_status(FILE *stream, int 
(*stream_printf)(FILE *stream,
  static bool write_header(FILE *fp)
  {
  TraceRecord header = {
-.event = -1UL, /* max avoids conflicting with TraceEventIDs */
-.timestamp_ns = 0xf2b177cb0aa429b4, /* magic number */
-.x1 = 0, /* bump this version number if file format changes */
+.event = HEADER_EVENT_ID,
+.timestamp_ns = HEADER_MAGIC,
+.x1 = HEADER_VERSION,
  };

  return fwrite(header, sizeof header, 1, fp) == 1;
diff --git a/simpletrace.h b/simpletrace.h
index 6a2b8d9..f81aa8e 100644
--- a/simpletrace.h
+++ b/simpletrace.h
@@ -10,6 +10,7 @@
  #define SIMPLETRACE_H

  #includestdbool.h
+#includestdint.h
  #includestdio.h

  typedef unsigned int TraceEventID;


It would be useful to have :

typedef uint64_t TraceEventID;

This ensures that the maximum number of trace events available on both 
32 and 64 bit builds is same.



@@ -20,11 +21,11 @@ typedef struct {
  } TraceEvent;

  void trace0(TraceEventID event);
-void trace1(TraceEventID event, unsigned long x1);
-void trace2(TraceEventID event, unsigned long x1, unsigned long x2);
-void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned 
long x3);
-void trace4(TraceEventID event, unsigned long x1, unsigned long x2, unsigned 
long x3, unsigned long x4);
-void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned 
long x3, unsigned long x4, unsigned long x5);
+void trace1(TraceEventID event, uint64_t x1);
+void trace2(TraceEventID event, uint64_t x1, uint64_t x2);
+void trace3(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3);
+void trace4(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, 
uint64_t x4);
+void trace5(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, 
uint64_t x4, uint64_t x5);
  void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const 
char *fmt, ...));
  void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, 
const char *fmt, ...));
  void st_change_trace_event_state(const char *tname, bool tstate);
diff --git a/simpletrace.py b/simpletrace.py
index 979d911..fdf0eb5 100755
--- a/simpletrace.py
+++ b/simpletrace.py
@@ -17,7 +17,7 @@ header_event_id = 0x
  header_magic= 0xf2b177cb0aa429b4
  header_version  = 0

-trace_fmt = 'LLL'
+trace_fmt = '=QQQ'
  trace_len = struct.calcsize(trace_fmt)
  event_re  = re.compile(r'(disable\s+)?([a-zA-Z0-9_]+)\(([^)]*)\)\s+([^]*)')

diff --git a/tracetool b/tracetool
index c5a5bdc..b78cd97 100755
--- a/tracetool
+++ b/tracetool
@@ -151,11 +151,11 @@ EOF
  simple_event_num=0
  }

-cast_args_to_ulong()
+cast_args_to_uint64_t()
  {
  local arg
  for arg in $(get_argnames $1); do
-echo -n (unsigned long)$arg
+echo -n (uint64_t)$arg


Tested this on a 32 bit host. It throws up some warnings, and we need :
echo -n (uint64_t)(uintptr_t)$arg


  done
  }

@@ -173,7 +173,7 @@ linetoh_simple()
  trace_args=$simple_event_num
  if [ $argc -gt 0 ]
  then
-trace_args=$trace_args, $(cast_args_to_ulong $1)
+trace_args=$trace_args, $(cast_args_to_uint64_t $1)
  fi

  catEOF



--
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India



[Qemu-devel] [PATCH 09/15] vnc: fix uint8_t comparisons with negative values

2010-08-11 Thread Corentin Chary
Signed-off-by: Corentin Chary corenti...@iksaif.net
---
 ui/vnc-enc-tight.c |6 +++---
 ui/vnc-enc-zrle.c  |3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 5ca4342..9f83235 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -1546,7 +1546,7 @@ static int send_sub_rect(VncState *vs, int x, int y, int 
w, int h)
 vnc_tight_stop(vs);
 
 #ifdef CONFIG_VNC_JPEG
-if (vs-tight.quality != -1) {
+if (vs-tight.quality != (uint8_t)-1) {
 double freq = vnc_update_freq(vs, x, y, w, h);
 
 if (freq  tight_jpeg_conf[vs-tight.quality].jpeg_freq_min) {
@@ -1562,7 +1562,7 @@ static int send_sub_rect(VncState *vs, int x, int y, int 
w, int h)
 colors = tight_fill_palette(vs, x, y, w * h, fg, bg, palette);
 
 #ifdef CONFIG_VNC_JPEG
-if (allow_jpeg  vs-tight.quality != -1) {
+if (allow_jpeg  vs-tight.quality != (uint8_t)-1) {
 ret = send_sub_rect_jpeg(vs, x, y, w, h, bg, fg, colors, palette,
  force_jpeg);
 } else {
@@ -1711,7 +1711,7 @@ static int tight_send_framebuffer_update(VncState *vs, 
int x, int y,
 vs-tight.pixel24 = false;
 }
 
-if (vs-tight.quality != -1) {
+if (vs-tight.quality != (uint8_t)-1) {
 double freq = vnc_update_freq(vs, x, y, w, h);
 
 if (freq  tight_jpeg_conf[vs-tight.quality].jpeg_freq_threshold) {
diff --git a/ui/vnc-enc-zrle.c b/ui/vnc-enc-zrle.c
index 4460890..b5a245a 100644
--- a/ui/vnc-enc-zrle.c
+++ b/ui/vnc-enc-zrle.c
@@ -284,7 +284,8 @@ static int zrle_send_framebuffer_update(VncState *vs, int 
x, int y,
   int zywrle_level;
 
   if (vs-zrle.type == VNC_ENCODING_ZYWRLE) {
-  if (!vs-vd-lossy || vs-tight.quality  0 || vs-tight.quality == 9) {
+  if (!vs-vd-lossy || vs-tight.quality == (uint8_t)-1
+  || vs-tight.quality == 9) {
   zywrle_level = 0;
   vs-zrle.type = VNC_ENCODING_ZRLE;
   } else if (vs-tight.quality  3) {
-- 
1.7.1




[Qemu-devel] [PATCH 14/15] vnc: tight: tweak adaptive tight settings

2010-08-11 Thread Corentin Chary
The force_jpeg threshold was too low.

Signed-off-by: Corentin Chary corenti...@iksaif.net
---
 qemu-thread.c  |1 +
 ui/vnc-enc-tight.c |   20 ++--
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/qemu-thread.c b/qemu-thread.c
index fbc78fe..4094c51 100644
--- a/qemu-thread.c
+++ b/qemu-thread.c
@@ -22,6 +22,7 @@
 static void error_exit(int err, const char *msg)
 {
 fprintf(stderr, qemu: %s: %s\n, msg, strerror(err));
+char *p = NULL; *p = 1;
 exit(1);
 }
 
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 9f83235..b0181ff 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -79,16 +79,16 @@ static const struct {
 int jpeg_idx;   /* Allow indexed JPEG */
 int jpeg_full;  /* Allow full color JPEG */
 } tight_jpeg_conf[] = {
-{ 0,   4,  1, 1 },
-{ 0,   4,  1, 1 },
-{ 0,   4,  1, 1 },
-{ 0,   4,  1, 1 },
-{ 0,   4,  0, 1 },
-{ 0.1, 4,  0, 1 },
-{ 0.2, 4,  0, 1 },
-{ 0.3, 6,  0, 0 },
-{ 0.4, 8,  0, 0 },
-{ 0.5, 10, 0, 0 },
+{ 0,   8,  1, 1 },
+{ 0,   8,  1, 1 },
+{ 0,   8,  1, 1 },
+{ 0,   8,  1, 1 },
+{ 0,   10, 1, 1 },
+{ 0.1, 10, 1, 1 },
+{ 0.2, 10, 1, 1 },
+{ 0.3, 12, 0, 0 },
+{ 0.4, 14, 0, 0 },
+{ 0.5, 16, 0, 0 },
 };
 #endif
 
-- 
1.7.1




[Qemu-devel] [PATCH 10/15] vnc: fix lossy rect refreshing

2010-08-11 Thread Corentin Chary
The for loop in send_lossy_rect was totally wrong, and we can't
call vnc_set_bits() because it does not really do what it should.
Use vnc_set_bit() directly instead.

Signed-off-by: Corentin Chary corenti...@iksaif.net
---
 ui/vnc.c |   12 
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 27263dc..5038863 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2292,8 +2292,8 @@ void vnc_sent_lossy_rect(VncState *vs, int x, int y, int 
w, int h)
 x /= VNC_STAT_RECT;
 y /= VNC_STAT_RECT;
 
-for (j = y; j = y + h; j++) {
-for (i = x; i = x + w; i++) {
+for (j = y; j = h; j++) {
+for (i = x; i = w; i++) {
 vs-lossy_rect[j][i] = 1;
 }
 }
@@ -2310,7 +2310,7 @@ static int vnc_refresh_lossy_rect(VncDisplay *vd, int x, 
int y)
 x = x / VNC_STAT_RECT * VNC_STAT_RECT;
 
 QTAILQ_FOREACH(vs, vd-clients, next) {
-int j ;
+int j, i;
 
 /* kernel send buffers are full - refresh later */
 if (vs-output.offset)
@@ -2318,12 +2318,16 @@ static int vnc_refresh_lossy_rect(VncDisplay *vd, int 
x, int y)
 
 if (!vs-lossy_rect[sty][stx])
 continue ;
+
 vs-lossy_rect[sty][stx] = 0;
 for (j = 0; j  VNC_STAT_RECT; ++j) {
-vnc_set_bits(vs-dirty[y + j], x / 16, VNC_STAT_RECT / 16);
+for (i = x / 16; i  VNC_STAT_RECT / 16 + x / 16; ++i) {
+vnc_set_bit(vs-dirty[y + j], i);
+}
 }
 has_dirty++;
 }
+
 return has_dirty;
 }
 
-- 
1.7.1




[Qemu-devel] [PATCH 13/15] vnc: don't try to send bigger updates that client height

2010-08-11 Thread Corentin Chary
Respect client size if it doesn't not support desktop resizing.

Signed-off-by: Corentin Chary corenti...@iksaif.net
---
 ui/vnc.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 0adab4a..dffb4aa 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -791,12 +791,11 @@ static void vnc_dpy_cursor_define(QEMUCursor *c)
 }
 
 static int find_and_clear_dirty_height(struct VncState *vs,
-   int y, int last_x, int x)
+   int y, int last_x, int x, int height)
 {
 int h;
-VncDisplay *vd = vs-vd;
 
-for (h = 1; h  (vd-server-height - y); h++) {
+for (h = 1; h  (height - y); h++) {
 int tmp_x;
 if (!test_bit(last_x, vs-dirty[y + h])) {
 break;
@@ -861,7 +860,8 @@ static int vnc_update_client(VncState *vs, int has_dirty)
 }
 } else {
 if (last_x != -1) {
-int h = find_and_clear_dirty_height(vs, y, last_x, x);
+int h = find_and_clear_dirty_height(vs, y, last_x, x,
+height);
 
 n += vnc_job_add_rect(job, last_x * 16, y,
   (x - last_x) * 16, h);
@@ -870,7 +870,7 @@ static int vnc_update_client(VncState *vs, int has_dirty)
 }
 }
 if (last_x != -1) {
-int h = find_and_clear_dirty_height(vs, y, last_x, x);
+int h = find_and_clear_dirty_height(vs, y, last_x, x, height);
 n += vnc_job_add_rect(job, last_x * 16, y,
   (x - last_x) * 16, h);
 }
-- 
1.7.1




[Qemu-devel] [PATCH 15/15] vnc: add a non-adaptive option

2010-08-11 Thread Corentin Chary
This option allow to disable adaptive behaviors in some encodings.

Signed-off-by: Corentin Chary corenti...@iksaif.net
---
 qemu-options.hx|9 +
 ui/vnc-enc-tight.c |2 +-
 ui/vnc.c   |   13 +
 ui/vnc.h   |1 +
 4 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 40cee70..e158101 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -842,6 +842,15 @@ option is set, VNC client may receive lossy framebuffer 
updates
 depending on its encoding settings. Enabling this option can save
 a lot of bandwidth at the expense of quality.
 
+...@item non-adaptive
+
+Disable adaptive encodings. Adaptive encodings are enabled by default.
+An adaptive encoding will try to detect frequently updated screen regions,
+and send updates in these regions using a lossy encoding (like JPEG).
+This can be really helpfull to save bandwidth when playing videos. Disabling
+adaptive encodings allow to restore the original static behavior of encodings
+like Tight.
+
 @end table
 ETEXI
 
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index b0181ff..534745e 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -1546,7 +1546,7 @@ static int send_sub_rect(VncState *vs, int x, int y, int 
w, int h)
 vnc_tight_stop(vs);
 
 #ifdef CONFIG_VNC_JPEG
-if (vs-tight.quality != (uint8_t)-1) {
+if (!vs-vd-non_adaptive  vs-tight.quality != (uint8_t)-1) {
 double freq = vnc_update_freq(vs, x, y, w, h);
 
 if (freq  tight_jpeg_conf[vs-tight.quality].jpeg_freq_min) {
diff --git a/ui/vnc.c b/ui/vnc.c
index dffb4aa..cb37a75 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2380,10 +2380,12 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
 VncState *vs;
 int has_dirty = 0;
 
-struct timeval tv;
+struct timeval tv = { 0, 0 };
 
-gettimeofday(tv, NULL);
-has_dirty = vnc_update_stats(vd, tv);
+if (!vd-non_adaptive) {
+gettimeofday(tv, NULL);
+has_dirty = vnc_update_stats(vd, tv);
+}
 
 /*
  * Walk through the guest dirty map.
@@ -2412,7 +2414,8 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
 if (memcmp(server_ptr, guest_ptr, cmp_bytes) == 0)
 continue;
 memcpy(server_ptr, guest_ptr, cmp_bytes);
-vnc_rect_updated(vd, x, y, tv);
+if (!vd-non_adaptive)
+vnc_rect_updated(vd, x, y, tv);
 QTAILQ_FOREACH(vs, vd-clients, next) {
 set_bit((x / 16), vs-dirty[y]);
 }
@@ -2717,6 +2720,8 @@ int vnc_display_open(DisplayState *ds, const char 
*display)
 acl = 1;
 } else if (strncmp(options, lossy, 5) == 0) {
 vs-lossy = true;
+} else if (strncmp(options, non-adapative, 13) == 0) {
+vs-non_adaptive = true;
 }
 }
 
diff --git a/ui/vnc.h b/ui/vnc.h
index 979467b..f502690 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -143,6 +143,7 @@ struct VncDisplay
 char *password;
 int auth;
 bool lossy;
+bool non_adaptive;
 #ifdef CONFIG_VNC_TLS
 int subauth; /* Used by VeNCrypt */
 VncDisplayTLS tls;
-- 
1.7.1




[Qemu-devel] [PATCH 12/15] vnc: use the new generic bitmap functions

2010-08-11 Thread Corentin Chary
Switch to bitmap.h and bitops.h instead of redefining our own bitmap
helpers.

Signed-off-by: Corentin Chary corenti...@iksaif.net
---
 ui/vnc.c |   91 ++---
 ui/vnc.h |7 +++--
 2 files changed, 25 insertions(+), 73 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 5038863..0adab4a 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -41,13 +41,6 @@ static const struct timeval VNC_REFRESH_LOSSY = { 2, 0 };
 #include vnc_keysym.h
 #include d3des.h
 
-#define count_bits(c, v) { \
-for (c = 0; v; v = 1) \
-{ \
-c += v  1; \
-} \
-}
-
 static VncDisplay *vnc_display; /* needed for info vnc */
 static DisplayChangeListener *dcl;
 
@@ -374,47 +367,6 @@ static void framebuffer_update_request(VncState *vs, int 
incremental,
 static void vnc_refresh(void *opaque);
 static int vnc_refresh_server_surface(VncDisplay *vd);
 
-static inline void vnc_set_bit(uint32_t *d, int k)
-{
-d[k  5] |= 1  (k  0x1f);
-}
-
-static inline void vnc_clear_bit(uint32_t *d, int k)
-{
-d[k  5] = ~(1  (k  0x1f));
-}
-
-static inline void vnc_set_bits(uint32_t *d, int n, int nb_words)
-{
-int j;
-
-j = 0;
-while (n = 32) {
-d[j++] = -1;
-n -= 32;
-}
-if (n  0)
-d[j++] = (1  n) - 1;
-while (j  nb_words)
-d[j++] = 0;
-}
-
-static inline int vnc_get_bit(const uint32_t *d, int k)
-{
-return (d[k  5]  (k  0x1f))  1;
-}
-
-static inline int vnc_and_bits(const uint32_t *d1, const uint32_t *d2,
-   int nb_words)
-{
-int i;
-for(i = 0; i  nb_words; i++) {
-if ((d1[i]  d2[i]) != 0)
-return 1;
-}
-return 0;
-}
-
 static void vnc_dpy_update(DisplayState *ds, int x, int y, int w, int h)
 {
 int i;
@@ -437,7 +389,7 @@ static void vnc_dpy_update(DisplayState *ds, int x, int y, 
int w, int h)
 
 for (; y  h; y++)
 for (i = 0; i  w; i += 16)
-vnc_set_bit(s-dirty[y], (x + i) / 16);
+set_bit((x + i) / 16, s-dirty[y]);
 }
 
 void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h,
@@ -776,7 +728,7 @@ static void vnc_dpy_copy(DisplayState *ds, int src_x, int 
src_y, int dst_x, int
 memmove(dst_row, src_row, cmp_bytes);
 QTAILQ_FOREACH(vs, vd-clients, next) {
 if (!vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
-vnc_set_bit(vs-dirty[y], ((x + dst_x) / 16));
+set_bit(((x + dst_x) / 16), vs-dirty[y]);
 }
 }
 }
@@ -846,10 +798,12 @@ static int find_and_clear_dirty_height(struct VncState 
*vs,
 
 for (h = 1; h  (vd-server-height - y); h++) {
 int tmp_x;
-if (!vnc_get_bit(vs-dirty[y + h], last_x))
+if (!test_bit(last_x, vs-dirty[y + h])) {
 break;
-for (tmp_x = last_x; tmp_x  x; tmp_x++)
-vnc_clear_bit(vs-dirty[y + h], tmp_x);
+}
+for (tmp_x = last_x; tmp_x  x; tmp_x++) {
+clear_bit(tmp_x, vs-dirty[y + h]);
+}
 }
 
 return h;
@@ -901,11 +855,10 @@ static int vnc_update_client(VncState *vs, int has_dirty)
 int x;
 int last_x = -1;
 for (x = 0; x  width / 16; x++) {
-if (vnc_get_bit(vs-dirty[y], x)) {
+if (test_and_clear_bit(x, vs-dirty[y])) {
 if (last_x == -1) {
 last_x = x;
 }
-vnc_clear_bit(vs-dirty[y], x);
 } else {
 if (last_x != -1) {
 int h = find_and_clear_dirty_height(vs, y, last_x, x);
@@ -1698,8 +1651,7 @@ static void framebuffer_update_request(VncState *vs, int 
incremental,
 if (!incremental) {
 vs-force_update = 1;
 for (i = 0; i  h; i++) {
-vnc_set_bits(vs-dirty[y_position + i],
- (ds_get_width(vs-ds) / 16), VNC_DIRTY_WORDS);
+bitmap_set(vs-dirty[y_position + i], x_position / 16, w / 16);
 }
 }
 }
@@ -1838,15 +1790,15 @@ static void set_pixel_format(VncState *vs,
 
 vs-clientds = *(vs-vd-guest.ds);
 vs-clientds.pf.rmax = red_max;
-count_bits(vs-clientds.pf.rbits, red_max);
+vs-clientds.pf.rbits = hweight_long(red_max);
 vs-clientds.pf.rshift = red_shift;
 vs-clientds.pf.rmask = red_max  red_shift;
 vs-clientds.pf.gmax = green_max;
-count_bits(vs-clientds.pf.gbits, green_max);
+vs-clientds.pf.gbits = hweight_long(green_max);
 vs-clientds.pf.gshift = green_shift;
 vs-clientds.pf.gmask = green_max  green_shift;
 vs-clientds.pf.bmax = blue_max;
-count_bits(vs-clientds.pf.bbits, blue_max);
+vs-clientds.pf.bbits = hweight_long(blue_max);
 vs-clientds.pf.bshift = blue_shift;
 vs-clientds.pf.bmask = blue_max  blue_shift;
 vs-clientds.pf.bits_per_pixel = bits_per_pixel;
@@ -2310,7 +2262,7 @@ static int vnc_refresh_lossy_rect(VncDisplay *vd, int 

[Qemu-devel] [PATCH 2/2] ivshmem: Fix compilation without kvm

2010-08-11 Thread Stefan Weil
kvm_set_ioeventfd_mmio_long is only available with CONFIG_KVM.

Cc: Anthony Liguori aligu...@us.ibm.com
Cc: Cam Macdonell c...@cs.ualberta.ca
Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/ivshmem.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/hw/ivshmem.c b/hw/ivshmem.c
index ec894e9..63562e1 100644
--- a/hw/ivshmem.c
+++ b/hw/ivshmem.c
@@ -385,8 +385,10 @@ static void close_guest_eventfds(IVShmemState *s, int posn)
 guest_curr_max = s-peers[posn].nb_eventfds;
 
 for (i = 0; i  guest_curr_max; i++) {
+#if defined(CONFIG_KVM)
 kvm_set_ioeventfd_mmio_long(s-peers[posn].eventfds[i],
 s-mmio_addr + DOORBELL, (posn  16) | i, 0);
+#endif
 close(s-peers[posn].eventfds[i]);
 }
 
@@ -395,7 +397,7 @@ static void close_guest_eventfds(IVShmemState *s, int posn)
 }
 
 static void setup_ioeventfds(IVShmemState *s) {
-
+#if defined(CONFIG_KVM)
 int i, j;
 
 for (i = 0; i = s-max_peer; i++) {
@@ -404,6 +406,7 @@ static void setup_ioeventfds(IVShmemState *s) {
 s-mmio_addr + DOORBELL, (i  16) | j, 1);
 }
 }
+#endif
 }
 
 /* this function increase the dynamic storage need to store data about other
@@ -530,12 +533,14 @@ static void ivshmem_read(void *opaque, const uint8_t * 
buf, int flags)
guest_max_eventfd);
 }
 
+#if defined(CONFIG_KVM)
 if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
 if (kvm_set_ioeventfd_mmio_long(incoming_fd, s-mmio_addr + DOORBELL,
 (incoming_posn  16) | guest_max_eventfd, 1)  0) {
 fprintf(stderr, ivshmem: ioeventfd not available\n);
 }
 }
+#endif
 
 return;
 }
-- 
1.7.1




[Qemu-devel] [PATCH 1/2] ivshmem: Fix compilation (wrong format specifier)

2010-08-11 Thread Stefan Weil
st_size is an off32_t or off64_t, so %ld does not always work.

Cc: Anthony Liguori aligu...@us.ibm.com
Cc: Cam Macdonell c...@cs.ualberta.ca
Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/ivshmem.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/ivshmem.c b/hw/ivshmem.c
index bbb5cba..ec894e9 100644
--- a/hw/ivshmem.c
+++ b/hw/ivshmem.c
@@ -352,8 +352,8 @@ static int check_shm_size(IVShmemState *s, int fd) {
 
 if (s-ivshmem_size  buf.st_size) {
 fprintf(stderr, IVSHMEM ERROR: Requested memory size greater);
-fprintf(stderr,  than shared object size (% PRIu64   %ld)\n,
-  s-ivshmem_size, buf.st_size);
+fprintf(stderr,  than shared object size (% PRIu64   % PRIu64 
)\n,
+  s-ivshmem_size, 
(uint64_t)buf.st_size);
 return -1;
 } else {
 return 0;
-- 
1.7.1




[Qemu-devel] [Tracing] More Trace events

2010-08-11 Thread Prerna Saxena
This patch adds few more trace events for tracking IO and also to trace 
balloon event flagged via the monitor.

Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com
---
 balloon.c|2 ++
 ioport.c |7 +++
 trace-events |8 
 3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/balloon.c b/balloon.c
index 8e0b7f1..0021fef 100644
--- a/balloon.c
+++ b/balloon.c
@@ -29,6 +29,7 @@
 #include cpu-common.h
 #include kvm.h
 #include balloon.h
+#include trace.h
 
 
 static QEMUBalloonEvent *qemu_balloon_event;
@@ -43,6 +44,7 @@ void qemu_add_balloon_handler(QEMUBalloonEvent *func, void 
*opaque)
 int qemu_balloon(ram_addr_t target, MonitorCompletion cb, void *opaque)
 {
 if (qemu_balloon_event) {
+trace_balloon_event(qemu_balloon_event_opaque, target);
 qemu_balloon_event(qemu_balloon_event_opaque, target, cb, opaque);
 return 1;
 } else {
diff --git a/ioport.c b/ioport.c
index 53dd87a..ec3dc65 100644
--- a/ioport.c
+++ b/ioport.c
@@ -26,6 +26,7 @@
  */
 
 #include ioport.h
+#include trace.h
 
 /***/
 /* IO Port */
@@ -195,18 +196,21 @@ void isa_unassign_ioport(pio_addr_t start, int length)
 void cpu_outb(pio_addr_t addr, uint8_t val)
 {
 LOG_IOPORT(outb: %04FMT_pioaddr %02PRIx8\n, addr, val);
+trace_cpu_out(addr, val);
 ioport_write(0, addr, val);
 }
 
 void cpu_outw(pio_addr_t addr, uint16_t val)
 {
 LOG_IOPORT(outw: %04FMT_pioaddr %04PRIx16\n, addr, val);
+trace_cpu_out(addr, val);
 ioport_write(1, addr, val);
 }
 
 void cpu_outl(pio_addr_t addr, uint32_t val)
 {
 LOG_IOPORT(outl: %04FMT_pioaddr %08PRIx32\n, addr, val);
+trace_cpu_out(addr, val);
 ioport_write(2, addr, val);
 }
 
@@ -214,6 +218,7 @@ uint8_t cpu_inb(pio_addr_t addr)
 {
 uint8_t val;
 val = ioport_read(0, addr);
+trace_cpu_in(addr, val);
 LOG_IOPORT(inb : %04FMT_pioaddr %02PRIx8\n, addr, val);
 return val;
 }
@@ -222,6 +227,7 @@ uint16_t cpu_inw(pio_addr_t addr)
 {
 uint16_t val;
 val = ioport_read(1, addr);
+trace_cpu_in(addr, val);
 LOG_IOPORT(inw : %04FMT_pioaddr %04PRIx16\n, addr, val);
 return val;
 }
@@ -230,6 +236,7 @@ uint32_t cpu_inl(pio_addr_t addr)
 {
 uint32_t val;
 val = ioport_read(2, addr);
+trace_cpu_in(addr, val);
 LOG_IOPORT(inl : %04FMT_pioaddr %08PRIx32\n, addr, val);
 return val;
 }
diff --git a/trace-events b/trace-events
index 80197b6..cade0b5 100644
--- a/trace-events
+++ b/trace-events
@@ -59,3 +59,11 @@ virtio_blk_handle_write(void *req, unsigned long sector, 
unsigned long nsectors)
 
 # posix-aio-compat.c
 paio_submit(void *acb, void *opaque, unsigned long sector_num, unsigned long 
nb_sectors, unsigned long type) acb %p opaque %p sector_num %lu nb_sectors %lu 
type %lu
+
+# ioport.c
+cpu_in(unsigned int addr, unsigned int val) Addr %u Value %u
+cpu_out(unsigned int addr, unsigned int val) Addr %u Value %u
+
+# balloon.c
+# Since requests are raised via monitor, not many tracepoints are needed.
+balloon_event(void *opaque, unsigned long addr) Opaque %p Addr %lu
-- 
1.6.2.5



-- 
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India




[Qemu-devel] Running the user emulation

2010-08-11 Thread C K Kashyap
Hi,
I've built qemu on my mac osx using this config -
./configure --prefix=/Users/ckk/local/ --target-list=i386-softmmu
x86_64-softmmu --enable-linux-user

Now, I have a simple a.out built on linux - how can I run it using qemu on
my mac box?

-- 
Regards,
Kashyap


Re: [Qemu-devel] [PATCH v8 5/5] RESEND: Inter-VM shared memory PCI device

2010-08-11 Thread Stefan Weil

Am 27.07.2010 18:54, schrieb Cam Macdonell:

resend for bug fix related to removal of irqfd

Support an inter-vm shared memory device that maps a shared-memory 
object as a
PCI device in the guest. This patch also supports interrupts between 
guest by
communicating over a unix domain socket. This patch applies to the 
qemu-kvm

repository.

-device ivshmem,size=size in format accepted by -m[,shm=shm name]

Interrupts are supported between multiple VMs by using a shared memory 
server

by using a chardev socket.

-device ivshmem,size=size in format accepted by -m[,shm=shm name]
[,chardev=id][,msi=on][,ioeventfd=on][,vectors=n][,role=peer|master]
-chardev socket,path=path,id=id

The shared memory server, sample programs and init scripts are in a 
git repo here:


www.gitorious.org/nahanni

Signed-off-by: Cam Macdonell c...@cs.ualberta.ca
---
Makefile.target | 3 +
hw/ivshmem.c | 828 +++
qemu-char.c | 6 +
qemu-char.h | 3 +
qemu-doc.texi | 43 +++
5 files changed, 883 insertions(+), 0 deletions(-)
create mode 100644 hw/ivshmem.c



Hi,

hw/ivshmem.c breaks compilation on 32 bit hosts, for targets without kvm 
support

and for win32 environments.

I sent patches to qemu-devel which fix the first two problems.

The win32 problems (missing mmap, maybe more) remain.
Could you please fix them?

Regards
Stefan




Re: [Qemu-devel] Running the user emulation

2010-08-11 Thread Stefan Weil

Am 11.08.2010 10:31, schrieb C K Kashyap:

Hi,
I've built qemu on my mac osx using this config -
./configure --prefix=/Users/ckk/local/ --target-list=i386-softmmu 
x86_64-softmmu --enable-linux-user


Now, I have a simple a.out built on linux - how can I run it using 
qemu on my mac box?


--
Regards,
Kashyap


Hi Kashyap,

you cannot run it in user mode emulation unless you replace Mac OS by Linux
on your mac box. Linux user emulations requires a Linux host.

If you have a Linux host, you would need --target-list=i386-linux-user.

You can run your a.out if you run system emulation (e.g. i386-softmmu/qemu)
and install Linux there, of course.

Regards,
Stefan


Re: [Qemu-devel] [PATCH] Add new user mode option -ignore-environment

2010-08-11 Thread Stefan Weil

Am 01.08.2010 13:48, schrieb Stefan Weil:

Am 16.07.2010 15:09, schrieb Stefan Weil:

Am 16.07.2010 09:04, schrieb Markus Armbruster:

Stefan Weilw...@mail.berlios.de  writes:


An empty environment is sometimes useful in user mode.
The new option provides it for linux-user and bsd-user
(darwin-user still has no environment related options).

Stupid question: why is /usr/bin/env insufficient?

[...]



In most cases it is sufficient (but not always available - Windows...).
The options -U and -E are also redundant and can be replaced by
/usr/bin/env.

But -U and -E exist, so completing the set of environment related
options seems to be logical. The name of the new option was
inspired by /usr/bin/env!

And finally, there is a use case where /usr/bin/env is a bad choice:
just look for getenv and you will find one in linux-user/main.c.
Removing the environment via /usr/bin/env will also remove
environment variables which are read by qemu's runtime code.



Is there any more feedback on this patch?
Or can it be commited to git master?



Ping? The patch is still missing.

Regards,
Stefan




Re: [Qemu-devel] Running the user emulation

2010-08-11 Thread C K Kashyap
Let me see if I understand this right -

qemu loads the a.out and begins to interpret the x86 instructions in the
a.out and when a system call happens, it makes the call the host system 
is that right?



On Wed, Aug 11, 2010 at 2:12 PM, Stefan Weil w...@mail.berlios.de wrote:

  Am 11.08.2010 10:31, schrieb C K Kashyap:

 Hi,
 I've built qemu on my mac osx using this config -
 ./configure --prefix=/Users/ckk/local/ --target-list=i386-softmmu
 x86_64-softmmu --enable-linux-user

 Now, I have a simple a.out built on linux - how can I run it using qemu on
 my mac box?

 --
 Regards,
 Kashyap


 Hi Kashyap,

 you cannot run it in user mode emulation unless you replace Mac OS by Linux
 on your mac box. Linux user emulations requires a Linux host.

 If you have a Linux host, you would need --target-list=i386-linux-user.

 You can run your a.out if you run system emulation (e.g. i386-softmmu/qemu)
 and install Linux there, of course.

 Regards,
 Stefan




-- 
Regards,
Kashyap


Re: [Qemu-devel] Running the user emulation

2010-08-11 Thread Stefan Weil

Am 11.08.2010 11:06, schrieb C K Kashyap:

Let me see if I understand this right -

qemu loads the a.out and begins to interpret the x86 instructions in 
the a.out and when a system call happens, it makes the call the host 
system  is that right?





Right. That's the way how linux user mode emulation (for example 
qemu-i386) works.

See linux-user/syscall.c if you want to see more details.

bsd-user and darwin-user are also supported (more or less), but darwin-user
only supports translation of darwin/powerpc to darwin/x86 syscalls.
It won't help you to run a linux a.out on your mac.




On Wed, Aug 11, 2010 at 2:12 PM, Stefan Weil w...@mail.berlios.de 
mailto:w...@mail.berlios.de wrote:


Am 11.08.2010 10:31, schrieb C K Kashyap:

Hi,
I've built qemu on my mac osx using this config -
./configure --prefix=/Users/ckk/local/
--target-list=i386-softmmu x86_64-softmmu --enable-linux-user

Now, I have a simple a.out built on linux - how can I run it
using qemu on my mac box?

-- 
Regards,

Kashyap


Hi Kashyap,

you cannot run it in user mode emulation unless you replace Mac OS
by Linux
on your mac box. Linux user emulations requires a Linux host.

If you have a Linux host, you would need
--target-list=i386-linux-user.

You can run your a.out if you run system emulation (e.g.
i386-softmmu/qemu)
and install Linux there, of course.

Regards,
Stefan




--
Regards,
Kashyap




[Qemu-devel] Latest version in Git doesn't link - any ideas?

2010-08-11 Thread Nigel Horne

make distclean
./configure --enable-linux-aio --enable-io-thread --enable-kvm
make
...
LINK  arm-softmmu/qemu-system-arm
ivshmem.o: In function `ivshmem_mmio_map':
ivshmem.c:(.text+0x80f): undefined reference to 
`kvm_set_ioeventfd_mmio_long'

ivshmem.o: In function `ivshmem_read':
ivshmem.c:(.text+0x9fc): undefined reference to 
`kvm_set_ioeventfd_mmio_long'
ivshmem.c:(.text+0xa6c): undefined reference to 
`kvm_set_ioeventfd_mmio_long'

collect2: ld returned 1 exit status
make[1]: *** [qemu-system-arm] Error 1
make: *** [subdir-arm-softmmu] Error 2

-Nigel

--
Nigel Horne. Arranger, Adjudicator, Band Trainer, Composer, Tutor, Typesetter.
NJH Music, ICQ#20252325, twitter: @nigelhorne
n...@bandsman.co.uk http://www.bandsman.co.uk




Re: [Qemu-devel] Running the user emulation

2010-08-11 Thread C K Kashyap
I was wondering if it would be easy to force build the user-emulation on mac
- as in, lets say my a.out from linux is really trivial - even statically
linked for that matter. All it does is, say, write hello world\n to the
screen - I'd imaging that write system call would be similar on mac (as far
as writing to stdout is concerned)  Would it be possible/easy to give it
a shot?


On Wed, Aug 11, 2010 at 2:48 PM, Stefan Weil w...@mail.berlios.de wrote:

  Am 11.08.2010 11:06, schrieb C K Kashyap:

 Let me see if I understand this right -

 qemu loads the a.out and begins to interpret the x86 instructions in the
 a.out and when a system call happens, it makes the call the host system 
 is that right?



 Right. That's the way how linux user mode emulation (for example qemu-i386)
 works.
 See linux-user/syscall.c if you want to see more details.

 bsd-user and darwin-user are also supported (more or less), but darwin-user
 only supports translation of darwin/powerpc to darwin/x86 syscalls.
 It won't help you to run a linux a.out on your mac.




 On Wed, Aug 11, 2010 at 2:12 PM, Stefan Weil w...@mail.berlios.de wrote:

 Am 11.08.2010 10:31, schrieb C K Kashyap:

 Hi,
 I've built qemu on my mac osx using this config -
 ./configure --prefix=/Users/ckk/local/ --target-list=i386-softmmu
 x86_64-softmmu --enable-linux-user

 Now, I have a simple a.out built on linux - how can I run it using qemu on
 my mac box?

 --
 Regards,
 Kashyap


 Hi Kashyap,

 you cannot run it in user mode emulation unless you replace Mac OS by Linux
 on your mac box. Linux user emulations requires a Linux host.

 If you have a Linux host, you would need --target-list=i386-linux-user.

 You can run your a.out if you run system emulation (e.g. i386-softmmu/qemu)
 and install Linux there, of course.

 Regards,
 Stefan




 --
 Regards,
 Kashyap





-- 
Regards,
Kashyap


Re: [Qemu-devel] [PATCH] trace: Make trace record fields 64-bit

2010-08-11 Thread malc
On Wed, 11 Aug 2010, Prerna Saxena wrote:

 On 08/09/2010 07:05 PM, Stefan Hajnoczi wrote:
  Explicitly use 64-bit fields in trace records so that timestamps and
  magic numbers work for 32-bit host builds.
  
  Signed-off-by: Stefan Hajnoczistefa...@linux.vnet.ibm.com
  ---
simpletrace.c  |   31 +--
simpletrace.h  |   11 ++-
simpletrace.py |2 +-
tracetool  |6 +++---
4 files changed, 31 insertions(+), 19 deletions(-)
  
  diff --git a/simpletrace.c b/simpletrace.c
  index 954cc4e..01acfc5 100644
  --- a/simpletrace.c
  +++ b/simpletrace.c
  @@ -9,18 +9,29 @@
 */
  
#includestdlib.h
  +#includestdint.h
#includestdio.h
#includetime.h
#include trace.h
  
  +/** Trace file header event ID */
  +#define HEADER_EVENT_ID (~(uint64_t)0) /* avoids conflicting with
  TraceEventIDs */
  +
  +/** Trace file magic number */
  +#define HEADER_MAGIC 0xf2b177cb0aa429b4ULL
  +
  +/** Trace file version number, bump if format changes */
  +#define HEADER_VERSION 0
  +
  +/** Trace buffer entry */
typedef struct {
  -unsigned long event;
  -unsigned long timestamp_ns;
  -unsigned long x1;
  -unsigned long x2;
  -unsigned long x3;
  -unsigned long x4;
  -unsigned long x5;
  +uint64_t event;
  +uint64_t timestamp_ns;
  +uint64_t x1;
  +uint64_t x2;
  +uint64_t x3;
  +uint64_t x4;
  +uint64_t x5;
} TraceRecord;
  
enum {
  @@ -42,9 +53,9 @@ void st_print_trace_file_status(FILE *stream, int
  (*stream_printf)(FILE *stream,
static bool write_header(FILE *fp)
{
TraceRecord header = {
  -.event = -1UL, /* max avoids conflicting with TraceEventIDs */
  -.timestamp_ns = 0xf2b177cb0aa429b4, /* magic number */
  -.x1 = 0, /* bump this version number if file format changes */
  +.event = HEADER_EVENT_ID,
  +.timestamp_ns = HEADER_MAGIC,
  +.x1 = HEADER_VERSION,
};
  
return fwrite(header, sizeof header, 1, fp) == 1;
  diff --git a/simpletrace.h b/simpletrace.h
  index 6a2b8d9..f81aa8e 100644
  --- a/simpletrace.h
  +++ b/simpletrace.h
  @@ -10,6 +10,7 @@
#define SIMPLETRACE_H
  
#includestdbool.h
  +#includestdint.h
#includestdio.h
  
typedef unsigned int TraceEventID;
 
 It would be useful to have :
 
 typedef uint64_t TraceEventID;
 
 This ensures that the maximum number of trace events available on both 32 and
 64 bit builds is same.
 
  @@ -20,11 +21,11 @@ typedef struct {
} TraceEvent;
  
void trace0(TraceEventID event);
  -void trace1(TraceEventID event, unsigned long x1);
  -void trace2(TraceEventID event, unsigned long x1, unsigned long x2);
  -void trace3(TraceEventID event, unsigned long x1, unsigned long x2,
  unsigned long x3);
  -void trace4(TraceEventID event, unsigned long x1, unsigned long x2,
  unsigned long x3, unsigned long x4);
  -void trace5(TraceEventID event, unsigned long x1, unsigned long x2,
  unsigned long x3, unsigned long x4, unsigned long x5);
  +void trace1(TraceEventID event, uint64_t x1);
  +void trace2(TraceEventID event, uint64_t x1, uint64_t x2);
  +void trace3(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3);
  +void trace4(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3,
  uint64_t x4);
  +void trace5(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3,
  uint64_t x4, uint64_t x5);
void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const
  char *fmt, ...));
void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE
  *stream, const char *fmt, ...));
void st_change_trace_event_state(const char *tname, bool tstate);
  diff --git a/simpletrace.py b/simpletrace.py
  index 979d911..fdf0eb5 100755
  --- a/simpletrace.py
  +++ b/simpletrace.py
  @@ -17,7 +17,7 @@ header_event_id = 0x
header_magic= 0xf2b177cb0aa429b4
header_version  = 0
  
  -trace_fmt = 'LLL'
  +trace_fmt = '=QQQ'
trace_len = struct.calcsize(trace_fmt)
event_re  =
  re.compile(r'(disable\s+)?([a-zA-Z0-9_]+)\(([^)]*)\)\s+([^]*)')
  
  diff --git a/tracetool b/tracetool
  index c5a5bdc..b78cd97 100755
  --- a/tracetool
  +++ b/tracetool
  @@ -151,11 +151,11 @@ EOF
simple_event_num=0
}
  
  -cast_args_to_ulong()
  +cast_args_to_uint64_t()
{
local arg
for arg in $(get_argnames $1); do
  -echo -n (unsigned long)$arg
  +echo -n (uint64_t)$arg
 
 Tested this on a 32 bit host. It throws up some warnings, and we need :
 echo -n (uint64_t)(uintptr_t)$arg

Generic echo doesn't have any command line options, please use printf
instead.

 
done
}
  
  @@ -173,7 +173,7 @@ linetoh_simple()
trace_args=$simple_event_num
if [ $argc -gt 0 ]
then
  -trace_args=$trace_args, $(cast_args_to_ulong $1)
  +trace_args=$trace_args, $(cast_args_to_uint64_t $1)
fi
  
catEOF
 
 
 

-- 

Re: [Qemu-devel] Running the user emulation

2010-08-11 Thread Stefan Weil

Am 11.08.2010 11:33, schrieb C K Kashyap:
I was wondering if it would be easy to force build the user-emulation 
on mac - as in, lets say my a.out from linux is really trivial - even 
statically linked for that matter. All it does is, say, write hello 
world\n to the screen - I'd imaging that write system call would be 
similar on mac (as far as writing to stdout is concerned)  Would 
it be possible/easy to give it a shot?





It should be possible. Projects like wine can emulate windows system 
calls on linux.

Emulating darwin system calls on linux is much easier.

If you want to try it yourself, you could start by removing the exit 
from file configure:


if test $linux != yes ; then
  echo ERROR: Target '$target' is only available on a Linux host
  # exit 1
fi

Then you can run 'configure --target-list=i386-linux-user'.
Run make and fix all error messages which you will get.
If you think they are in code which you don't need for your a.out,
#if 0 ... #endif helps to remove that code.

Run the new-built qemu-i386 with your a.out and fix the remaining bugs.

That's all :-)


On Wed, Aug 11, 2010 at 2:48 PM, Stefan Weil w...@mail.berlios.de 
mailto:w...@mail.berlios.de wrote:


Am 11.08.2010 11:06, schrieb C K Kashyap:

Let me see if I understand this right -

qemu loads the a.out and begins to interpret the x86 instructions
in the a.out and when a system call happens, it makes the call
the host system  is that right?




Right. That's the way how linux user mode emulation (for example
qemu-i386) works.
See linux-user/syscall.c if you want to see more details.

bsd-user and darwin-user are also supported (more or less), but
darwin-user
only supports translation of darwin/powerpc to darwin/x86 syscalls.
It won't help you to run a linux a.out on your mac.





On Wed, Aug 11, 2010 at 2:12 PM, Stefan Weil
w...@mail.berlios.de mailto:w...@mail.berlios.de wrote:

Am 11.08.2010 10:31, schrieb C K Kashyap:

Hi,
I've built qemu on my mac osx using this config -
./configure --prefix=/Users/ckk/local/
--target-list=i386-softmmu x86_64-softmmu --enable-linux-user

Now, I have a simple a.out built on linux - how can I run it
using qemu on my mac box?

-- 
Regards,

Kashyap


Hi Kashyap,

you cannot run it in user mode emulation unless you replace
Mac OS by Linux
on your mac box. Linux user emulations requires a Linux host.

If you have a Linux host, you would need
--target-list=i386-linux-user.

You can run your a.out if you run system emulation (e.g.
i386-softmmu/qemu)
and install Linux there, of course.

Regards,
Stefan

-- 
Regards,

Kashyap


--
Regards,
Kashyap




[Qemu-devel] Re: [Tracing] More Trace events

2010-08-11 Thread Stefan Hajnoczi
On Wed, Aug 11, 2010 at 01:55:02PM +0530, Prerna Saxena wrote:
 This patch adds few more trace events for tracking IO and also to trace 
 balloon event flagged via the monitor.
 
 Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com
 ---

Thanks for adding these trace events.  Two minor requests:
1. Please split the patch into one patch that adds ioport tracing and
   one that adds virtio-balloon tracing.  If there is discussion related
   to one of these subsystems any follow up will be cleaner and only
   affect that commit.

 diff --git a/trace-events b/trace-events
 index 80197b6..cade0b5 100644
 --- a/trace-events
 +++ b/trace-events
 @@ -59,3 +59,11 @@ virtio_blk_handle_write(void *req, unsigned long sector, 
 unsigned long nsectors)
 
  # posix-aio-compat.c
  paio_submit(void *acb, void *opaque, unsigned long sector_num, unsigned long 
 nb_sectors, unsigned long type) acb %p opaque %p sector_num %lu nb_sectors 
 %lu type %lu
 +
 +# ioport.c
 +cpu_in(unsigned int addr, unsigned int val) Addr %u Value %u
 +cpu_out(unsigned int addr, unsigned int val) Addr %u Value %u
 +
 +# balloon.c
 +# Since requests are raised via monitor, not many tracepoints are needed.
 +balloon_event(void *opaque, unsigned long addr) Opaque %p Addr %lu

2. Please follow the lowercase format string convention.  All other
   trace events use lowercase like %p this %u.

Thanks,
Stefan



[Qemu-devel] Unmaintained QEMU builds

2010-08-11 Thread Stefan Weil

Hi,

since several months, QEMU for Windows (and mingw32 cross builds)
no longer builds without error.

I suspect that the same is true for QEMU on Darwin (lots of errors like
darwin-user/qemu.h:149: error: cast to pointer from integer of different 
size),

but I'm not sure here because I have no valid Darwin test environment.
Maybe someone can test this.

What about these environments? They have no maintainers.
Should they be marked as unsupported? Are they still used?
Or should they be removed?

Regards
Stefan




Fwd: [Qemu-devel] Unmaintained QEMU builds

2010-08-11 Thread Matthijs ter Woord
Stefan,
Sorry for directly replying. Resending to list:

At least QEMU for windows has some serious bugs, related to GDB handling,
and serial handling..



On Wed, Aug 11, 2010 at 12:58 PM, Stefan Weil w...@mail.berlios.de wrote:

 Hi,

 since several months, QEMU for Windows (and mingw32 cross builds)
 no longer builds without error.

 I suspect that the same is true for QEMU on Darwin (lots of errors like
 darwin-user/qemu.h:149: error: cast to pointer from integer of different
 size),
 but I'm not sure here because I have no valid Darwin test environment.
 Maybe someone can test this.

 What about these environments? They have no maintainers.
 Should they be marked as unsupported? Are they still used?
 Or should they be removed?

 Regards
 Stefan





[Qemu-devel] [PATCH v2] trace: Make trace record fields 64-bit

2010-08-11 Thread Prerna Saxena
Explicitly use 64-bit fields in trace records so that timestamps and
 magic numbers work for 32-bit host builds.

Changelog (from initial patch posted by Stefan):
1) TraceEventID is now uint64_t to take care of same number of 
tracepoints on both 32 and 64 bit builds.
2) Cast arguments to uintptr_t, and then to uint64_t to bypass warnings.


Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com
---
 simpletrace.c  |   41 ++---
 simpletrace.h  |   13 +++--
 simpletrace.py |2 +-
 tracetool  |6 +++---
 4 files changed, 37 insertions(+), 25 deletions(-)

diff --git a/simpletrace.c b/simpletrace.c
index 954cc4e..27b0cab 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -9,18 +9,29 @@
  */
 
 #include stdlib.h
+#include stdint.h
 #include stdio.h
 #include time.h
 #include trace.h
 
+/** Trace file header event ID */
+#define HEADER_EVENT_ID (~(uint64_t)0) /* avoids conflicting with 
TraceEventIDs */
+
+/** Trace file magic number */
+#define HEADER_MAGIC 0xf2b177cb0aa429b4ULL
+
+/** Trace file version number, bump if format changes */
+#define HEADER_VERSION 0
+
+/** Trace buffer entry */
 typedef struct {
-unsigned long event;
-unsigned long timestamp_ns;
-unsigned long x1;
-unsigned long x2;
-unsigned long x3;
-unsigned long x4;
-unsigned long x5;
+uint64_t event;
+uint64_t timestamp_ns;
+uint64_t x1;
+uint64_t x2;
+uint64_t x3;
+uint64_t x4;
+uint64_t x5;
 } TraceRecord;
 
 enum {
@@ -42,9 +53,9 @@ void st_print_trace_file_status(FILE *stream, int 
(*stream_printf)(FILE *stream,
 static bool write_header(FILE *fp)
 {
 TraceRecord header = {
-.event = -1UL, /* max avoids conflicting with TraceEventIDs */
-.timestamp_ns = 0xf2b177cb0aa429b4, /* magic number */
-.x1 = 0, /* bump this version number if file format changes */
+.event = HEADER_EVENT_ID,
+.timestamp_ns = HEADER_MAGIC,
+.x1 = HEADER_VERSION,
 };
 
 return fwrite(header, sizeof header, 1, fp) == 1;
@@ -160,27 +171,27 @@ void trace0(TraceEventID event)
 trace(event, 0, 0, 0, 0, 0);
 }
 
-void trace1(TraceEventID event, unsigned long x1)
+void trace1(TraceEventID event, uint64_t x1)
 {
 trace(event, x1, 0, 0, 0, 0);
 }
 
-void trace2(TraceEventID event, unsigned long x1, unsigned long x2)
+void trace2(TraceEventID event, uint64_t x1, uint64_t x2)
 {
 trace(event, x1, x2, 0, 0, 0);
 }
 
-void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned 
long x3)
+void trace3(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3)
 {
 trace(event, x1, x2, x3, 0, 0);
 }
 
-void trace4(TraceEventID event, unsigned long x1, unsigned long x2, unsigned 
long x3, unsigned long x4)
+void trace4(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, 
uint64_t x4)
 {
 trace(event, x1, x2, x3, x4, 0);
 }
 
-void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned 
long x3, unsigned long x4, unsigned long x5)
+void trace5(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, 
uint64_t x4, uint64_t x5)
 {
 trace(event, x1, x2, x3, x4, x5);
 }
diff --git a/simpletrace.h b/simpletrace.h
index 6a2b8d9..00ca439 100644
--- a/simpletrace.h
+++ b/simpletrace.h
@@ -10,9 +10,10 @@
 #define SIMPLETRACE_H
 
 #include stdbool.h
+#include stdint.h
 #include stdio.h
 
-typedef unsigned int TraceEventID;
+typedef uint64_t TraceEventID;
 
 typedef struct {
 const char *tp_name;
@@ -20,11 +21,11 @@ typedef struct {
 } TraceEvent;
 
 void trace0(TraceEventID event);
-void trace1(TraceEventID event, unsigned long x1);
-void trace2(TraceEventID event, unsigned long x1, unsigned long x2);
-void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned 
long x3);
-void trace4(TraceEventID event, unsigned long x1, unsigned long x2, unsigned 
long x3, unsigned long x4);
-void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned 
long x3, unsigned long x4, unsigned long x5);
+void trace1(TraceEventID event, uint64_t x1);
+void trace2(TraceEventID event, uint64_t x1, uint64_t x2);
+void trace3(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3);
+void trace4(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, 
uint64_t x4);
+void trace5(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, 
uint64_t x4, uint64_t x5);
 void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const 
char *fmt, ...));
 void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, 
const char *fmt, ...));
 void st_change_trace_event_state(const char *tname, bool tstate);
diff --git a/simpletrace.py b/simpletrace.py
index 979d911..fdf0eb5 100755
--- a/simpletrace.py
+++ b/simpletrace.py
@@ -17,7 +17,7 @@ header_event_id = 0x
 header_magic= 0xf2b177cb0aa429b4
 header_version  = 0
 
-trace_fmt = 'LLL'
+trace_fmt = '=QQQ'
 trace_len = struct.calcsize(trace_fmt)
 event_re  

Re: [Qemu-devel] Running the user emulation

2010-08-11 Thread C K Kashyap
Thanks Stefan for the explanation ... It does not look like a pleasant thing
to do though :)

On Wed, Aug 11, 2010 at 3:33 PM, Stefan Weil w...@mail.berlios.de wrote:

  Am 11.08.2010 11:33, schrieb C K Kashyap:

 I was wondering if it would be easy to force build the user-emulation on
 mac - as in, lets say my a.out from linux is really trivial - even
 statically linked for that matter. All it does is, say, write hello
 world\n to the screen - I'd imaging that write system call would be similar
 on mac (as far as writing to stdout is concerned)  Would it be
 possible/easy to give it a shot?



 It should be possible. Projects like wine can emulate windows system calls
 on linux.
 Emulating darwin system calls on linux is much easier.

 If you want to try it yourself, you could start by removing the exit from
 file configure:

 if test $linux != yes ; then
   echo ERROR: Target '$target' is only available on a Linux host
   # exit 1
 fi

 Then you can run 'configure --target-list=i386-linux-user'.
 Run make and fix all error messages which you will get.
 If you think they are in code which you don't need for your a.out,
 #if 0 ... #endif helps to remove that code.

 Run the new-built qemu-i386 with your a.out and fix the remaining bugs.

 That's all :-)


  On Wed, Aug 11, 2010 at 2:48 PM, Stefan Weil w...@mail.berlios.dewrote:

 Am 11.08.2010 11:06, schrieb C K Kashyap:

 Let me see if I understand this right -

 qemu loads the a.out and begins to interpret the x86 instructions in the
 a.out and when a system call happens, it makes the call the host system 
 is that right?



  Right. That's the way how linux user mode emulation (for example
 qemu-i386) works.
 See linux-user/syscall.c if you want to see more details.

 bsd-user and darwin-user are also supported (more or less), but darwin-user
 only supports translation of darwin/powerpc to darwin/x86 syscalls.
 It won't help you to run a linux a.out on your mac.




  On Wed, Aug 11, 2010 at 2:12 PM, Stefan Weil w...@mail.berlios.dewrote:

 Am 11.08.2010 10:31, schrieb C K Kashyap:

 Hi,
 I've built qemu on my mac osx using this config -
 ./configure --prefix=/Users/ckk/local/ --target-list=i386-softmmu
 x86_64-softmmu --enable-linux-user

 Now, I have a simple a.out built on linux - how can I run it using qemu on
 my mac box?

 --
 Regards,
 Kashyap


 Hi Kashyap,

 you cannot run it in user mode emulation unless you replace Mac OS by Linux
 on your mac box. Linux user emulations requires a Linux host.

 If you have a Linux host, you would need --target-list=i386-linux-user.

 You can run your a.out if you run system emulation (e.g. i386-softmmu/qemu)
 and install Linux there, of course.

 Regards,
 Stefan

  --
 Regards,
 Kashyap

   --
 Regards,
 Kashyap





-- 
Regards,
Kashyap


[Qemu-devel] [Tracing][PATCH 0/2] More Trace events

2010-08-11 Thread Prerna Saxena
Set of patches to add trace-events for tracking IO and balloon events 
flagged via the monitor.

-- 
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India




[Qemu-devel] [Tracing][PATCH 1/2] More Trace events

2010-08-11 Thread Prerna Saxena
[PATCH 1/2] Trace events for tracking port IO

Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com
---
 ioport.c |7 +++
 trace-events |4 
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/ioport.c b/ioport.c
index 53dd87a..ec3dc65 100644
--- a/ioport.c
+++ b/ioport.c
@@ -26,6 +26,7 @@
  */
 
 #include ioport.h
+#include trace.h
 
 /***/
 /* IO Port */
@@ -195,18 +196,21 @@ void isa_unassign_ioport(pio_addr_t start, int length)
 void cpu_outb(pio_addr_t addr, uint8_t val)
 {
 LOG_IOPORT(outb: %04FMT_pioaddr %02PRIx8\n, addr, val);
+trace_cpu_out(addr, val);
 ioport_write(0, addr, val);
 }
 
 void cpu_outw(pio_addr_t addr, uint16_t val)
 {
 LOG_IOPORT(outw: %04FMT_pioaddr %04PRIx16\n, addr, val);
+trace_cpu_out(addr, val);
 ioport_write(1, addr, val);
 }
 
 void cpu_outl(pio_addr_t addr, uint32_t val)
 {
 LOG_IOPORT(outl: %04FMT_pioaddr %08PRIx32\n, addr, val);
+trace_cpu_out(addr, val);
 ioport_write(2, addr, val);
 }
 
@@ -214,6 +218,7 @@ uint8_t cpu_inb(pio_addr_t addr)
 {
 uint8_t val;
 val = ioport_read(0, addr);
+trace_cpu_in(addr, val);
 LOG_IOPORT(inb : %04FMT_pioaddr %02PRIx8\n, addr, val);
 return val;
 }
@@ -222,6 +227,7 @@ uint16_t cpu_inw(pio_addr_t addr)
 {
 uint16_t val;
 val = ioport_read(1, addr);
+trace_cpu_in(addr, val);
 LOG_IOPORT(inw : %04FMT_pioaddr %04PRIx16\n, addr, val);
 return val;
 }
@@ -230,6 +236,7 @@ uint32_t cpu_inl(pio_addr_t addr)
 {
 uint32_t val;
 val = ioport_read(2, addr);
+trace_cpu_in(addr, val);
 LOG_IOPORT(inl : %04FMT_pioaddr %08PRIx32\n, addr, val);
 return val;
 }
diff --git a/trace-events b/trace-events
index 80197b6..7dbd08f 100644
--- a/trace-events
+++ b/trace-events
@@ -59,3 +59,7 @@ virtio_blk_handle_write(void *req, unsigned long sector, 
unsigned long nsectors)
 
 # posix-aio-compat.c
 paio_submit(void *acb, void *opaque, unsigned long sector_num, unsigned long 
nb_sectors, unsigned long type) acb %p opaque %p sector_num %lu nb_sectors %lu 
type %lu
+
+# ioport.c
+cpu_in(unsigned int addr, unsigned int val) addr %u value %u
+cpu_out(unsigned int addr, unsigned int val) addr %u value %u
-- 
1.6.2.5



-- 
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India




Re: [Qemu-devel] [PATCH 14/15] vnc: tight: tweak adaptive tight settings

2010-08-11 Thread Chris Krumme

Hello Corentin,

On 08/11/2010 12:49 AM, Corentin Chary wrote:

The force_jpeg threshold was too low.

Signed-off-by: Corentin Charycorenti...@iksaif.net
---
  qemu-thread.c  |1 +
  ui/vnc-enc-tight.c |   20 ++--
  2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/qemu-thread.c b/qemu-thread.c
index fbc78fe..4094c51 100644
--- a/qemu-thread.c
+++ b/qemu-thread.c
@@ -22,6 +22,7 @@
  static void error_exit(int err, const char *msg)
  {
  fprintf(stderr, qemu: %s: %s\n, msg, strerror(err));
+char *p = NULL; *p = 1;
   


I do not believe this is the official way to do an assert.  It is also 
not documented in the change comments.


Thanks

Chris


  exit(1);
  }

diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 9f83235..b0181ff 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -79,16 +79,16 @@ static const struct {
  int jpeg_idx;   /* Allow indexed JPEG */
  int jpeg_full;  /* Allow full color JPEG */
  } tight_jpeg_conf[] = {
-{ 0,   4,  1, 1 },
-{ 0,   4,  1, 1 },
-{ 0,   4,  1, 1 },
-{ 0,   4,  1, 1 },
-{ 0,   4,  0, 1 },
-{ 0.1, 4,  0, 1 },
-{ 0.2, 4,  0, 1 },
-{ 0.3, 6,  0, 0 },
-{ 0.4, 8,  0, 0 },
-{ 0.5, 10, 0, 0 },
+{ 0,   8,  1, 1 },
+{ 0,   8,  1, 1 },
+{ 0,   8,  1, 1 },
+{ 0,   8,  1, 1 },
+{ 0,   10, 1, 1 },
+{ 0.1, 10, 1, 1 },
+{ 0.2, 10, 1, 1 },
+{ 0.3, 12, 0, 0 },
+{ 0.4, 14, 0, 0 },
+{ 0.5, 16, 0, 0 },
  };
  #endif

   





Re: [Qemu-devel] [PATCH 14/15] vnc: tight: tweak adaptive tight settings

2010-08-11 Thread Corentin Chary
On Wed, Aug 11, 2010 at 3:06 PM, Chris Krumme
chris.kru...@windriver.com wrote:
 Hello Corentin,

 On 08/11/2010 12:49 AM, Corentin Chary wrote:

 The force_jpeg threshold was too low.

 Signed-off-by: Corentin Charycorenti...@iksaif.net
 ---
  qemu-thread.c      |    1 +
  ui/vnc-enc-tight.c |   20 ++--
  2 files changed, 11 insertions(+), 10 deletions(-)

 diff --git a/qemu-thread.c b/qemu-thread.c
 index fbc78fe..4094c51 100644
 --- a/qemu-thread.c
 +++ b/qemu-thread.c
 @@ -22,6 +22,7 @@
  static void error_exit(int err, const char *msg)
  {
      fprintf(stderr, qemu: %s: %s\n, msg, strerror(err));
 +    char *p = NULL; *p = 1;


 I do not believe this is the official way to do an assert.  It is also not
 documented in the change comments.

 Thanks

 Chris

Ooops .. that sould not be in the patch, it was only a test... I'll
re-send it tomorow, sorry for that :/.

-- 
Corentin Chary
http://xf.iksaif.net



[Qemu-devel] [PATCH] virtio-9p: Allow O_NOCTTY flag in open().

2010-08-11 Thread Sripathi Kodi
Currently virtio-9p server doesn't allow O_NOCTTY flag in open().
However, gcc passes this flag while opening files. As a result it
is now impossible to compile any C code on the 9P mount!

I don't see any reason for dis-allowing O_NOCTTY flag in QEMU 9P server.
AFAIK QEMU starts off with a controlling terminal, so calling open with
O_NOCTTY flag is not going to make any difference to QEMU.

The following patch makes 9P server allow O_NOCTTY flag in open().

Signed-off-by: Sripathi Kodi sripat...@in.ibm.com
---

 hw/virtio-9p.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 24115ef..f3b8bce 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1676,11 +1676,11 @@ out:
 
 static inline int valid_flags(int flag)
 {
-if (flag  O_NOCTTY || flag  O_NONBLOCK || flag  O_ASYNC ||
-flag  O_CLOEXEC)
+if (flag  O_NONBLOCK || flag  O_ASYNC || flag  O_CLOEXEC) {
 return 0;
-else
+} else {
 return 1;
+}
 }
 
 static void v9fs_open_post_lstat(V9fsState *s, V9fsOpenState *vs, int err)




Re: [Qemu-devel] [Tracing][PATCH 0/2] More Trace events

2010-08-11 Thread Stefan Hajnoczi
On Wed, Aug 11, 2010 at 12:43 PM, Prerna Saxena
pre...@linux.vnet.ibm.com wrote:
 Set of patches to add trace-events for tracking IO and balloon events
 flagged via the monitor.

http://repo.or.cz/w/qemu/stefanha.git/commitdiff/939e5dc31ec374036628986686e9d49e6cbbc33c
http://repo.or.cz/w/qemu/stefanha.git/commitdiff/ed80239f2dfe5369f18480ef1b034367c949932c

Applied, thanks!

Stefan



Re: [Qemu-devel] [PATCH v8 5/5] RESEND: Inter-VM shared memory PCI device

2010-08-11 Thread Cam Macdonell
On Wed, Aug 11, 2010 at 4:35 AM, Stefan Weil w...@mail.berlios.de wrote:
 Am 27.07.2010 18:54, schrieb Cam Macdonell:

 resend for bug fix related to removal of irqfd

 Support an inter-vm shared memory device that maps a shared-memory object
 as a
 PCI device in the guest. This patch also supports interrupts between guest
 by
 communicating over a unix domain socket. This patch applies to the
 qemu-kvm
 repository.

 -device ivshmem,size=size in format accepted by -m[,shm=shm name]

 Interrupts are supported between multiple VMs by using a shared memory
 server
 by using a chardev socket.

 -device ivshmem,size=size in format accepted by -m[,shm=shm name]
 [,chardev=id][,msi=on][,ioeventfd=on][,vectors=n][,role=peer|master]
 -chardev socket,path=path,id=id

 The shared memory server, sample programs and init scripts are in a git
 repo here:

 www.gitorious.org/nahanni

 Signed-off-by: Cam Macdonell c...@cs.ualberta.ca
 ---
 Makefile.target | 3 +
 hw/ivshmem.c | 828 +++
 qemu-char.c | 6 +
 qemu-char.h | 3 +
 qemu-doc.texi | 43 +++
 5 files changed, 883 insertions(+), 0 deletions(-)
 create mode 100644 hw/ivshmem.c


 Hi,

 hw/ivshmem.c breaks compilation on 32 bit hosts, for targets without kvm
 support
 and for win32 environments.

 I sent patches to qemu-devel which fix the first two problems.

 The win32 problems (missing mmap, maybe more) remain.
 Could you please fix them?

Could that be accomplished with excluding it on Windows on the makefiles?

Thanks,
Cam


 Regards
 Stefan





Re: [Qemu-devel] [PATCH] elf: Calculate symbol size if needed

2010-08-11 Thread Blue Swirl
On Mon, Aug 9, 2010 at 2:43 PM, Stefan Weil w...@mail.berlios.de wrote:
 Symbols with a size of 0 are unusable for the disassembler.

 Example:

 While running an arm linux kernel, no symbolic names are
 used in qemu.log when the cpu is executing an assembler function.

That is a problem of the assembler function, it should use '.size'
directive like what happens when C code is compiled. And why just ARM?

 Assume that the size of such symbols is the difference to the
 next symbol value.

 Signed-off-by: Stefan Weil w...@mail.berlios.de
 ---
  hw/elf_ops.h |    5 +
  1 files changed, 5 insertions(+), 0 deletions(-)

 diff --git a/hw/elf_ops.h b/hw/elf_ops.h
 index 27d1ab9..0bd7235 100644
 --- a/hw/elf_ops.h
 +++ b/hw/elf_ops.h
 @@ -153,6 +153,11 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, 
 int fd, int must_swab,
         syms = qemu_realloc(syms, nsyms * sizeof(*syms));

         qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
 +        for (i = 0; i  nsyms - 1; i++) {
 +            if (syms[i].st_size == 0) {
 +                syms[i].st_size = syms[i + 1].st_value - syms[i].st_value;
 +            }
 +        }

The size of the last symbol is not guesstimated, it could be assumed
to be _etext - syms[nsyms].st_value.

     } else {
         qemu_free(syms);
         syms = NULL;
 --
 1.7.1






Re: [Qemu-devel] Unmaintained QEMU builds

2010-08-11 Thread Blue Swirl
On Wed, Aug 11, 2010 at 10:58 AM, Stefan Weil w...@mail.berlios.de wrote:
 Hi,

 since several months, QEMU for Windows (and mingw32 cross builds)
 no longer builds without error.

Not true for mingw32, it was building fine here until the latest commit.

 I suspect that the same is true for QEMU on Darwin (lots of errors like
 darwin-user/qemu.h:149: error: cast to pointer from integer of different
 size),
 but I'm not sure here because I have no valid Darwin test environment.
 Maybe someone can test this.

 What about these environments? They have no maintainers.
 Should they be marked as unsupported? Are they still used?
 Or should they be removed?

I compile test mingw32 very often, it's part of my build test setup.
If the build breaks, I may even fix the problem.

But perhaps darwin-user should be removed.



[Qemu-devel] [Bug 614958] Re: copy-paste between client and host

2010-08-11 Thread Steve White
Hi Paolo,

Thanks for your acknowledgement!  if a solution is on the way, I'm glad
to hear it!

I agree that it would be best to keep this report open until *after* the
solution arrives and this particular feature has been tested and it has
been released to the public.  If this SPICE doesn't completely satisfy
the cut and paste requirement, then the bug report should be moved to
the SPICE bug report system.

We are eagerly awaiting the new features!

Cheers!

-- 
copy-paste between client and host
https://bugs.launchpad.net/bugs/614958
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: New

Bug description:
Hi,

I propose that copy/paste between VMs be implemented somehow directly in QEMU.
This has been discussed repeatedly elsewhere; various solutions are proposed.  
See below.

As it is, each user has to do their own research and testing if they are to 
find a solution.   This makes the product frustratingly unattractive for many.

Most solutions involve either running vnc and using a vnc client that supports 
copy/paste (this can be tricky to find itself), or running some other tcp-based 
copy-paste application. 

For many users, the networking in a client VM is unimportant--they just want to 
run some application there, and setting up netoworking in a VM itself can be an 
issue.  Most of these solutions rely on un-maintained software, and some 
require that other software be installed to make them work (Basic interpreter, 
Java, etc).  Any of these solutions take some work to set up.

I can tell you, the absence of a copy/paste mechanism makes the project an 
immediate no-go for many users.  I work with a guy who spent a lot of time 
trying, gave up, and switched to VirtualBox for this exact reason.

It would be much better if copy/paste worked out of the box.  Ideally, it 
should work independently of networking.

Cheers!

Some discussions and proposed solutions:
-
http://qemu-forum.ipi.fi/viewtopic.php?f=4t=161
Somebody suggests VNC into the virtual host, and use vncviewer
Somebody else suggests TCP/IP Clipboard (text editor with tcp/ip)

http://qemu-forum.ipi.fi/viewtopic.php?f=4t=2626
primitive app for sharing text across machines (in Basic)
http://homepage.mac.com/bnej/shareclip/

http://borderworlds.dk/blog/20070217-00.html
Says doesn't know a good solution but points to unmaintained package
Qemu Guest Tools
http://wolfpackally.wo.funpic.de/qemu/qgt/

http://bonzoli.com/docs/How_to_setup_Qemu_on_Fedora_8.html
proposes Java remoteclip running on client and server
http://www.cs.cmu.edu/afs/cs/user/rcm/WWW/RemoteClip/





Re: [Qemu-devel] [PATCH v8 5/5] RESEND: Inter-VM shared memory PCI device

2010-08-11 Thread Paolo Bonzini

On 08/11/2010 11:49 AM, Cam Macdonell wrote:

The win32 problems (missing mmap, maybe more) remain.
Could you please fix them?


Could that be accomplished with excluding it on Windows on the makefiles?


Yes, just use obj-$(CONFIG_POSIX).

Paolo



[Qemu-devel] Re: [PATCH 2/2] ivshmem: Fix compilation without kvm

2010-08-11 Thread Paolo Bonzini

On 08/11/2010 03:38 AM, Stefan Weil wrote:

kvm_set_ioeventfd_mmio_long is only available with CONFIG_KVM.


We should just disable ivshmem for non-KVM

diff --git a/Makefile.target b/Makefile.target
index b791492..c8281e9 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -191,7 +191,7 @@ obj-y += rtl8139.o
 obj-y += e1000.o

 # Inter-VM PCI shared memory
-obj-y += ivshmem.o
+obj-$(CONFIG_KVM) += ivshmem.o

 # Hardware support
 obj-i386-y += vga.o

because it is also breaking Windows builds.

Alternatively, the right way to do what this patch does, is to add 
kvm_set_ioeventfd_mmio_long to kvm-stub.c, and to use 
obj-$(CONFIG_POSIX) += ivshmem.o in the makefile to work around the 
Windows build problems.


Paolo



Re: [Qemu-devel] Re: [PATCH 2/2] ivshmem: Fix compilation without kvm

2010-08-11 Thread Blue Swirl
On Wed, Aug 11, 2010 at 5:05 PM, Paolo Bonzini pbonz...@redhat.com wrote:
 On 08/11/2010 03:38 AM, Stefan Weil wrote:

 kvm_set_ioeventfd_mmio_long is only available with CONFIG_KVM.

 We should just disable ivshmem for non-KVM

 diff --git a/Makefile.target b/Makefile.target
 index b791492..c8281e9 100644
 --- a/Makefile.target
 +++ b/Makefile.target
 @@ -191,7 +191,7 @@ obj-y += rtl8139.o
  obj-y += e1000.o

  # Inter-VM PCI shared memory
 -obj-y += ivshmem.o
 +obj-$(CONFIG_KVM) += ivshmem.o

  # Hardware support
  obj-i386-y += vga.o

 because it is also breaking Windows builds.

 Alternatively, the right way to do what this patch does, is to add
 kvm_set_ioeventfd_mmio_long to kvm-stub.c, and to use obj-$(CONFIG_POSIX)
 += ivshmem.o in the makefile to work around the Windows build problems.

This patch fixes mingw32 build for me.


0001-Fix-mingw32-build.patch
Description: application/mbox


[Qemu-devel] Re: [PATCH 2/2] ivshmem: Fix compilation without kvm

2010-08-11 Thread Cam Macdonell
On Wed, Aug 11, 2010 at 1:05 PM, Paolo Bonzini pbonz...@redhat.com wrote:
 On 08/11/2010 03:38 AM, Stefan Weil wrote:

 kvm_set_ioeventfd_mmio_long is only available with CONFIG_KVM.

 We should just disable ivshmem for non-KVM

 diff --git a/Makefile.target b/Makefile.target
 index b791492..c8281e9 100644
 --- a/Makefile.target
 +++ b/Makefile.target
 @@ -191,7 +191,7 @@ obj-y += rtl8139.o
  obj-y += e1000.o

  # Inter-VM PCI shared memory
 -obj-y += ivshmem.o
 +obj-$(CONFIG_KVM) += ivshmem.o

  # Hardware support
  obj-i386-y += vga.o

 because it is also breaking Windows builds.

 Alternatively, the right way to do what this patch does, is to add
 kvm_set_ioeventfd_mmio_long to kvm-stub.c, and to use obj-$(CONFIG_POSIX)
 += ivshmem.o in the makefile to work around the Windows build problems.


I think we decided to disable it on non-KVM systems to avoid people
stumbling into atomicity issues with emulation.

 Paolo





Re: [Qemu-devel] [PATCH] elf: Calculate symbol size if needed

2010-08-11 Thread Stefan Weil

Am 11.08.2010 18:21, schrieb Blue Swirl:

On Mon, Aug 9, 2010 at 2:43 PM, Stefan Weilw...@mail.berlios.de  wrote:
   

Symbols with a size of 0 are unusable for the disassembler.

Example:

While running an arm linux kernel, no symbolic names are
used in qemu.log when the cpu is executing an assembler function.
 

That is a problem of the assembler function, it should use '.size'
directive like what happens when C code is compiled. And why just ARM?
   


It's not just ARM. ARM is just an example.

But I stumbled upon this problem when running the linux
start code from arch/arm/kernel/head.S.


Assume that the size of such symbols is the difference to the
next symbol value.

Signed-off-by: Stefan Weilw...@mail.berlios.de
---
  hw/elf_ops.h |5 +
  1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/hw/elf_ops.h b/hw/elf_ops.h
index 27d1ab9..0bd7235 100644
--- a/hw/elf_ops.h
+++ b/hw/elf_ops.h
@@ -153,6 +153,11 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int 
fd, int must_swab,
 syms = qemu_realloc(syms, nsyms * sizeof(*syms));

 qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
+for (i = 0; i  nsyms - 1; i++) {
+if (syms[i].st_size == 0) {
+syms[i].st_size = syms[i + 1].st_value - syms[i].st_value;
+}
+}
 

The size of the last symbol is not guesstimated, it could be assumed
to be _etext - syms[nsyms].st_value.
   


Or better
syms[nsyms - 1].st_size = _etext - syms[nsyms - 1].st_value

Even that would be wrong if the last symbol is not in the
text segment but data.

Programming that special case just to get perhaps one
last symbol size seems too much perfectionism.

Most symbols have a size != 0, so let's hope the last symbol
has one, too :-)




[Qemu-devel] Re: [PATCH 2/2] ivshmem: Fix compilation without kvm

2010-08-11 Thread Paolo Bonzini

On 08/11/2010 01:18 PM, Blue Swirl wrote:

On Wed, Aug 11, 2010 at 5:05 PM, Paolo Bonzinipbonz...@redhat.com  wrote:

On 08/11/2010 03:38 AM, Stefan Weil wrote:


kvm_set_ioeventfd_mmio_long is only available with CONFIG_KVM.


We should just disable ivshmem for non-KVM

diff --git a/Makefile.target b/Makefile.target
index b791492..c8281e9 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -191,7 +191,7 @@ obj-y += rtl8139.o
  obj-y += e1000.o

  # Inter-VM PCI shared memory
-obj-y += ivshmem.o
+obj-$(CONFIG_KVM) += ivshmem.o

  # Hardware support
  obj-i386-y += vga.o

because it is also breaking Windows builds.

Alternatively, the right way to do what this patch does, is to add
kvm_set_ioeventfd_mmio_long to kvm-stub.c, and to use obj-$(CONFIG_POSIX)
+= ivshmem.o in the makefile to work around the Windows build problems.


This patch fixes mingw32 build for me.


Looks fine.

Paolo



[Qemu-devel] [PATCH 1/2] Add kvm_set_ioeventfd_mmio_long definition for non-KVM systems

2010-08-11 Thread Cam Macdonell
---
 kvm-stub.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/kvm-stub.c b/kvm-stub.c
index 3378bd3..d45f9fa 100644
--- a/kvm-stub.c
+++ b/kvm-stub.c
@@ -136,3 +136,8 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, 
uint16_t val, bool assign)
 {
 return -ENOSYS;
 }
+
+int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool 
assign)
+{
+return -ENOSYS;
+}
-- 
1.6.2.5




[Qemu-devel] [PATCH 2/2] Disable build of ivshmem on non-KVM systems

2010-08-11 Thread Cam Macdonell
---
 Makefile.target |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index b791492..c8281e9 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -191,7 +191,7 @@ obj-y += rtl8139.o
 obj-y += e1000.o
 
 # Inter-VM PCI shared memory
-obj-y += ivshmem.o
+obj-$(CONFIG_KVM) += ivshmem.o
 
 # Hardware support
 obj-i386-y += vga.o
-- 
1.6.2.5




Re: [Qemu-devel] Unmaintained QEMU builds

2010-08-11 Thread Stefan Weil

Am 11.08.2010 18:34, schrieb Blue Swirl:
On Wed, Aug 11, 2010 at 10:58 AM, Stefan Weil w...@mail.berlios.de 
wrote:

Hi,

since several months, QEMU for Windows (and mingw32 cross builds)
no longer builds without error.


Not true for mingw32, it was building fine here until the latest commit.


That's a big surprise! Do you have a mingw32 version which includes 
setenv()?

My Debian mingw32-runtime 3.13-1 does not support setenv(), so
compilation gives a warning and linking gives an error.

And don't you get warnings from SDL headers which redefine
WIN32_LEAN_AND_MEAN?




I suspect that the same is true for QEMU on Darwin (lots of errors like
darwin-user/qemu.h:149: error: cast to pointer from integer of different
size),
but I'm not sure here because I have no valid Darwin test environment.
Maybe someone can test this.

What about these environments? They have no maintainers.
Should they be marked as unsupported? Are they still used?
Or should they be removed?


I compile test mingw32 very often, it's part of my build test setup.
If the build breaks, I may even fix the problem.

But perhaps darwin-user should be removed.






Re: [Qemu-devel] [PATCH v8 5/5] RESEND: Inter-VM shared memory PCI device

2010-08-11 Thread Stefan Weil

Am 11.08.2010 19:07, schrieb Paolo Bonzini:

On 08/11/2010 11:49 AM, Cam Macdonell wrote:

The win32 problems (missing mmap, maybe more) remain.
Could you please fix them?


Could that be accomplished with excluding it on Windows on the 
makefiles?


Yes, just use obj-$(CONFIG_POSIX).

Paolo




Or use obj-$(CONFIG_KVM) if that file is only reasonable when KVM is 
supported.


Stefan




Re: [Qemu-devel] [PATCH 1/2] Add kvm_set_ioeventfd_mmio_long definition for non-KVM systems

2010-08-11 Thread Stefan Weil

Am 11.08.2010 20:16, schrieb Cam Macdonell:

---
kvm-stub.c | 5 +
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/kvm-stub.c b/kvm-stub.c
index 3378bd3..d45f9fa 100644
--- a/kvm-stub.c
+++ b/kvm-stub.c
@@ -136,3 +136,8 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t 
addr, uint16_t val, bool assign)

{
return -ENOSYS;
}
+
+int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, 
bool assign)

+{
+ return -ENOSYS;
+}


Your 2nd patch disables build of ivshmem.o on non-kvm systems.
Only ivshmem.c was using kvm_set_ioeventfd_mmio_long, so
up to now, no dummy function in kvm-stub.c is needed.

Regards
Stefan



Re: [Qemu-devel] [PATCH 1/2] Add kvm_set_ioeventfd_mmio_long definition for non-KVM systems

2010-08-11 Thread Cam Macdonell
On Wed, Aug 11, 2010 at 2:28 PM, Stefan Weil w...@mail.berlios.de wrote:
 Am 11.08.2010 20:16, schrieb Cam Macdonell:

 ---
 kvm-stub.c | 5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

 diff --git a/kvm-stub.c b/kvm-stub.c
 index 3378bd3..d45f9fa 100644
 --- a/kvm-stub.c
 +++ b/kvm-stub.c
 @@ -136,3 +136,8 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr,
 uint16_t val, bool assign)
 {
 return -ENOSYS;
 }
 +
 +int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool
 assign)
 +{
 + return -ENOSYS;
 +}

 Your 2nd patch disables build of ivshmem.o on non-kvm systems.
 Only ivshmem.c was using kvm_set_ioeventfd_mmio_long, so
 up to now, no dummy function in kvm-stub.c is needed.

Right. It can be left out for now if that's preferred.

Cam



Re: [Qemu-devel] Running the user emulation

2010-08-11 Thread Natalia Portillo
You can check how NetBSD does that.

NetBSD is able to run executables from other UNIXes and POSIX-compatible 
systems, including, Linux, IRIX, Darwin.
They do that with a series of syscall conversions and library substitutions.

That should be portable to use Mac OS X as host instead of NetBSD, and to run 
thru QEMU (running x86 Linux software on PowerPC Darwin)

Regards,
Natalia Portillo

El 11/08/2010, a las 10:33, C K Kashyap escribió:

 I was wondering if it would be easy to force build the user-emulation on mac 
 - as in, lets say my a.out from linux is really trivial - even statically 
 linked for that matter. All it does is, say, write hello world\n to the 
 screen - I'd imaging that write system call would be similar on mac (as far 
 as writing to stdout is concerned)  Would it be possible/easy to give it 
 a shot?
 
 
 On Wed, Aug 11, 2010 at 2:48 PM, Stefan Weil w...@mail.berlios.de wrote:
 Am 11.08.2010 11:06, schrieb C K Kashyap:
 Let me see if I understand this right -
 
 qemu loads the a.out and begins to interpret the x86 instructions in the 
 a.out and when a system call happens, it makes the call the host system  
 is that right?
 
 
 
 Right. That's the way how linux user mode emulation (for example qemu-i386) 
 works.
 See linux-user/syscall.c if you want to see more details.
 
 bsd-user and darwin-user are also supported (more or less), but darwin-user
 only supports translation of darwin/powerpc to darwin/x86 syscalls.
 It won't help you to run a linux a.out on your mac.
 
 
 
 
 On Wed, Aug 11, 2010 at 2:12 PM, Stefan Weil w...@mail.berlios.de wrote:
 Am 11.08.2010 10:31, schrieb C K Kashyap:
 Hi,
 I've built qemu on my mac osx using this config - 
 ./configure --prefix=/Users/ckk/local/ --target-list=i386-softmmu 
 x86_64-softmmu --enable-linux-user
 
 Now, I have a simple a.out built on linux - how can I run it using qemu on 
 my mac box?
 
 -- 
 Regards,
 Kashyap
 
 Hi Kashyap,
 
 you cannot run it in user mode emulation unless you replace Mac OS by Linux
 on your mac box. Linux user emulations requires a Linux host.
 
 If you have a Linux host, you would need --target-list=i386-linux-user.
 
 You can run your a.out if you run system emulation (e.g. i386-softmmu/qemu)
 and install Linux there, of course.
 
 Regards,
 Stefan
 
 
 
 -- 
 Regards,
 Kashyap
 
 
 
 
 -- 
 Regards,
 Kashyap



Re: [Qemu-devel] Unmaintained QEMU builds

2010-08-11 Thread Blue Swirl
On Wed, Aug 11, 2010 at 6:18 PM, Stefan Weil w...@mail.berlios.de wrote:
 Am 11.08.2010 18:34, schrieb Blue Swirl:

 On Wed, Aug 11, 2010 at 10:58 AM, Stefan Weil w...@mail.berlios.de
 wrote:

 Hi,

 since several months, QEMU for Windows (and mingw32 cross builds)
 no longer builds without error.

 Not true for mingw32, it was building fine here until the latest commit.

 That's a big surprise! Do you have a mingw32 version which includes
 setenv()?
 My Debian mingw32-runtime 3.13-1 does not support setenv(), so
 compilation gives a warning and linking gives an error.

 And don't you get warnings from SDL headers which redefine
 WIN32_LEAN_AND_MEAN?

No, I have even configured with --enable-werror. But it looks like I
have forgotten to make SDL headers available. I think SDL with mingw32
worked at some point, VNC is still fine.



Re: [Qemu-devel] Unmaintained QEMU builds

2010-08-11 Thread Blue Swirl
On Wed, Aug 11, 2010 at 6:51 PM, Blue Swirl blauwir...@gmail.com wrote:
 On Wed, Aug 11, 2010 at 6:18 PM, Stefan Weil w...@mail.berlios.de wrote:
 Am 11.08.2010 18:34, schrieb Blue Swirl:

 On Wed, Aug 11, 2010 at 10:58 AM, Stefan Weil w...@mail.berlios.de
 wrote:

 Hi,

 since several months, QEMU for Windows (and mingw32 cross builds)
 no longer builds without error.

 Not true for mingw32, it was building fine here until the latest commit.

 That's a big surprise! Do you have a mingw32 version which includes
 setenv()?
 My Debian mingw32-runtime 3.13-1 does not support setenv(), so
 compilation gives a warning and linking gives an error.

 And don't you get warnings from SDL headers which redefine
 WIN32_LEAN_AND_MEAN?

 No, I have even configured with --enable-werror. But it looks like I
 have forgotten to make SDL headers available. I think SDL with mingw32
 worked at some point, VNC is still fine.

With these changes, build succeeds with SDL. For example,
qemu-system-sparc.exe can boot from a Sparc32 CD under Wine.


0001-Fix-mingw32-warnings-with-SDL.patch
Description: application/mbox


Re: [Qemu-devel] Unmaintained QEMU builds

2010-08-11 Thread Stefan Weil

Am 11.08.2010 21:19, schrieb Blue Swirl:

On Wed, Aug 11, 2010 at 6:51 PM, Blue Swirlblauwir...@gmail.com  wrote:
   

On Wed, Aug 11, 2010 at 6:18 PM, Stefan Weilw...@mail.berlios.de  wrote:
 

Am 11.08.2010 18:34, schrieb Blue Swirl:
   

On Wed, Aug 11, 2010 at 10:58 AM, Stefan Weilw...@mail.berlios.de
wrote:
 

Hi,

since several months, QEMU for Windows (and mingw32 cross builds)
no longer builds without error.
   

Not true for mingw32, it was building fine here until the latest commit.
 

That's a big surprise! Do you have a mingw32 version which includes
setenv()?
My Debian mingw32-runtime 3.13-1 does not support setenv(), so
compilation gives a warning and linking gives an error.

And don't you get warnings from SDL headers which redefine
WIN32_LEAN_AND_MEAN?
   

No, I have even configured with --enable-werror. But it looks like I
have forgotten to make SDL headers available. I think SDL with mingw32
worked at some point, VNC is still fine.
 

With these changes, build succeeds with SDL. For example,
qemu-system-sparc.exe can boot from a Sparc32 CD under Wine.
   


Yes, that's a possible solution.

You could also take these patches which I sent to qemu-devel:

http://patchwork.ozlabs.org/patch/49217/
http://patchwork.ozlabs.org/patch/57532/

Regards
Stefan




[Qemu-devel] [PATCH] make -qmp stdio usable

2010-08-11 Thread Paolo Bonzini
Currently -qmp stdio (or the equivalent -mon/-chardev combination) sets
up the terminal attributes even though it does not go through readline
to actually do I/O.  As a result, echo is disabled and you cannot see
anything you type.  This patch fixes it by adding a cooked option to
the stdio chardev backend, that when set will disable switching the tty
to raw mode.

Cc: Kevin Wolf kw...@redhat.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 qemu-char.c   |   26 ++
 qemu-config.c |3 +++
 vl.c  |3 +++
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 6a3952c..15e1891 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -735,19 +735,21 @@ static void term_init(QemuOpts *opts)
 oldtty = tty;
 old_fd0_flags = fcntl(0, F_GETFL);
 
-tty.c_iflag = ~(IGNBRK|BRKINT|PARMRK|ISTRIP
+if (!qemu_opt_get_bool(opts, cooked, 0)) {
+tty.c_iflag = ~(IGNBRK|BRKINT|PARMRK|ISTRIP
   |INLCR|IGNCR|ICRNL|IXON);
-tty.c_oflag |= OPOST;
-tty.c_lflag = ~(ECHO|ECHONL|ICANON|IEXTEN);
-/* if graphical mode, we allow Ctrl-C handling */
-if (!qemu_opt_get_bool(opts, signal, display_type != DT_NOGRAPHIC))
-tty.c_lflag = ~ISIG;
-tty.c_cflag = ~(CSIZE|PARENB);
-tty.c_cflag |= CS8;
-tty.c_cc[VMIN] = 1;
-tty.c_cc[VTIME] = 0;
-
-tcsetattr (0, TCSANOW, tty);
+tty.c_oflag |= OPOST;
+tty.c_lflag = ~(ECHO|ECHONL|ICANON|IEXTEN);
+/* if graphical mode, we allow Ctrl-C handling */
+if (!qemu_opt_get_bool(opts, signal, display_type != DT_NOGRAPHIC))
+tty.c_lflag = ~ISIG;
+tty.c_cflag = ~(CSIZE|PARENB);
+tty.c_cflag |= CS8;
+tty.c_cc[VMIN] = 1;
+tty.c_cc[VTIME] = 0;
+
+   tcsetattr (0, TCSANOW, tty);
+}
 
 if (!term_atexit_done++)
 atexit(term_exit);
diff --git a/qemu-config.c b/qemu-config.c
index 95abe61..8c525b0 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -146,6 +146,9 @@ QemuOptsList qemu_chardev_opts = {
 },{
 .name = signal,
 .type = QEMU_OPT_BOOL,
+},{
+.name = cooked,
+.type = QEMU_OPT_BOOL,
 },
 { /* end if list */ }
 },
diff --git a/vl.c b/vl.c
index b3e3676..be122e7 100644
--- a/vl.c
+++ b/vl.c
@@ -1596,6 +1596,9 @@ static void monitor_parse(const char *optarg, const char 
*mode)
 fprintf(stderr, parse error: %s\n, optarg);
 exit(1);
 }
+if (!strcmp(mode, control)) {
+qemu_opt_set(opts, cooked, on);
+}
 }
 
 opts = qemu_opts_create(qemu_mon_opts, label, 1);
-- 
1.7.1




Re: [Qemu-devel] [PATCH 1/2] Add kvm_set_ioeventfd_mmio_long definition for non-KVM systems

2010-08-11 Thread Paolo Bonzini

On 08/11/2010 02:32 PM, Cam Macdonell wrote:

On Wed, Aug 11, 2010 at 2:28 PM, Stefan Weilw...@mail.berlios.de  wrote:

Am 11.08.2010 20:16, schrieb Cam Macdonell:


---
kvm-stub.c | 5 +
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/kvm-stub.c b/kvm-stub.c
index 3378bd3..d45f9fa 100644
--- a/kvm-stub.c
+++ b/kvm-stub.c
@@ -136,3 +136,8 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr,
uint16_t val, bool assign)
{
return -ENOSYS;
}
+
+int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool
assign)
+{
+ return -ENOSYS;
+}


Your 2nd patch disables build of ivshmem.o on non-kvm systems.
Only ivshmem.c was using kvm_set_ioeventfd_mmio_long, so
up to now, no dummy function in kvm-stub.c is needed.


Right. It can be left out for now if that's preferred.


No, your patch is correct.  If kvm-stub.c is not complete, the build 
will break the next time someone uses one of those functions.


Paolo



[Qemu-devel] Re: Unmaintained QEMU builds

2010-08-11 Thread Paolo Bonzini

On 08/11/2010 03:37 PM, Stefan Weil wrote:

With these changes, build succeeds with SDL. For example,
qemu-system-sparc.exe can boot from a Sparc32 CD under Wine.


Yes, that's a possible solution.

You could also take these patches which I sent to qemu-devel:

http://patchwork.ozlabs.org/patch/49217/
http://patchwork.ozlabs.org/patch/57532/


The latter change is already in Blue Swirl's patch.

The former is for the setenv issue.  Jes Sorensen asked you to make some 
changes, and you never replied; this is the best way to keep your patch 
*out* of the tree.  Blue Swirl patch is suboptimal with respect to 
setenv, because the setenv is actually useful under Win32, but I still 
think it should go in---and then you can fix it in a better way if you 
want to follow the rules of the community.


Paolo