Re: [Qemu-devel] [RFC V6 27/33] qcow2: Adapt checking of QCOW_OFLAG_COPIED for dedup.

2013-03-01 Thread Kevin Wolf
Am 28.02.2013 um 17:14 hat Benoît Canet geschrieben:
 Le Thursday 28 Feb 2013 à 11:14:34 (+0100), Kevin Wolf a écrit :
  Am 28.02.2013 um 10:41 hat Stefan Hajnoczi geschrieben:
   On Wed, Feb 27, 2013 at 04:00:28PM +0100, Benoît Canet wrote:
  -if ((refcount == 1) != ((l2_entry  
  QCOW_OFLAG_COPIED) != 0)) {
  +if (!s-has_dedup 
  +(refcount == 1) != ((l2_entry  
  QCOW_OFLAG_COPIED) != 0)) {
  +fprintf(stderr, ERROR OFLAG_COPIED: offset=%
  +PRIx64  refcount=%d\n, l2_entry, 
  refcount);
  +res-corruptions++;
  +}
 
 Why is this warning suppressed when dedup is enabled?  The meaning of
 QCOW_OFLAG_COPIED is that refcount == 1.  If this invariant is 
 violated
 then something is wrong.

When deduplication is done refcount will be bigger than one and
QCOW_OFLAG_COPIED will be cleared.

Then if enough logical clustere pointing to the same physical cluster 
are
rewritten with something else the refcount will goes down back to one.

But this time QCOW_OFLAG_COPIED can be set back so this equality won't 
be true.
   
   When the refcount decreases to 1 again we need to set QCOW_OFLAG_COPIED
   again.  qcow2-snapshot.c:qcow2_snapshot_delete() does this with:
   
   /* must update the copied flag on the current cluster offsets */
   ret = qcow2_update_snapshot_refcount(bs, s-l1_table_offset, 
   s-l1_size, 0);
   
   Is dedup not restoring QCOW_OFLAG_COPIED?
  
  This is a very expensive operation. I don't think that you can do it for
  each deduplicated cluster that is overwritten. Not doing it comes with
  the cost of doing more COW than is actually needed. And we need to
  mention in the spec that QCOW_OFLAG_COPIED can be missing on clusters
  with deduplication enabled.
 
 Also when two logical clusters point to the same physical cluster and one of 
 the
 logical cluster get overwritten the deduplication code has no way to know the
 index of the last logical cluster entry.

Well, strictly speaking you can. The qcow2_update_snapshot_refcount()
call that Stefan mention does exactly that. It's just insanely expensive
because it has to look at the refcounts for all clusters.

Kevin



[Qemu-devel] [RfC PATCH 04/12] qxl: zap qxl0 global

2013-03-01 Thread Gerd Hoffmann
DisplayChangeListener is passed now to all DisplayChangeListenerOps
callbacks, so we can use that to access the qxl state and kill the
qxl0 global variable.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/qxl.c |   28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index cb3d317..cc0ba40 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -118,8 +118,6 @@ static QXLMode qxl_modes[] = {
 QXL_MODE_EX(3200, 2400),
 };
 
-static PCIQXLDevice *qxl0;
-
 static void qxl_send_events(PCIQXLDevice *d, uint32_t events);
 static int qxl_destroy_primary(PCIQXLDevice *d, qxl_async_io async);
 static void qxl_reset_memslots(PCIQXLDevice *d);
@@ -1870,28 +1868,34 @@ static void display_update(DisplayChangeListener *dcl,
struct DisplayState *ds,
int x, int y, int w, int h)
 {
-if (qxl0-mode == QXL_MODE_VGA) {
-qemu_spice_display_update(qxl0-ssd, x, y, w, h);
+PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl);
+
+if (qxl-mode == QXL_MODE_VGA) {
+qemu_spice_display_update(qxl-ssd, x, y, w, h);
 }
 }
 
 static void display_resize(DisplayChangeListener *dcl,
struct DisplayState *ds)
 {
-if (qxl0-mode == QXL_MODE_VGA) {
-qemu_spice_display_resize(qxl0-ssd);
+PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl);
+
+if (qxl-mode == QXL_MODE_VGA) {
+qemu_spice_display_resize(qxl-ssd);
 }
 }
 
 static void display_refresh(DisplayChangeListener *dcl,
 struct DisplayState *ds)
 {
-if (qxl0-mode == QXL_MODE_VGA) {
-qemu_spice_display_refresh(qxl0-ssd);
+PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl);
+
+if (qxl-mode == QXL_MODE_VGA) {
+qemu_spice_display_refresh(qxl-ssd);
 } else {
-qemu_mutex_lock(qxl0-ssd.lock);
-qemu_spice_cursor_refresh_unlocked(qxl0-ssd);
-qemu_mutex_unlock(qxl0-ssd.lock);
+qemu_mutex_lock(qxl-ssd.lock);
+qemu_spice_cursor_refresh_unlocked(qxl-ssd);
+qemu_mutex_unlock(qxl-ssd.lock);
 }
 }
 
@@ -2074,8 +2078,6 @@ static int qxl_init_primary(PCIDevice *dev)
qxl_hw_screen_dump, qxl_hw_text_update, 
qxl);
 qemu_spice_display_init_common(qxl-ssd, vga-ds);
 
-qxl0 = qxl;
-
 rc = qxl_init_common(qxl);
 if (rc != 0) {
 return rc;
-- 
1.7.9.7




[Qemu-devel] [RfC PATCH 10/12] gtk: stop using DisplayState

2013-03-01 Thread Gerd Hoffmann
Rework DisplayStateListener callbacks to not use the DisplayState
any more.  Factor out the window size handling to a separate function,
so the zoom callbacks can call that directly instead of abusing the
gd_switch DisplayStateListener callback for that.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 ui/gtk.c |  140 +++---
 1 file changed, 80 insertions(+), 60 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index abef1ca..f06f18e 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -143,7 +143,7 @@ typedef struct GtkDisplayState
 GtkWidget *drawing_area;
 cairo_surface_t *surface;
 DisplayChangeListener dcl;
-DisplayState *ds;
+DisplaySurface *ds;
 int button_mask;
 int last_x;
 int last_y;
@@ -225,10 +225,48 @@ static void gd_update_caption(GtkDisplayState *s)
 g_free(title);
 }
 
+static void gd_update_windowsize(GtkDisplayState *s)
+{
+if (!s-full_screen) {
+GtkRequisition req;
+double sx, sy;
+
+if (s-free_scale) {
+sx = s-scale_x;
+sy = s-scale_y;
+
+s-scale_y = 1.0;
+s-scale_x = 1.0;
+} else {
+sx = 1.0;
+sy = 1.0;
+}
+
+gtk_widget_set_size_request(s-drawing_area,
+surface_width(s-ds) * s-scale_x,
+surface_height(s-ds) * s-scale_y);
+#if GTK_CHECK_VERSION(3, 0, 0)
+gtk_widget_get_preferred_size(s-vbox, NULL, req);
+#else
+gtk_widget_size_request(s-vbox, req);
+#endif
+
+gtk_window_resize(GTK_WINDOW(s-window),
+  req.width * sx, req.height * sy);
+}
+}
+
+static void gd_update_full_redraw(GtkDisplayState *s)
+{
+int ww, wh;
+gdk_drawable_get_size(gtk_widget_get_window(s-drawing_area), ww, wh);
+gtk_widget_queue_draw_area(s-drawing_area, 0, 0, ww, wh);
+}
+
 /** DisplayState Callbacks **/
 
 static void gd_update(DisplayChangeListener *dcl,
-  DisplayState *ds, int x, int y, int w, int h)
+  DisplayState *dontuse, int x, int y, int w, int h)
 {
 GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
 int x1, x2, y1, y2;
@@ -244,8 +282,8 @@ static void gd_update(DisplayChangeListener *dcl,
 x2 = ceil(x * s-scale_x + w * s-scale_x);
 y2 = ceil(y * s-scale_y + h * s-scale_y);
 
-fbw = ds_get_width(s-ds) * s-scale_x;
-fbh = ds_get_height(s-ds) * s-scale_y;
+fbw = surface_width(s-ds) * s-scale_x;
+fbh = surface_height(s-ds) * s-scale_y;
 
 gdk_drawable_get_size(gtk_widget_get_window(s-drawing_area), ww, wh);
 
@@ -261,27 +299,34 @@ static void gd_update(DisplayChangeListener *dcl,
 }
 
 static void gd_refresh(DisplayChangeListener *dcl,
-   DisplayState *ds)
+   DisplayState *dontuse)
 {
 vga_hw_update();
 }
 
 static void gd_switch(DisplayChangeListener *dcl,
-  DisplayState *ds,
+  DisplayState *dontuse,
   DisplaySurface *surface)
 {
 GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
 cairo_format_t kind;
+bool resized = true;
 int stride;
 
 DPRINTF(resize(width=%d, height=%d)\n,
-ds_get_width(ds), ds_get_height(ds));
+surface_width(surface), surface_height(surface));
 
 if (s-surface) {
 cairo_surface_destroy(s-surface);
 }
 
-switch (ds-surface-pf.bits_per_pixel) {
+if (s-ds 
+surface_width(s-ds) == surface_width(surface) 
+surface_height(s-ds) == surface_height(surface)) {
+resized = false;
+}
+s-ds = surface;
+switch (surface_bits_per_pixel(surface)) {
 case 8:
 kind = CAIRO_FORMAT_A8;
 break;
@@ -296,41 +341,19 @@ static void gd_switch(DisplayChangeListener *dcl,
 break;
 }
 
-stride = cairo_format_stride_for_width(kind, ds_get_width(ds));
-g_assert(ds_get_linesize(ds) == stride);
+stride = cairo_format_stride_for_width(kind, surface_width(surface));
+g_assert(surface_stride(surface) == stride);
 
-s-surface = cairo_image_surface_create_for_data(ds_get_data(ds),
+s-surface = cairo_image_surface_create_for_data(surface_data(surface),
  kind,
- ds_get_width(ds),
- ds_get_height(ds),
- ds_get_linesize(ds));
-
-if (!s-full_screen) {
-GtkRequisition req;
-double sx, sy;
-
-if (s-free_scale) {
-sx = s-scale_x;
-sy = s-scale_y;
-
-s-scale_y = 1.0;
-s-scale_x = 1.0;
-} else {
-sx = 1.0;
-sy = 1.0;
-}
-
-gtk_widget_set_size_request(s-drawing_area,
-

[Qemu-devel] [RfC PATCH 00/12] console/display: cleanup untangle data structures.

2013-03-01 Thread Gerd Hoffmann
  Hi,

This patch series continues the console  display code cleanups.
It's RfC because it is (a) not complete yet and (b) most likely
breaks the build (xen, cocoa).  If someone wants help fill the
gaps (especially cocoa) patches are very welcome.

The short-team goal I'm heading to is to make the DisplaySurface
(and *only* the DisplaySurface) the central data structure for
the display renderers in ui/.  They get one, they render it, they
are notified about updates, they are notified when the surface
changes.  Done, there is nothing else they need to know or care
about.

The longer-term goal building on top of this is to put the console
internals upside down (without having to touch the ui renderers in
the process).  I want have one DisplaySurface per console, which then
lives forever, and console switches (Ctrl-Alt-$number in vnc+sdl)
become a simple surface switch.  Alternative ways to handle consoles
becomes alot easier to implement, in gtk we can probably simply put
each DisplaySurface into one tab.  The need to ask the vga emulation
to redraw the screen on console switches goes away, vga_hw_invalidate
can be zapped.  We can stop hopping through loops for screendumps,
we can just write out the DisplaySurface content.

Oh, and this also paves the way to handle multihead in a reasonable
way.

cheers,
  Gerd

Gerd Hoffmann (12):
  console: fix displaychangelisteners interface
  console: kill DisplayState-opaque
  spice: zap sdpy global
  qxl: zap qxl0 global
  qxl: better vga init in enter_vga_mode
  sdl: drop dead code
  console: rework DisplaySurface handling [vga emu side]
  console: rework DisplaySurface handling [dcl/ui side]
  console: add surface_*() getters
  gtk: stop using DisplayState
  vnc: stop using DisplayState
  sdl: stop using DisplayState

 hw/nseries.c   |7 --
 hw/palm.c  |7 --
 hw/qxl-render.c|   12 +--
 hw/qxl.c   |   51 ++
 hw/vga.c   |   17 ++--
 include/ui/console.h   |  226 +++-
 include/ui/spice-display.h |4 +-
 trace-events   |7 +-
 ui/cocoa.m |   26 +++--
 ui/console.c   |  193 +++--
 ui/curses.c|   32 +--
 ui/gtk.c   |  162 ++-
 ui/sdl.c   |  123 ++--
 ui/spice-display.c |   51 ++
 ui/vnc-enc-tight.c |7 +-
 ui/vnc-jobs.c  |1 -
 ui/vnc.c   |  144 +++-
 ui/vnc.h   |4 +-
 vl.c   |6 +-
 19 files changed, 611 insertions(+), 469 deletions(-)

-- 
1.7.9.7




[Qemu-devel] [RfC PATCH 06/12] sdl: drop dead code

2013-03-01 Thread Gerd Hoffmann
DisplayAllocator removal made this a nop.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 ui/sdl.c |5 -
 1 file changed, 5 deletions(-)

diff --git a/ui/sdl.c b/ui/sdl.c
index 5baffa0..fc4dc1b 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -458,11 +458,6 @@ static void sdl_scale(DisplayState *ds, int width, int 
height)
 }
 do_sdl_resize(width, height, bpp);
 scaling_active = 1;
-if (!is_buffer_shared(ds-surface)) {
-ds-surface = qemu_resize_displaysurface(ds, ds_get_width(ds),
- ds_get_height(ds));
-dpy_gfx_resize(ds);
-}
 }
 
 static void toggle_full_screen(DisplayState *ds)
-- 
1.7.9.7




[Qemu-devel] [RfC PATCH 09/12] console: add surface_*() getters

2013-03-01 Thread Gerd Hoffmann
Add convinence wrappers to query DisplaySurface properties.
Simliar to ds_get_*, but operating in the DisplaySurface
not the DisplayState.

With this patch in place ui frontents can stop using DisplayState
in the rendering code paths, they can simply operate using the
DisplaySurface passed in via dpy_gfx_switch callback.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 include/ui/console.h |   46 ++
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index f15a541..ab59e15 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -244,36 +244,66 @@ void dpy_mouse_set(struct DisplayState *s, int x, int y, 
int on);
 void dpy_cursor_define(struct DisplayState *s, QEMUCursor *cursor);
 bool dpy_cursor_define_supported(struct DisplayState *s);
 
+static inline int surface_stride(DisplaySurface *s)
+{
+return pixman_image_get_stride(s-image);
+}
+
+static inline void *surface_data(DisplaySurface *s)
+{
+return pixman_image_get_data(s-image);
+}
+
+static inline int surface_width(DisplaySurface *s)
+{
+return pixman_image_get_width(s-image);
+}
+
+static inline int surface_height(DisplaySurface *s)
+{
+return pixman_image_get_height(s-image);
+}
+
+static inline int surface_bits_per_pixel(DisplaySurface *s)
+{
+int bits = PIXMAN_FORMAT_BPP(s-format);
+return bits;
+}
+
+static inline int surface_bytes_per_pixel(DisplaySurface *s)
+{
+int bits = PIXMAN_FORMAT_BPP(s-format);
+return (bits + 7) / 8;
+}
+
 static inline int ds_get_linesize(DisplayState *ds)
 {
-return pixman_image_get_stride(ds-surface-image);
+return surface_stride(ds-surface);
 }
 
 static inline uint8_t* ds_get_data(DisplayState *ds)
 {
-return (void *)pixman_image_get_data(ds-surface-image);
+return surface_data(ds-surface);
 }
 
 static inline int ds_get_width(DisplayState *ds)
 {
-return pixman_image_get_width(ds-surface-image);
+return surface_width(ds-surface);
 }
 
 static inline int ds_get_height(DisplayState *ds)
 {
-return pixman_image_get_height(ds-surface-image);
+return surface_height(ds-surface);
 }
 
 static inline int ds_get_bits_per_pixel(DisplayState *ds)
 {
-int bits = PIXMAN_FORMAT_BPP(ds-surface-format);
-return bits;
+return surface_bits_per_pixel(ds-surface);
 }
 
 static inline int ds_get_bytes_per_pixel(DisplayState *ds)
 {
-int bits = PIXMAN_FORMAT_BPP(ds-surface-format);
-return (bits + 7) / 8;
+return surface_bytes_per_pixel(ds-surface);
 }
 
 static inline pixman_format_code_t ds_get_format(DisplayState *ds)
-- 
1.7.9.7




[Qemu-devel] [RfC PATCH 05/12] qxl: better vga init in enter_vga_mode

2013-03-01 Thread Gerd Hoffmann
Ask the vga core to update the display.  Will trigger dpy_gfx_resize
if needed.  More complete than just calling dpy_gfx_resize.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/qxl.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index cc0ba40..8177008 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1073,8 +1073,8 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d)
 trace_qxl_enter_vga_mode(d-id);
 qemu_spice_create_host_primary(d-ssd);
 d-mode = QXL_MODE_VGA;
-dpy_gfx_resize(d-ssd.ds);
 vga_dirty_log_start(d-vga);
+vga_hw_update();
 }
 
 static void qxl_exit_vga_mode(PCIQXLDevice *d)
-- 
1.7.9.7




[Qemu-devel] [RfC PATCH 11/12] vnc: stop using DisplayState

2013-03-01 Thread Gerd Hoffmann
Rework DisplayStateListener callbacks to not use the DisplayState
any more.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 ui/vnc-enc-tight.c |7 ++---
 ui/vnc-jobs.c  |1 -
 ui/vnc.c   |   73 +---
 ui/vnc.h   |3 +--
 4 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 4ddea7d..e6966ae 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -123,7 +123,7 @@ static bool tight_can_send_png_rect(VncState *vs, int w, 
int h)
 return false;
 }
 
-if (ds_get_bytes_per_pixel(vs-ds) == 1 ||
+if (surface_bytes_per_pixel(vs-vd-ds) == 1 ||
 vs-client_pf.bytes_per_pixel == 1) {
 return false;
 }
@@ -301,7 +301,7 @@ tight_detect_smooth_image(VncState *vs, int w, int h)
 return 0;
 }
 
-if (ds_get_bytes_per_pixel(vs-ds) == 1 ||
+if (surface_bytes_per_pixel(vs-vd-ds) == 1 ||
 vs-client_pf.bytes_per_pixel == 1 ||
 w  VNC_TIGHT_DETECT_MIN_WIDTH || h  VNC_TIGHT_DETECT_MIN_HEIGHT) {
 return 0;
@@ -1184,8 +1184,9 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int 
w, int h, int quality)
 uint8_t *buf;
 int dy;
 
-if (ds_get_bytes_per_pixel(vs-ds) == 1)
+if (surface_bytes_per_pixel(vs-vd-ds) == 1) {
 return send_full_color_rect(vs, x, y, w, h);
+}
 
 buffer_reserve(vs-tight.jpeg, 2048);
 
diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c
index 0bfc0c5..2d3fce8 100644
--- a/ui/vnc-jobs.c
+++ b/ui/vnc-jobs.c
@@ -183,7 +183,6 @@ static void vnc_async_encoding_start(VncState *orig, 
VncState *local)
 {
 local-vnc_encoding = orig-vnc_encoding;
 local-features = orig-features;
-local-ds = orig-ds;
 local-vd = orig-vd;
 local-lossy_rect = orig-lossy_rect;
 local-write_pixels = orig-write_pixels;
diff --git a/ui/vnc.c b/ui/vnc.c
index f8398c3..ea6f37c 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -519,17 +519,17 @@ void buffer_advance(Buffer *buf, size_t len)
 
 static void vnc_desktop_resize(VncState *vs)
 {
-DisplayState *ds = vs-ds;
+DisplaySurface *ds = vs-vd-ds;
 
 if (vs-csock == -1 || !vnc_has_feature(vs, VNC_FEATURE_RESIZE)) {
 return;
 }
-if (vs-client_width == ds_get_width(ds) 
-vs-client_height == ds_get_height(ds)) {
+if (vs-client_width == surface_width(ds) 
+vs-client_height == surface_height(ds)) {
 return;
 }
-vs-client_width = ds_get_width(ds);
-vs-client_height = ds_get_height(ds);
+vs-client_width = surface_width(ds);
+vs-client_height = surface_height(ds);
 vnc_lock_output(vs);
 vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
 vnc_write_u8(vs, 0);
@@ -575,7 +575,7 @@ void *vnc_server_fb_ptr(VncDisplay *vd, int x, int y)
 }
 
 static void vnc_dpy_switch(DisplayChangeListener *dcl,
-   DisplayState *ds,
+   DisplayState *dontuse,
DisplaySurface *surface)
 {
 VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
@@ -585,9 +585,10 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl,
 
 /* server surface */
 qemu_pixman_image_unref(vd-server);
+vd-ds = surface;
 vd-server = pixman_image_create_bits(VNC_SERVER_FB_FORMAT,
-  ds_get_width(ds),
-  ds_get_height(ds),
+  surface_width(vd-ds),
+  surface_height(vd-ds),
   NULL, 0);
 
 /* guest surface */
@@ -596,8 +597,8 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl,
 console_color_init(ds);
 #endif
 qemu_pixman_image_unref(vd-guest.fb);
-vd-guest.fb = pixman_image_ref(ds-surface-image);
-vd-guest.format = ds-surface-format;
+vd-guest.fb = pixman_image_ref(surface-image);
+vd-guest.format = surface-format;
 memset(vd-guest.dirty, 0xFF, sizeof(vd-guest.dirty));
 
 QTAILQ_FOREACH(vs, vd-clients, next) {
@@ -739,7 +740,7 @@ static void vnc_copy(VncState *vs, int src_x, int src_y, 
int dst_x, int dst_y, i
 }
 
 static void vnc_dpy_copy(DisplayChangeListener *dcl,
- DisplayState *ds,
+ DisplayState *dontuse,
  int src_x, int src_y,
  int dst_x, int dst_y, int w, int h)
 {
@@ -813,7 +814,7 @@ static void vnc_dpy_copy(DisplayChangeListener *dcl,
 }
 
 static void vnc_mouse_set(DisplayChangeListener *dcl,
-  DisplayState *ds,
+  DisplayState *dontuse,
   int x, int y, int visible)
 {
 /* can we ask the client(s) to move the pointer ??? */
@@ -841,7 +842,7 @@ static int vnc_cursor_define(VncState *vs)
 }
 
 static void vnc_dpy_cursor_define(DisplayChangeListener *dcl,
-  

[Qemu-devel] [RfC PATCH 03/12] spice: zap sdpy global

2013-03-01 Thread Gerd Hoffmann
DisplayChangeListener is passed now to all DisplayChangeListenerOps
callbacks, so we can use that to access the spice display state and
kill the sdpy global variable.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 ui/spice-display.c |   30 --
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/ui/spice-display.c b/ui/spice-display.c
index b6528fa..b2bda23 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -581,25 +581,26 @@ static const QXLInterface dpy_interface = {
 .client_monitors_config  = interface_client_monitors_config,
 };
 
-static SimpleSpiceDisplay sdpy;
-
 static void display_update(DisplayChangeListener *dcl,
struct DisplayState *ds,
int x, int y, int w, int h)
 {
-qemu_spice_display_update(sdpy, x, y, w, h);
+SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
+qemu_spice_display_update(ssd, x, y, w, h);
 }
 
 static void display_resize(DisplayChangeListener *dcl,
struct DisplayState *ds)
 {
-qemu_spice_display_resize(sdpy);
+SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
+qemu_spice_display_resize(ssd);
 }
 
 static void display_refresh(DisplayChangeListener *dcl,
 struct DisplayState *ds)
 {
-qemu_spice_display_refresh(sdpy);
+SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
+qemu_spice_display_refresh(ssd);
 }
 
 static const DisplayChangeListenerOps display_listener_ops = {
@@ -611,16 +612,17 @@ static const DisplayChangeListenerOps 
display_listener_ops = {
 
 void qemu_spice_display_init(DisplayState *ds)
 {
-assert(sdpy.ds == NULL);
-qemu_spice_display_init_common(sdpy, ds);
+SimpleSpiceDisplay *ssd = g_new0(SimpleSpiceDisplay, 1);
+
+qemu_spice_display_init_common(ssd, ds);
 
-sdpy.qxl.base.sif = dpy_interface.base;
-qemu_spice_add_interface(sdpy.qxl.base);
-assert(sdpy.worker);
+ssd-qxl.base.sif = dpy_interface.base;
+qemu_spice_add_interface(ssd-qxl.base);
+assert(ssd-worker);
 
-qemu_spice_create_host_memslot(sdpy);
-qemu_spice_create_host_primary(sdpy);
+qemu_spice_create_host_memslot(ssd);
+qemu_spice_create_host_primary(ssd);
 
-sdpy.dcl.ops = display_listener_ops;
-register_displaychangelistener(ds, sdpy.dcl);
+ssd-dcl.ops = display_listener_ops;
+register_displaychangelistener(ds, ssd-dcl);
 }
-- 
1.7.9.7




[Qemu-devel] [RfC PATCH 12/12] sdl: stop using DisplayState

2013-03-01 Thread Gerd Hoffmann
Rework DisplayStateListener callbacks to not use the DisplayState
any more.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 ui/sdl.c |   92 ++
 1 file changed, 51 insertions(+), 41 deletions(-)

diff --git a/ui/sdl.c b/ui/sdl.c
index 85eefdf..58f16bc 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -35,6 +35,7 @@
 #include sdl_zoom.h
 
 static DisplayChangeListener *dcl;
+static DisplaySurface *surface;
 static SDL_Surface *real_screen;
 static SDL_Surface *guest_screen = NULL;
 static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
@@ -60,7 +61,7 @@ static int scaling_active = 0;
 static Notifier mouse_mode_notifier;
 
 static void sdl_update(DisplayChangeListener *dcl,
-   DisplayState *ds,
+   DisplayState *dontuse,
int x, int y, int w, int h)
 {
 //printf(updating x=%d y=%d w=%d h=%d\n, x, y, w, h);
@@ -83,17 +84,6 @@ static void sdl_update(DisplayChangeListener *dcl,
 SDL_UpdateRect(real_screen, rec.x, rec.y, rec.w, rec.h);
 }
 
-static void sdl_setdata(DisplayChangeListener *dcl,
-DisplayState *ds)
-{
-if (guest_screen != NULL) SDL_FreeSurface(guest_screen);
-
-guest_screen = SDL_CreateRGBSurfaceFrom(ds_get_data(ds), ds_get_width(ds), 
ds_get_height(ds),
-ds_get_bits_per_pixel(ds), 
ds_get_linesize(ds),
-ds-surface-pf.rmask, 
ds-surface-pf.gmask,
-ds-surface-pf.bmask, 
ds-surface-pf.amask);
-}
-
 static void do_sdl_resize(int width, int height, int bpp)
 {
 int flags;
@@ -118,16 +108,32 @@ static void do_sdl_resize(int width, int height, int bpp)
 }
 
 static void sdl_switch(DisplayChangeListener *dcl,
-   DisplayState *ds,
-   DisplaySurface *surface)
+   DisplayState *dontuse,
+   DisplaySurface *new_surface)
 {
+
+/* temporary hack: allows to call sdl_switch to handle scaling changes */
+if (new_surface) {
+surface = new_surface;
+}
+
 if (!scaling_active) {
-do_sdl_resize(ds_get_width(ds), ds_get_height(ds), 0);
-} else if (real_screen-format-BitsPerPixel != ds_get_bits_per_pixel(ds)) 
{
+do_sdl_resize(surface_width(surface), surface_height(surface), 0);
+} else if (real_screen-format-BitsPerPixel !=
+   surface_bits_per_pixel(surface)) {
 do_sdl_resize(real_screen-w, real_screen-h,
-  ds_get_bits_per_pixel(ds));
+  surface_bits_per_pixel(surface));
 }
-sdl_setdata(dcl, ds);
+
+if (guest_screen != NULL) {
+SDL_FreeSurface(guest_screen);
+}
+guest_screen = SDL_CreateRGBSurfaceFrom
+(surface_data(surface),
+ surface_width(surface), surface_height(surface),
+ surface_bits_per_pixel(surface), surface_stride(surface),
+ surface-pf.rmask, surface-pf.gmask,
+ surface-pf.bmask, surface-pf.amask);
 }
 
 /* generic keyboard conversion */
@@ -450,7 +456,7 @@ static void sdl_send_mouse_event(int dx, int dy, int dz, 
int x, int y, int state
 kbd_mouse_event(dx, dy, dz, buttons);
 }
 
-static void sdl_scale(DisplayState *ds, int width, int height)
+static void sdl_scale(int width, int height)
 {
 int bpp = real_screen-format-BitsPerPixel;
 
@@ -461,25 +467,28 @@ static void sdl_scale(DisplayState *ds, int width, int 
height)
 scaling_active = 1;
 }
 
-static void toggle_full_screen(DisplayState *ds)
+static void toggle_full_screen(void)
 {
+int width = surface_width(surface);
+int height = surface_height(surface);
+int bpp = surface_bits_per_pixel(surface);
+
 gui_fullscreen = !gui_fullscreen;
 if (gui_fullscreen) {
 gui_saved_width = real_screen-w;
 gui_saved_height = real_screen-h;
 gui_saved_scaling = scaling_active;
 
-do_sdl_resize(ds_get_width(ds), ds_get_height(ds),
-  ds_get_bits_per_pixel(ds));
+do_sdl_resize(width, height, bpp);
 scaling_active = 0;
 
 gui_saved_grab = gui_grab;
 sdl_grab_start();
 } else {
 if (gui_saved_scaling) {
-sdl_scale(ds, gui_saved_width, gui_saved_height);
+sdl_scale(gui_saved_width, gui_saved_height);
 } else {
-do_sdl_resize(ds_get_width(ds), ds_get_height(ds), 0);
+do_sdl_resize(width, height, 0);
 }
 if (!gui_saved_grab || !is_graphic_console()) {
 sdl_grab_end();
@@ -489,7 +498,7 @@ static void toggle_full_screen(DisplayState *ds)
 vga_hw_update();
 }
 
-static void handle_keydown(DisplayState *ds, SDL_Event *ev)
+static void handle_keydown(SDL_Event *ev)
 {
 int mod_state;
 int keycode;
@@ -508,13 +517,13 @@ static void handle_keydown(DisplayState *ds, SDL_Event 
*ev)
 

[Qemu-devel] [RfC PATCH 01/12] console: fix displaychangelisteners interface

2013-03-01 Thread Gerd Hoffmann
Split callbacks into separate Ops struct.  Pass DisplayChangeListener
pointer as first argument to all callbacks.  Uninline a bunch of
display functions and move them from console.h to console.c

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/qxl.c   |   18 ++--
 include/ui/console.h   |  207 
 include/ui/spice-display.h |1 +
 trace-events   |2 +
 ui/cocoa.m |   26 --
 ui/console.c   |  144 ++
 ui/curses.c|   32 ---
 ui/gtk.c   |   30 ---
 ui/sdl.c   |   44 ++
 ui/spice-display.c |   19 ++--
 ui/vnc.c   |   44 +++---
 vl.c   |6 +-
 12 files changed, 345 insertions(+), 228 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index 2e1c5e2..cb3d317 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1866,21 +1866,25 @@ static void qxl_vm_change_state_handler(void *opaque, 
int running,
 
 /* display change listener */
 
-static void display_update(struct DisplayState *ds, int x, int y, int w, int h)
+static void display_update(DisplayChangeListener *dcl,
+   struct DisplayState *ds,
+   int x, int y, int w, int h)
 {
 if (qxl0-mode == QXL_MODE_VGA) {
 qemu_spice_display_update(qxl0-ssd, x, y, w, h);
 }
 }
 
-static void display_resize(struct DisplayState *ds)
+static void display_resize(DisplayChangeListener *dcl,
+   struct DisplayState *ds)
 {
 if (qxl0-mode == QXL_MODE_VGA) {
 qemu_spice_display_resize(qxl0-ssd);
 }
 }
 
-static void display_refresh(struct DisplayState *ds)
+static void display_refresh(DisplayChangeListener *dcl,
+struct DisplayState *ds)
 {
 if (qxl0-mode == QXL_MODE_VGA) {
 qemu_spice_display_refresh(qxl0-ssd);
@@ -1891,10 +1895,11 @@ static void display_refresh(struct DisplayState *ds)
 }
 }
 
-static DisplayChangeListener display_listener = {
+static DisplayChangeListenerOps display_listener_ops = {
+.dpy_name= spice/qxl,
 .dpy_gfx_update  = display_update,
 .dpy_gfx_resize  = display_resize,
-.dpy_refresh = display_refresh,
+.dpy_refresh = display_refresh,
 };
 
 static void qxl_init_ramsize(PCIQXLDevice *qxl)
@@ -2076,7 +2081,8 @@ static int qxl_init_primary(PCIDevice *dev)
 return rc;
 }
 
-register_displaychangelistener(vga-ds, display_listener);
+qxl-ssd.dcl.ops = display_listener_ops;
+register_displaychangelistener(vga-ds, qxl-ssd.dcl);
 return rc;
 }
 
diff --git a/include/ui/console.h b/include/ui/console.h
index c42bca6..695eabb 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -147,24 +147,46 @@ void cursor_set_mono(QEMUCursor *c,
 void cursor_get_mono_image(QEMUCursor *c, int foreground, uint8_t *mask);
 void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask);
 
-struct DisplayChangeListener {
-int idle;
-uint64_t gui_timer_interval;
-
-void (*dpy_refresh)(struct DisplayState *s);
-
-void (*dpy_gfx_update)(struct DisplayState *s, int x, int y, int w, int h);
-void (*dpy_gfx_resize)(struct DisplayState *s);
-void (*dpy_gfx_setdata)(struct DisplayState *s);
-void (*dpy_gfx_copy)(struct DisplayState *s, int src_x, int src_y,
+typedef struct DisplayChangeListenerOps {
+const char *dpy_name;
+
+void (*dpy_refresh)(DisplayChangeListener *dcl,
+struct DisplayState *s);
+
+void (*dpy_gfx_update)(DisplayChangeListener *dcl,
+   struct DisplayState *s,
+   int x, int y, int w, int h);
+void (*dpy_gfx_resize)(DisplayChangeListener *dcl,
+   struct DisplayState *s);
+void (*dpy_gfx_setdata)(DisplayChangeListener *dcl,
+struct DisplayState *s);
+void (*dpy_gfx_copy)(DisplayChangeListener *dcl,
+ struct DisplayState *s, int src_x, int src_y,
  int dst_x, int dst_y, int w, int h);
 
-void (*dpy_text_cursor)(struct DisplayState *s, int x, int y);
-void (*dpy_text_resize)(struct DisplayState *s, int w, int h);
-void (*dpy_text_update)(struct DisplayState *s, int x, int y, int w, int 
h);
+void (*dpy_text_cursor)(DisplayChangeListener *dcl,
+struct DisplayState *s,
+int x, int y);
+void (*dpy_text_resize)(DisplayChangeListener *dcl,
+struct DisplayState *s,
+int w, int h);
+void (*dpy_text_update)(DisplayChangeListener *dcl,
+struct DisplayState *s,
+int x, int y, int w, int h);
+
+void (*dpy_mouse_set)(DisplayChangeListener *dcl,
+  struct DisplayState *s,
+

[Qemu-devel] [RfC PATCH 02/12] console: kill DisplayState-opaque

2013-03-01 Thread Gerd Hoffmann
It's broken by design.  There can be multiple DisplayChangeListener
instances, so they simply can't store state in the (single) DisplayState
struct.  Try 'qemu -display gtk -vnc :0', watch it crash  burn.

With DisplayChangeListenerOps having a more sane interface now we can
simply use the DisplayChangeListener pointer to get access to our
private data instead.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 include/ui/console.h |1 -
 ui/gtk.c |5 ++---
 ui/vnc.c |   38 +-
 ui/vnc.h |1 +
 4 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 695eabb..0fe9e50 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -193,7 +193,6 @@ struct DisplayChangeListener {
 
 struct DisplayState {
 struct DisplaySurface *surface;
-void *opaque;
 struct QEMUTimer *gui_timer;
 bool have_gfx;
 bool have_text;
diff --git a/ui/gtk.c b/ui/gtk.c
index e89d4b1..fe58494 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -230,7 +230,7 @@ static void gd_update_caption(GtkDisplayState *s)
 static void gd_update(DisplayChangeListener *dcl,
   DisplayState *ds, int x, int y, int w, int h)
 {
-GtkDisplayState *s = ds-opaque;
+GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
 int x1, x2, y1, y2;
 int mx, my;
 int fbw, fbh;
@@ -269,7 +269,7 @@ static void gd_refresh(DisplayChangeListener *dcl,
 static void gd_resize(DisplayChangeListener *dcl,
   DisplayState *ds)
 {
-GtkDisplayState *s = ds-opaque;
+GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
 cairo_format_t kind;
 int stride;
 
@@ -1297,7 +1297,6 @@ void gtk_display_init(DisplayState *ds)
 
 gtk_init(NULL, NULL);
 
-ds-opaque = s;
 s-ds = ds;
 s-dcl.ops = dcl_ops;
 
diff --git a/ui/vnc.c b/ui/vnc.c
index bdc3cd8..a6111d6 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -44,7 +44,6 @@ static const struct timeval VNC_REFRESH_LOSSY = { 2, 0 };
 #include d3des.h
 
 static VncDisplay *vnc_display; /* needed for info vnc */
-static DisplayChangeListener *dcl;
 
 static int vnc_cursor_define(VncState *vs);
 static void vnc_release_modifiers(VncState *vs);
@@ -435,7 +434,7 @@ static void vnc_dpy_update(DisplayChangeListener *dcl,
int x, int y, int w, int h)
 {
 int i;
-VncDisplay *vd = ds-opaque;
+VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
 struct VncSurface *s = vd-guest;
 int width = ds_get_width(ds);
 int height = ds_get_height(ds);
@@ -578,7 +577,7 @@ void *vnc_server_fb_ptr(VncDisplay *vd, int x, int y)
 static void vnc_dpy_resize(DisplayChangeListener *dcl,
DisplayState *ds)
 {
-VncDisplay *vd = ds-opaque;
+VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
 VncState *vs;
 
 vnc_abort_display_jobs(vd);
@@ -743,7 +742,7 @@ static void vnc_dpy_copy(DisplayChangeListener *dcl,
  int src_x, int src_y,
  int dst_x, int dst_y, int w, int h)
 {
-VncDisplay *vd = ds-opaque;
+VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
 VncState *vs, *vn;
 uint8_t *src_row;
 uint8_t *dst_row;
@@ -1069,7 +1068,7 @@ void vnc_disconnect_finish(VncState *vs)
 }
 
 if (QTAILQ_EMPTY(vs-vd-clients)) {
-dcl-idle = 1;
+vs-vd-dcl.idle = 1;
 }
 
 vnc_remove_timer(vs-vd);
@@ -1985,7 +1984,7 @@ static void pixel_format_message (VncState *vs) {
 static void vnc_dpy_setdata(DisplayChangeListener *dcl,
 DisplayState *ds)
 {
-VncDisplay *vd = ds-opaque;
+VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
 
 qemu_pixman_image_unref(vd-guest.fb);
 vd-guest.fb = pixman_image_ref(ds-surface-image);
@@ -2697,7 +2696,7 @@ static void vnc_init_timer(VncDisplay *vd)
 vd-timer_interval = VNC_REFRESH_INTERVAL_BASE;
 if (vd-timer == NULL  !QTAILQ_EMPTY(vd-clients)) {
 vd-timer = qemu_new_timer_ms(rt_clock, vnc_refresh, vd);
-vnc_dpy_resize(dcl, vd-ds);
+vnc_dpy_resize(vd-dcl, vd-ds);
 vnc_refresh(vd);
 }
 }
@@ -2736,7 +2735,7 @@ static void vnc_connect(VncDisplay *vd, int csock, int 
skipauth, bool websocket)
 }
 
 VNC_DEBUG(New client on socket %d\n, csock);
-dcl-idle = 0;
+vd-dcl.idle = 0;
 socket_set_nonblock(vs-csock);
 #ifdef CONFIG_VNC_WS
 if (websocket) {
@@ -2847,10 +2846,7 @@ void vnc_display_init(DisplayState *ds)
 {
 VncDisplay *vs = g_malloc0(sizeof(*vs));
 
-dcl = g_malloc0(sizeof(DisplayChangeListener));
-
-ds-opaque = vs;
-dcl-idle = 1;
+vs-dcl.idle = 1;
 vnc_display = vs;
 
 vs-lsock = -1;
@@ -2873,14 +2869,14 @@ void vnc_display_init(DisplayState *ds)
 qemu_mutex_init(vs-mutex);
 vnc_start_worker_thread();
 
-dcl-ops = dcl_ops;
-register_displaychangelistener(ds, dcl);
+

[Qemu-devel] [RfC PATCH 08/12] console: rework DisplaySurface handling [dcl/ui side]

2013-03-01 Thread Gerd Hoffmann
Replace the dpy_gfx_resize and dpy_gfx_setdata DisplayChangeListener
callbacks with a dpy_gfx_switch callback which notifies the ui code
when the framebuffer backing storage changes.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/qxl.c   |9 +
 include/ui/console.h   |7 +++
 include/ui/spice-display.h |3 ++-
 ui/console.c   |8 
 ui/gtk.c   |   15 ---
 ui/sdl.c   |   10 +-
 ui/spice-display.c |   12 +++-
 ui/vnc.c   |   21 +
 8 files changed, 39 insertions(+), 46 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index 8177008..1ec03a5 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1875,13 +1875,14 @@ static void display_update(DisplayChangeListener *dcl,
 }
 }
 
-static void display_resize(DisplayChangeListener *dcl,
-   struct DisplayState *ds)
+static void display_switch(DisplayChangeListener *dcl,
+   struct DisplayState *ds,
+   struct DisplaySurface *surface)
 {
 PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl);
 
 if (qxl-mode == QXL_MODE_VGA) {
-qemu_spice_display_resize(qxl-ssd);
+qemu_spice_display_switch(qxl-ssd, surface);
 }
 }
 
@@ -1902,7 +1903,7 @@ static void display_refresh(DisplayChangeListener *dcl,
 static DisplayChangeListenerOps display_listener_ops = {
 .dpy_name= spice/qxl,
 .dpy_gfx_update  = display_update,
-.dpy_gfx_resize  = display_resize,
+.dpy_gfx_switch  = display_switch,
 .dpy_refresh = display_refresh,
 };
 
diff --git a/include/ui/console.h b/include/ui/console.h
index bbf3b1d..f15a541 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -156,10 +156,9 @@ typedef struct DisplayChangeListenerOps {
 void (*dpy_gfx_update)(DisplayChangeListener *dcl,
struct DisplayState *s,
int x, int y, int w, int h);
-void (*dpy_gfx_resize)(DisplayChangeListener *dcl,
-   struct DisplayState *s);
-void (*dpy_gfx_setdata)(DisplayChangeListener *dcl,
-struct DisplayState *s);
+void (*dpy_gfx_switch)(DisplayChangeListener *dcl,
+   struct DisplayState *s,
+   struct DisplaySurface *new_surface);
 void (*dpy_gfx_copy)(DisplayChangeListener *dcl,
  struct DisplayState *s, int src_x, int src_y,
  int dst_x, int dst_y, int w, int h);
diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h
index f2752aa..82f8246 100644
--- a/include/ui/spice-display.h
+++ b/include/ui/spice-display.h
@@ -117,7 +117,8 @@ void qemu_spice_display_init_common(SimpleSpiceDisplay 
*ssd, DisplayState *ds);
 
 void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
int x, int y, int w, int h);
-void qemu_spice_display_resize(SimpleSpiceDisplay *ssd);
+void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
+   DisplaySurface *surface);
 void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd);
 void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd);
 
diff --git a/ui/console.c b/ui/console.c
index 54c7bf3..461cda8 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1372,8 +1372,8 @@ void register_displaychangelistener(DisplayState *ds,
 dcl-ds = ds;
 QLIST_INSERT_HEAD(ds-listeners, dcl, next);
 gui_setup_refresh(ds);
-if (dcl-ops-dpy_gfx_resize) {
-dcl-ops-dpy_gfx_resize(dcl, ds);
+if (dcl-ops-dpy_gfx_switch) {
+dcl-ops-dpy_gfx_switch(dcl, ds, ds-surface);
 }
 }
 
@@ -1413,8 +1413,8 @@ void dpy_gfx_replace_surface(DisplayState *s,
 
 s-surface = surface;
 QLIST_FOREACH(dcl, s-listeners, next) {
-if (dcl-ops-dpy_gfx_resize) {
-dcl-ops-dpy_gfx_resize(dcl, s);
+if (dcl-ops-dpy_gfx_switch) {
+dcl-ops-dpy_gfx_switch(dcl, s, surface);
 }
 }
 qemu_free_displaysurface(old_surface);
diff --git a/ui/gtk.c b/ui/gtk.c
index fe58494..abef1ca 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -266,8 +266,9 @@ static void gd_refresh(DisplayChangeListener *dcl,
 vga_hw_update();
 }
 
-static void gd_resize(DisplayChangeListener *dcl,
-  DisplayState *ds)
+static void gd_switch(DisplayChangeListener *dcl,
+  DisplayState *ds,
+  DisplaySurface *surface)
 {
 GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
 cairo_format_t kind;
@@ -738,7 +739,7 @@ static void gd_menu_zoom_in(GtkMenuItem *item, void *opaque)
 s-scale_x += .25;
 s-scale_y += .25;
 
-gd_resize(s-dcl, s-ds);
+gd_switch(s-dcl, s-ds, s-ds-surface);
 }
 
 static void gd_menu_zoom_out(GtkMenuItem *item, void *opaque)
@@ -754,7 +755,7 @@ static void 

[Qemu-devel] [RfC PATCH 07/12] console: rework DisplaySurface handling [vga emu side]

2013-03-01 Thread Gerd Hoffmann
Decouple DisplaySurface allocation  deallocation from DisplayState.
Replace dpy_gfx_resize + dpy_gfx_setdata with a dpy_gfx_replace_surface
function.

This handles the graphic hardware emulation.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/nseries.c |7 -
 hw/palm.c|7 -
 hw/qxl-render.c  |   12 -
 hw/vga.c |   17 ++--
 include/ui/console.h |   11 +++-
 trace-events |5 ++--
 ui/console.c |   71 +-
 7 files changed, 50 insertions(+), 80 deletions(-)

diff --git a/hw/nseries.c b/hw/nseries.c
index 99d353a..9b6b51d 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -1290,7 +1290,6 @@ static void n8x0_init(QEMUMachineInitArgs *args,
 MemoryRegion *sysmem = get_system_memory();
 struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s));
 int sdram_size = binfo-ram_size;
-DisplayState *ds;
 
 s-mpu = omap2420_mpu_init(sysmem, sdram_size, args-cpu_model);
 
@@ -1370,12 +1369,6 @@ static void n8x0_init(QEMUMachineInitArgs *args,
 n800_setup_nolo_tags(nolo_tags);
 cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x1);
 }
-/* FIXME: We shouldn't really be doing this here.  The LCD controller
-   will set the size once configured, so this just sets an initial
-   size until the guest activates the display.  */
-ds = get_displaystate();
-ds-surface = qemu_resize_displaysurface(ds, 800, 480);
-dpy_gfx_resize(ds);
 }
 
 static struct arm_boot_info n800_binfo = {
diff --git a/hw/palm.c b/hw/palm.c
index a633dfc..f86e1b0 100644
--- a/hw/palm.c
+++ b/hw/palm.c
@@ -205,7 +205,6 @@ static void palmte_init(QEMUMachineInitArgs *args)
 static uint32_t cs2val = 0xe1a0;
 static uint32_t cs3val = 0xe1a0e1a0;
 int rom_size, rom_loaded = 0;
-DisplayState *ds = get_displaystate();
 MemoryRegion *flash = g_new(MemoryRegion, 1);
 MemoryRegion *cs = g_new(MemoryRegion, 4);
 
@@ -268,12 +267,6 @@ static void palmte_init(QEMUMachineInitArgs *args)
 palmte_binfo.initrd_filename = initrd_filename;
 arm_load_kernel(mpu-cpu, palmte_binfo);
 }
-
-/* FIXME: We shouldn't really be doing this here.  The LCD controller
-   will set the size once configured, so this just sets an initial
-   size until the guest activates the display.  */
-ds-surface = qemu_resize_displaysurface(ds, 320, 320);
-dpy_gfx_resize(ds);
 }
 
 static QEMUMachine palmte_machine = {
diff --git a/hw/qxl-render.c b/hw/qxl-render.c
index 455fb91..7172d9a 100644
--- a/hw/qxl-render.c
+++ b/hw/qxl-render.c
@@ -98,6 +98,7 @@ static void qxl_set_rect_to_surface(PCIQXLDevice *qxl, 
QXLRect *area)
 static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl)
 {
 VGACommonState *vga = qxl-vga;
+DisplaySurface *surface;
 int i;
 
 if (qxl-guest_primary.resized) {
@@ -112,8 +113,7 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice 
*qxl)
qxl-guest_primary.bytes_pp,
qxl-guest_primary.bits_pp);
 if (qxl-guest_primary.qxl_stride  0) {
-qemu_free_displaysurface(vga-ds);
-vga-ds-surface = qemu_create_displaysurface_from
+surface = qemu_create_displaysurface_from
 (qxl-guest_primary.surface.width,
  qxl-guest_primary.surface.height,
  qxl-guest_primary.bits_pp,
@@ -121,11 +121,11 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice 
*qxl)
  qxl-guest_primary.data,
  false);
 } else {
-qemu_resize_displaysurface(vga-ds,
-qxl-guest_primary.surface.width,
-qxl-guest_primary.surface.height);
+surface = qemu_create_displaysurface
+(qxl-guest_primary.surface.width,
+ qxl-guest_primary.surface.height);
 }
-dpy_gfx_resize(vga-ds);
+dpy_gfx_replace_surface(vga-ds, surface);
 }
 for (i = 0; i  qxl-num_dirty_rects; i++) {
 if (qemu_spice_rect_is_empty(qxl-dirty+i)) {
diff --git a/hw/vga.c b/hw/vga.c
index 1caf23d..65471c6 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -1691,11 +1691,11 @@ static void vga_draw_graphic(VGACommonState *s, int 
full_update)
 height != s-last_height ||
 s-last_depth != depth) {
 if (depth == 32 || (depth == 16  !byteswap)) {
-qemu_free_displaysurface(s-ds);
-s-ds-surface = qemu_create_displaysurface_from(disp_width, 
height, depth,
-s-line_offset,
+DisplaySurface *surface;
+surface = qemu_create_displaysurface_from(disp_width,
+height, depth, s-line_offset,
 s-vram_ptr + (s-start_addr * 4), byteswap);
-dpy_gfx_resize(s-ds);
+dpy_gfx_replace_surface(s-ds, surface);
 } else {
 

Re: [Qemu-devel] [RFC PATCH 0/4] savevm: save vmsate with fixed size

2013-03-01 Thread Kevin Wolf
Am 01.03.2013 um 03:35 hat Wenchao Xia geschrieben:
 于 2013-2-28 18:50, Kevin Wolf 写道:
 Am 28.02.2013 um 09:09 hat Wenchao Xia geschrieben:
 This version have following limitation:
1 in patch 3 only dirty page got written, clean page is not touched, so
 it will have trouble when savevm to an old internal snapshot, which
 will be fixed later if this approach seems OK.
 
 Basically you need a bdrv_zero_vmstate(), right? I think this would
   Yes, an API to initialize the data at the beginning, or just write 4K
 zero in the progress
 
 actually be a bug fix, because snapshots might today get references to
 unused VM state clusters that are just leftovers from the last snapshot.
 
   In a qcow2 file that have snapA, if user type savevm snapA, then
 qemu will delete old snapA and then create new snapA.
   Do you mean that new snapA and old snapA may use the same cluster
 that is not cleaned up as zeros? I guess this brings no trouble to old
 stream savevm, but will brings trouble to plane savevm in this patch.
 If so, I think yes this bug fix can solve the problem.

The scenario I'm thinking of is something like:

1. (qemu) savevm A
2. (qemu) quit
3. qemu-img snapshot -c B test.qcow2
4. qemu-img snapshot -d A test.qcow2

Step 1 creates a snapshot from a running VM, so it writes a lot of VM
state data to the image. Step 3 creates another snapshot, however
outside of a running qemu, so without VM state. It wrongly gets a
reference to all VM state clusters of A, which haven't been overwritten
or discarded since snapshot A was taken. When deleting A in step 4, the
clusters cannot be freed because they are still referenced by B (which
doesn't need them at all)

Kevin



[Qemu-devel] [PATCH 0/2 v3] Time resync support by qemu-ga

2013-03-01 Thread Lei Li
This patch series attempts to add time resync support
to qemu-ga by introducing qemu-ga commands guest-get-time
and guest-set-time.

Right now, when a guest is paused or migrated to a file
then loaded from that file, the guest OS has no idea that
there was a big gap in the time. Depending on how long the
gap was, NTP might not be able to resynchronize the guest.
So adding new guest-agent command that is called any time
a guest is resumed  and which tells the guest to update its
own wall clock time based on the information from the host
will make it easier for a guest to resynchronize without
waiting for NTP.

The previous RFC send for discussion and suggestion as link
here:

http://article.gmane.org/gmane.comp.emulators.qemu/186126

The interface for these commands like:

{ 'command': 'guest-get-time', 'returns': 'int' }

{ 'command': 'guest-set-time', 'data': { 'time': int } }

Notes:
For the implementition of win32-specific commands, I plan
to send it out in another thread later.

Suggestions and comments are welcome!


Changes since v2:
  - Get rid of utc-offset, and make it just pass single nanoseconds
relative to the Epoch in UTC/GMT according to Anthony and
Eric's comments.
  - Make time argument mandatory.
  - Fix the overflow check for year-2038 problem.
  - Error handel improvment from Eric. 

Changes since v1:
  - Squashed patches add support to get host time and add
guest-get-time command into one.
  - Documents improvment based on the suggestions from
Eric and Mike.
  - Change the name of 'HostTimeInfo' to 'TimeInfo'.
  - Better use-case and logic for 'guest-set-time'
command suggested by Eric.
  - Error handel improvment from Luiz.

Lei Li (2):
  qga: add guest-get-time command
  qga: add guest-set-time command




[Qemu-devel] [PATCH 1/2] qga: add guest-get-time command

2013-03-01 Thread Lei Li
Signed-off-by: Lei Li li...@linux.vnet.ibm.com
---
 qga/commands-posix.c | 16 
 qga/qapi-schema.json | 16 
 2 files changed, 32 insertions(+)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 0ad73f3..f159e25 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -119,6 +119,22 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, 
Error **err)
 /* succeded */
 }
 
+int64_t qmp_guest_get_time(Error **errp)
+{
+   int ret;
+   qemu_timeval tq;
+   int64_t time_ns;
+
+   ret = qemu_gettimeofday(tq);
+   if (ret  0) {
+   error_setg_errno(errp, errno, Failed to get time);
+   return -1;
+   }
+
+   time_ns = tq.tv_sec * 10LL + tq.tv_usec * 1000;
+   return time_ns; 
+}
+
 typedef struct GuestFileHandle {
 uint64_t id;
 FILE *fh;
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index d91d903..563600c 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -83,6 +83,22 @@
 { 'command': 'guest-ping' }
 
 ##
+# @guest-get-time:
+#
+# Get the information about guest time relative to the Epoch
+# of 1970-01-01 in UTC/GMT.
+#
+# This command try to get the guest's notion of the current
+# time.
+#
+# Returns: Time in nanoseconds on success.
+#
+# Since 1.5
+##
+{ 'command': 'guest-get-time',
+  'returns': 'int' }
+
+##
 # @GuestAgentCommandInfo:
 #
 # Information about guest agent commands.
-- 
1.7.11.7




Re: [Qemu-devel] [RFC V6 27/33] qcow2: Adapt checking of QCOW_OFLAG_COPIED for dedup.

2013-03-01 Thread Stefan Hajnoczi
On Fri, Mar 01, 2013 at 09:59:33AM +0100, Kevin Wolf wrote:
 Am 28.02.2013 um 17:14 hat Benoît Canet geschrieben:
  Le Thursday 28 Feb 2013 à 11:14:34 (+0100), Kevin Wolf a écrit :
   Am 28.02.2013 um 10:41 hat Stefan Hajnoczi geschrieben:
On Wed, Feb 27, 2013 at 04:00:28PM +0100, Benoît Canet wrote:
   -if ((refcount == 1) != ((l2_entry  
   QCOW_OFLAG_COPIED) != 0)) {
   +if (!s-has_dedup 
   +(refcount == 1) != ((l2_entry  
   QCOW_OFLAG_COPIED) != 0)) {
   +fprintf(stderr, ERROR OFLAG_COPIED: 
   offset=%
   +PRIx64  refcount=%d\n, l2_entry, 
   refcount);
   +res-corruptions++;
   +}
  
  Why is this warning suppressed when dedup is enabled?  The meaning 
  of
  QCOW_OFLAG_COPIED is that refcount == 1.  If this invariant is 
  violated
  then something is wrong.
 
 When deduplication is done refcount will be bigger than one and
 QCOW_OFLAG_COPIED will be cleared.
 
 Then if enough logical clustere pointing to the same physical cluster 
 are
 rewritten with something else the refcount will goes down back to one.
 
 But this time QCOW_OFLAG_COPIED can be set back so this equality 
 won't be true.

When the refcount decreases to 1 again we need to set QCOW_OFLAG_COPIED
again.  qcow2-snapshot.c:qcow2_snapshot_delete() does this with:

/* must update the copied flag on the current cluster offsets */
ret = qcow2_update_snapshot_refcount(bs, s-l1_table_offset, 
s-l1_size, 0);

Is dedup not restoring QCOW_OFLAG_COPIED?
   
   This is a very expensive operation. I don't think that you can do it for
   each deduplicated cluster that is overwritten. Not doing it comes with
   the cost of doing more COW than is actually needed. And we need to
   mention in the spec that QCOW_OFLAG_COPIED can be missing on clusters
   with deduplication enabled.
  
  Also when two logical clusters point to the same physical cluster and one 
  of the
  logical cluster get overwritten the deduplication code has no way to know 
  the
  index of the last logical cluster entry.
 
 Well, strictly speaking you can. The qcow2_update_snapshot_refcount()
 call that Stefan mention does exactly that. It's just insanely expensive
 because it has to look at the refcounts for all clusters.

Okay, I agree that qcow2_update_snapshot_refcount() is too expensive.

Please add a comment explaining that QCOW_OFLAG_COPIED is not guaranteed
when dedup is enabled since it would be too expensive to do this
everything sharing breaks (refcount is decremented to 1).

Stefan



[Qemu-devel] [PATCH 2/2] qga: add guest-set-time command

2013-03-01 Thread Lei Li
Signed-off-by: Lei Li li...@linux.vnet.ibm.com
---
 qga/commands-posix.c | 55 
 qga/qapi-schema.json | 27 ++
 2 files changed, 82 insertions(+)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index f159e25..e246a0d 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -135,6 +135,61 @@ int64_t qmp_guest_get_time(Error **errp)
return time_ns; 
 }
 
+void qmp_guest_set_time(int64_t time_ns, Error **errp)
+{
+int ret;
+int status;
+pid_t pid;
+Error *local_err = NULL;
+struct timeval tv;
+
+/* year-2038 will overflow in case time_t is 32bit */
+if ((sizeof(time_t) = 4)  ((unsigned long) time_ns  (1ul  31))) {
+error_setg_errno(errp, errno, Invalid time %ld for overflow,
+ time_ns);
+}
+
+tv.tv_sec = time_ns / 10;
+tv.tv_usec = (time_ns % 10) / 1000;
+
+ret = settimeofday(tv, NULL);
+if (ret  0) {
+error_setg_errno(errp, errno, Failed to set time to guest);
+return;
+}
+
+/* Set the Hardware Clock to the current System Time. */
+pid = fork();
+if (pid == 0) {
+setsid();
+reopen_fd_to_null(0);
+reopen_fd_to_null(1);
+reopen_fd_to_null(2);
+
+execle(/sbin/hwclock, hwclock, -w, NULL, environ);
+_exit(EXIT_FAILURE);
+} else if (pid  0) {
+error_setg_errno(errp, errno, failed to create child process);
+return;
+}
+
+ga_wait_child(pid, status, local_err);
+if (error_is_set(local_err)) {
+error_propagate(errp, local_err);
+return;
+}
+
+if (!WIFEXITED(status)) {
+error_setg(errp, child process has terminated abnormally);
+return;
+}
+
+if (WEXITSTATUS(status)) {
+error_setg(errp, hwclock failed to set hardware clock to system 
time);
+return;
+}
+}
+
 typedef struct GuestFileHandle {
 uint64_t id;
 FILE *fh;
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index 563600c..5eba324 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -99,6 +99,33 @@
   'returns': 'int' }
 
 ##
+# @guest-set-time:
+#
+# Set guest time.
+#
+# Right now, when a guest is paused or migrated to a file
+# then loaded from that file, the guest OS has no idea that
+# there was a big gap in the time. Depending on how long
+# the gap was, NTP might not be able to resynchronize the
+# guest.
+#
+# This command tries to set guest time based on the information
+# from host or an absolute value given by management app, and
+# set the Hardware Clock to the current System Time. This
+# will make it easier for a guest to resynchronize without
+# waiting for NTP.
+#
+# @time: time of nanoseconds, relative to the Epoch of
+#1970-01-01 in UTC/GMT.
+#
+# Returns: Nothing on success.
+#
+# Since: 1.5
+##
+{ 'command': 'guest-set-time',
+  'data': { 'time': 'int' } }
+
+##
 # @GuestAgentCommandInfo:
 #
 # Information about guest agent commands.
-- 
1.7.11.7




Re: [Qemu-devel] [PATCH] net: use socket_set_nodelay() for -netdev socket

2013-03-01 Thread Stefan Hajnoczi
On Thu, Feb 28, 2013 at 01:55:58PM +, Daniel P. Berrange wrote:
 On Thu, Feb 28, 2013 at 02:49:51PM +0100, Stefan Hajnoczi wrote:
  On Wed, Feb 27, 2013 at 04:49:16PM +, Daniel P. Berrange wrote:
   On Wed, Feb 27, 2013 at 03:05:47PM +0100, Stefan Hajnoczi wrote:
Reduce -netdev socket latency by disabling the Nagle algorithm on
SOCK_STREAM sockets in net/socket.c.  Since we are tunelling Ethernet
over TCP we shouldn't artificially delay outgoing packets, let the guest
decide packet scheduling.

I already get sub-millisecond -netdev socket ping times on localhost, so
there was no measurable difference in my testing.  This won't hurt
though and may improve remote socket performance.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
   
   ACK.
   
   Signed-off-by: Daniel P. Berrange berra...@redhat.com
  
  Hi Dan,
  QEMU usually only uses Singed-off-by: for authors and subsystem
  maintainers who merge the patch.
 
 Ah, ok.
 
  
  Is it okay if I add a Reviewed-by: Daniel P. Berrange
  berra...@redhat.com instead?
 
 Of course. 

Thanks, done.

Stefan



Re: [Qemu-devel] [RFC] parallelize migration_bitmap_sync()

2013-03-01 Thread Paolo Bonzini
Il 01/03/2013 00:22, Michael R. Hines ha scritto:te
 Hi,
 
 Currently migration_bitmap_sync() is very expensive: on the order of
 15-20 milliseconds by my count using timestamps (for a simple 2GB ram
 virtual machine).
 Until new EPT processor versions come out in 2014, we need software
 support for cutting this time down much lowerby at least an
 order of magnitude.
 
 Would anyone be opposed to me writing a patch that creates N threads and
 dividing up the migration_bitmap_sync() function to have the dirty page
 scanning run in parallel?

Yes, that's a possibility.  You can make a quick prototype using OpenMP.

But Juan is working on making the dirty bitmap really a bitmap (not a
bytemap).  That should speed up migration_bitmap_sync by a factor of
64 (i.e. sizeof(long)*8).

Paolo



Re: [Qemu-devel] virtio-rng and fd passing

2013-03-01 Thread Paolo Bonzini
Il 01/03/2013 01:36, Eric Blake ha scritto:
 For fd passing to work, we have to use qemu_open() instead of raw
 open().  Is there any way to enforce that all files being opened by qemu
 go through the appropriate qemu_open() wrapper?
 
 Meanwhile, we have a quandary on the libvirt side of things: qemu 1.4
 supports fd passing in general, but does not support it for rng.  I
 guess the same is true for -blockdev - we don't (yet) have a way to do
 fd passing for backing files.  Do we need some sort of QMP command that
 will let libvirt query for a particular device whether that device is
 known to support fd passing, so that libvirt can use fd passing for all
 supported devices, while falling back to older direct open()s, and to
 know which instance of qemu can safely have open() blocked at the
 SELinux or syscall blacklist level?

Let's change open to qemu_open for 1.4.1, and declare rng only supported
in 1.4.1...

Paolo



Re: [Qemu-devel] Advice on some configuration parameters

2013-03-01 Thread Fabio Fantoni

Il 12/02/2013 14:05, Fabio Fantoni ha scritto:
I'm making patches to enable some qemu upstream features in xen that 
are missing in libxl.
I'm trying to do it just by giving arguments to qemu, and I want them 
to be dynamic (e.g. without physical addresses if possible) and concise.


I'm confused about usb configuration.

Looking at what virt-manager does, it seems that you set the 
usbredirection in channels like this:
-chardev spicevmc,id=charredir0,name=usbredir -device 
usb-redir,chardev=charredir0,id=redir0


At the moment I'm defining the physical usb devices like this:
-readconfig /etc/qemu/ich9-ehci-uhci.cfg

If I try to set up virt-manager so that it doesn't point to a file, it 
uses this configuration:


-device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x5.0x7
-device 
ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5

-device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x5.0x1
-device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x5.0x2

This seems to differ from the configuration file, e.g. you have 
multifunzion=on only on the first uhci, besides I can't understand how 
many physical ports are defined. I tried setting 9 usbredirection 
channels in virt-manager but that configuration doesn't change and no 
errors are reported, but I doubt that physical ports are being define 
dynamically.


Can you omit physical addresses?
I searched the web but I can't find detailed informations about it. 
Can someone explain in detail how you are supposed to configure usb 
physical ports? I want to enable both usb redirection and usb 
passthrough in a dynamic and concise manner.


About spice vdagent at the moment I'm using this configuration that 
seems to work:
-device virtio-serial -chardev spicevmc,id=vdagent,name=vdagent 
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0


But I noticed that virt-manager use this slightly different one:
-chardev pty,id=charserial0 -device 
isa-serial,chardev=charserial0,id=serial0 -chardev 
spicevmc,id=charchannel0,name=vdagent -device 
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0


Are there any problem with the more concise one I'm using?

Thanks for any reply.



Are there someone can help me please?



smime.p7s
Description: Firma crittografica S/MIME


Re: [Qemu-devel] [ARM] Cortex-R4F and VFP3-D16

2013-03-01 Thread Fabien Chouteau
On 02/28/2013 07:42 PM, Peter Maydell wrote:
 On 28 February 2013 17:39, Fabien Chouteau chout...@adacore.com wrote:
 On 02/28/2013 03:16 PM, Peter Maydell wrote:
 On 28 February 2013 14:01, Fabien Chouteau chout...@adacore.com wrote:
 In fact I'm
 working on a big-endian R4F (TMS570) and I have endianness issue in the
 communication with GDB.

 If you're also trying to get big-endian mode to work (linux-user
 mode or system emulation?) you may have more problems than merely
 implementing R4 support or VFP-D16 :-)
 
 I already built qemu-system-armeb, and implemented few devices of the
 TMS570 (rti, sci, and vim). Besides this GDB issue I have no endianness
 problem so far.
 
 This is probably some combination of luck and insufficient testing.
 If you submit some patches I will review them :-)
 

Well my goal is not to test every ARM cpu and every devices in big-endian.

I only need a small subset of TMS570: - Cortex-R4F without MPU
  - Timers (RTI)
  - Serial port (SCI)
  - Interrupt manager (RTI)
and everything works good so far.


 How are you handling the SCTLR IE and EE bits?


I did nothing, as far as I know it's not possible to switch endianness
in QEMU. TMS570 are configured for big-endian only, so this is not a
problem for me.

 Are you planning to do the v7 PMSA support?
 
 I don't know what that is, but I'll take a look :)
 
 It's the Memory Protection Unit -- QEMU currently only has the
 old v5 MPU, and register_cpu_regs_for_features() will assert
 if your CPU is v6 or v7 and has the FEATURE_MPU bit set.
 If you're putting in system emulation for an R4 then you must
 implement this (and I'm surprised you've managed to get anything
 significant to run without it).
 

The programs I run don't need MPU, so for the moment I have no plan to
implement PMSA.

Regards,

-- 
Fabien Chouteau



Re: [Qemu-devel] [PATCH v10 0/7] trace: Generic event state description

2013-03-01 Thread Stefan Hajnoczi
On Thu, Feb 28, 2013 at 02:48:27PM +0100, Lluís Vilanova wrote:
 Stefan Hajnoczi writes:
 
  On Fri, Jan 25, 2013 at 05:33:46PM +0100, Lluís Vilanova wrote:
  Provides a generic event state description structure (TraceEvent) and a 
  more
  detailed event control and query interface.
  
  This is achieved by creating a new non-public tracing backend (i.e., not
  selectable by the user at configure time) that will generate the 
  appropriate
  event description information.
  
  Signed-off-by: Lluís Vilanova vilan...@ac.upc.edu
  ---
 
  Hi Lluís,
  I hit an issue testing the different backends with this series applied.
 
  The simple trace writeout thread hangs when the 'quit' monitor command
  is issued.  Do you see the same issue?
 
  $ ./configure --target-list=x86_64-softmmu --enable-trace-backend=simple
  $ make -j4
  $ cat my-events 
  bdrv_open_common
  $ x86_64-softmmu/qemu-system-x86_64 -trace events=my-events
  (qemu) quit
 
 I've rebased the series in master (which forced me to fix a tiny line in a
 makefile, due recent changes), and everything's working fine.
 
 I can resend the rebased series, if you want.

Okay, sounds good.  I'll retest your rebased series.

Stefan



Re: [Qemu-devel] [ARM] Cortex-R4F and VFP3-D16

2013-03-01 Thread Peter Maydell
On 1 March 2013 10:13, Fabien Chouteau chout...@adacore.com wrote:
 On 02/28/2013 07:42 PM, Peter Maydell wrote:
 How are you handling the SCTLR IE and EE bits?

 I did nothing, as far as I know it's not possible to switch endianness
 in QEMU.

Yes, that's why I'm wondering how you're handling them.

 TMS570 are configured for big-endian only, so this is not a
 problem for me.

Do you mean they are BE8 for load/stores always (ie SCTLR.EE is
1, or that they are both BE8 for load/stores and also for
instruction fetches (ie that SCTLR.IE is also 1) ?

Endianness in ARM is not as simple as a single flag saying
big or little...

 Are you planning to do the v7 PMSA support?

 I don't know what that is, but I'll take a look :)

 It's the Memory Protection Unit -- QEMU currently only has the
 old v5 MPU, and register_cpu_regs_for_features() will assert
 if your CPU is v6 or v7 and has the FEATURE_MPU bit set.
 If you're putting in system emulation for an R4 then you must
 implement this (and I'm surprised you've managed to get anything
 significant to run without it).

 The programs I run don't need MPU, so for the moment I have no plan to
 implement PMSA.

However from an upstream point of view something that claims
to be an R4 but doesn't actually implement the MPU is not
terribly useful...

-- PMM



Re: [Qemu-devel] Block I/O optimizations

2013-03-01 Thread Stefan Hajnoczi
On Thu, Feb 28, 2013 at 08:20:08PM +0200, Abel Gordon wrote:
 Stefan Hajnoczi stefa...@gmail.com wrote on 28/02/2013 04:43:04 PM:
  I think extending and tuning the existing mechanisms is the way to go.
  I don't see obvious advantages other than reducing context switches.
 
 Maybe it is worth checking...
 We did experiments using vhost-net and vhost-blk. We measured and compared
 the traditional model (kernel thread per VM/virtual device) to the
 shared-thread model with fine-grained I/O scheduling (single kernel thread
 used to serve multiple VMs). We noticed improvements up-to 2.5x
 in throughput and almost half the latency when running up-to 14 VMs.

Can you post patches?

Also, I wonder if you have time to do a presentation/discussion session
so we can get the ball rolling and more people exposed to your approach.
There is a weekly QEMU Community Call which we can use as the forum.

The reason I have been skeptical is that prototyping radical changes
often involves rewriting or bypassing code.  These accidental changes
can impact performance too.  We need to understand where to attribute
the performance improvements.

Stefan



Re: [Qemu-devel] [ARM] Cortex-R4F and VFP3-D16

2013-03-01 Thread Fabien Chouteau
On 03/01/2013 11:40 AM, Peter Maydell wrote:
 On 1 March 2013 10:13, Fabien Chouteau chout...@adacore.com wrote:
 On 02/28/2013 07:42 PM, Peter Maydell wrote:
 How are you handling the SCTLR IE and EE bits?

 I did nothing, as far as I know it's not possible to switch endianness
 in QEMU.

 Yes, that's why I'm wondering how you're handling them.

 TMS570 are configured for big-endian only, so this is not a
 problem for me.

 Do you mean they are BE8 for load/stores always (ie SCTLR.EE is
 1, or that they are both BE8 for load/stores and also for
 instruction fetches (ie that SCTLR.IE is also 1) ?

 Endianness in ARM is not as simple as a single flag saying
 big or little...


I'm new to this ARM architecture so I will just quote the doc.

TMS570LS31x/21x Technical Reference Manual:

The TMS570 family is based on the ARM® CortexTM-R4F core. ARM has
designed this core to be used in big-endian and little-endian systems.
For the TI TMS570 family, the endianness has been configured to BE32.


 Are you planning to do the v7 PMSA support?

 I don't know what that is, but I'll take a look :)

 It's the Memory Protection Unit -- QEMU currently only has the
 old v5 MPU, and register_cpu_regs_for_features() will assert
 if your CPU is v6 or v7 and has the FEATURE_MPU bit set.
 If you're putting in system emulation for an R4 then you must
 implement this (and I'm surprised you've managed to get anything
 significant to run without it).

 The programs I run don't need MPU, so for the moment I have no plan to
 implement PMSA.

 However from an upstream point of view something that claims
 to be an R4 but doesn't actually implement the MPU is not
 terribly useful...


Well it is useful for us. Our safety-critical small-foot-print run-time
doesn't need MPU. Look for Ravenscar profile in Ada.

Regards,

-- 
Fabien Chouteau



Re: [Qemu-devel] [ARM] Cortex-R4F and VFP3-D16

2013-03-01 Thread Peter Maydell
On 1 March 2013 11:21, Fabien Chouteau chout...@adacore.com wrote:
 On 03/01/2013 11:40 AM, Peter Maydell wrote:
 On 1 March 2013 10:13, Fabien Chouteau chout...@adacore.com wrote:
 TMS570 are configured for big-endian only, so this is not a
 problem for me.

 Do you mean they are BE8 for load/stores always (ie SCTLR.EE is
 1, or that they are both BE8 for load/stores and also for
 instruction fetches (ie that SCTLR.IE is also 1) ?

 Endianness in ARM is not as simple as a single flag saying
 big or little...


 I'm new to this ARM architecture so I will just quote the doc.

 TMS570LS31x/21x Technical Reference Manual:

 The TMS570 family is based on the ARM® CortexTM-R4F core. ARM has
 designed this core to be used in big-endian and little-endian systems.
 For the TI TMS570 family, the endianness has been configured to BE32.

That is confusing, because ARM's R4F Technical Reference Manual
says The processor does not support word-invariant big-endianness
(BE)-32...

(http://translatedcode.wordpress.com/2012/04/02/this-end-up/
has a quick summary of what the various flavours of ARM
endianness actually mean.)

I think you're going to have to run some tests on the actual
hardware to find out what it really does. Specifically, what
are the values of SCTLR.IE, SCTLR.EE and CPSR.E when you think
you're in big-endian mode? (We need to sort out what parts of
the behaviour you're seeing are the CPU itself and what parts
are the SoC/board doing endianness flipping externally to the
CPU.)

thanks
-- PMM



[Qemu-devel] [PATCH] page_cache: use multiplicative hash for page position calculation

2013-03-01 Thread Peter Lieven

instead of a linear mapping we use a multiplicative hash
with the golden ratio to derive the cache bucket from the
address. this helps to reduce collisions if memory positions
are multiple of the cache size and it avoids a division
in the position calculation.

Signed-off-by: Peter Lieven p...@kamp.de
---
 page_cache.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/page_cache.c b/page_cache.c
index 376f1db..45d769a 100644
--- a/page_cache.c
+++ b/page_cache.c
@@ -24,6 +24,7 @@
 #include strings.h

 #include qemu-common.h
+#include qemu/host-utils.h
 #include migration/page_cache.h

 #ifdef DEBUG_CACHE
@@ -48,6 +49,7 @@ struct PageCache {
 int64_t max_num_items;
 uint64_t max_item_age;
 int64_t num_items;
+uint64_t hash_shift_bits;
 };

 PageCache *cache_init(int64_t num_pages, unsigned int page_size)
@@ -72,6 +74,7 @@ PageCache *cache_init(int64_t num_pages, unsigned int 
page_size)
 cache-num_items = 0;
 cache-max_item_age = 0;
 cache-max_num_items = num_pages;
+cache-hash_shift_bits = clz64(num_pages-1);

 DPRINTF(Setting cache buckets to % PRId64 \n, cache-max_num_items);

@@ -108,7 +111,7 @@ static size_t cache_get_cache_pos(const PageCache *cache,
 size_t pos;

 g_assert(cache-max_num_items);
-pos = (address / cache-page_size)  (cache-max_num_items - 1);
+pos = (address * 0x9e3779b97f4a7c13)  cache-hash_shift_bits;
 return pos;
 }

--
1.7.9.5



Re: [Qemu-devel] [ARM] Cortex-R4F and VFP3-D16

2013-03-01 Thread Fabien Chouteau
On 03/01/2013 12:32 PM, Peter Maydell wrote:
 On 1 March 2013 11:21, Fabien Chouteau chout...@adacore.com wrote:
 TMS570LS31x/21x Technical Reference Manual:

 The TMS570 family is based on the ARM® CortexTM-R4F core. ARM has
 designed this core to be used in big-endian and little-endian systems.
 For the TI TMS570 family, the endianness has been configured to BE32.
 
 That is confusing, because ARM's R4F Technical Reference Manual
 says The processor does not support word-invariant big-endianness
 (BE)-32...
 
 (http://translatedcode.wordpress.com/2012/04/02/this-end-up/
 has a quick summary of what the various flavours of ARM
 endianness actually mean.)
 

Confusing indeed. It seems that the documentation is not reliable. Below
the text I just quoted, there's an example showing that TMS570 is
actually BE8. And this is confirmed by our experience using the real
board.

 I think you're going to have to run some tests on the actual
 hardware to find out what it really does. Specifically, what
 are the values of SCTLR.IE, SCTLR.EE and CPSR.E when you think
 you're in big-endian mode? (We need to sort out what parts of
 the behaviour you're seeing are the CPU itself and what parts
 are the SoC/board doing endianness flipping externally to the
 CPU.)
 

SCTLR.IE and SCTLR.EE are both set to 1 at reset and the values cannot
be changed.

BTW, our run-time works both on QEMU and a real-board, that's also why
I'm confident that there are no endianness issue.

Regards,

-- 
Fabien Chouteau



Re: [Qemu-devel] [ARM] Cortex-R4F and VFP3-D16

2013-03-01 Thread Peter Maydell
On 1 March 2013 12:07, Fabien Chouteau chout...@adacore.com wrote:
 On 03/01/2013 12:32 PM, Peter Maydell wrote:
 I think you're going to have to run some tests on the actual
 hardware to find out what it really does. Specifically, what
 are the values of SCTLR.IE, SCTLR.EE and CPSR.E when you think
 you're in big-endian mode?

 SCTLR.IE and SCTLR.EE are both set to 1 at reset and the values
 cannot be changed.

OK, that makes sense. I think it's also a reasonable thing for
qemu's qemu-system-armeb model to present to the guest. Have
you changed QEMU to report IE and EE (and CPSR.E) as always-1,
or does your guest code just not look at them?

 BTW, our run-time works both on QEMU and a real-board, that's also why
 I'm confident that there are no endianness issue.

The trouble is that you can have two separate bits of QEMU
which both model the endianness incorrectly but in such
a way that the two errors cancel each other out and the
guest-visible behaviour looks correct...

-- PMM



Re: [Qemu-devel] Advice on some configuration parameters

2013-03-01 Thread Paolo Bonzini
Il 12/02/2013 14:05, Fabio Fantoni ha scritto:
 I'm making patches to enable some qemu upstream features in xen that are
 missing in libxl.
 I'm trying to do it just by giving arguments to qemu, and I want them to
 be dynamic (e.g. without physical addresses if possible) and concise.

They should use physical addresses, otherwise changing the VM hardware
in trivial ways may cause a waterfall effect and cause Windows to
reactivate.

 If I try to set up virt-manager so that it doesn't point to a file, it
 uses this configuration:
 
 -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x5.0x7
 -device
 ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5
 
 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x5.0x1
 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x5.0x2
 
 This seems to differ from the configuration file, e.g. you have
 multifunzion=on only on the first uhci

That doesn't matter.

 , besides I can't understand how many physical ports are defined.

There are 6 ports, controlled by either the EHCI for USB 2.0 devices
(the EHCI controls 6 ports) or by one of the three UHCI for USB 1.1
ports (one UHCI has 2 ports).

 I tried setting 9 usbredirection
 channels in virt-manager but that configuration doesn't change and no
 errors are reported, but I doubt that physical ports are being define
 dynamically.

QEMU creates hubs automatically I think in that case.

 About spice vdagent at the moment I'm using this configuration that
 seems to work:
 -device virtio-serial -chardev spicevmc,id=vdagent,name=vdagent -device
 virtserialport,chardev=vdagent,name=com.redhat.spice.0
 
 But I noticed that virt-manager use this slightly different one:
 -chardev pty,id=charserial0 -device
 isa-serial,chardev=charserial0,id=serial0 -chardev
 spicevmc,id=charchannel0,name=vdagent -device
 virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0
 
 Are there any problem with the more concise one I'm using?

It is the same.

Paolo




Re: [Qemu-devel] [PATCH] page_cache: use multiplicative hash for page position calculation

2013-03-01 Thread Laszlo Ersek
On 03/01/13 12:53, Peter Lieven wrote:
 instead of a linear mapping we use a multiplicative hash
 with the golden ratio to derive the cache bucket from the
 address. this helps to reduce collisions if memory positions
 are multiple of the cache size and it avoids a division
 in the position calculation.
 
 Signed-off-by: Peter Lieven p...@kamp.de
 ---
  page_cache.c |5 -
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 diff --git a/page_cache.c b/page_cache.c
 index 376f1db..45d769a 100644
 --- a/page_cache.c
 +++ b/page_cache.c
 @@ -24,6 +24,7 @@
  #include strings.h
 
  #include qemu-common.h
 +#include qemu/host-utils.h
  #include migration/page_cache.h
 
  #ifdef DEBUG_CACHE
 @@ -48,6 +49,7 @@ struct PageCache {
  int64_t max_num_items;
  uint64_t max_item_age;
  int64_t num_items;
 +uint64_t hash_shift_bits;
  };
 
  PageCache *cache_init(int64_t num_pages, unsigned int page_size)
 @@ -72,6 +74,7 @@ PageCache *cache_init(int64_t num_pages, unsigned int
 page_size)
  cache-num_items = 0;
  cache-max_item_age = 0;
  cache-max_num_items = num_pages;
 +cache-hash_shift_bits = clz64(num_pages-1);
 
  DPRINTF(Setting cache buckets to % PRId64 \n,
 cache-max_num_items);
 
 @@ -108,7 +111,7 @@ static size_t cache_get_cache_pos(const PageCache
 *cache,
  size_t pos;
 
  g_assert(cache-max_num_items);
 -pos = (address / cache-page_size)  (cache-max_num_items - 1);
 +pos = (address * 0x9e3779b97f4a7c13)  cache-hash_shift_bits;
  return pos;
  }
 

According to http://www.brpreiss.com/books/opus4/html/page214.html,
the multiplier is chosen as the integer that is relatively prime to
2^64 which is closest to (sqrt(5)-1)/2 * 2^64.

(sqrt(5)-1)/2 * 2^64 ~= 11400714819323198485.86699842797038469120

hence the constant would be a=0x9e3779b97f4a7c15. Any reason why a-2 is
used in the patch?

(Note: this is not a review or any suggestion to change the patch; I'm
just curious.)

A google-fight between a and a-2 is inconclusive. So is stackoverflow:

http://stackoverflow.com/questions/4113278/64-bit-multiplicative-hashing
http://stackoverflow.com/questions/8513911/how-to-create-a-good-hash-combine-with-64-bit-output-inspired-by-boosthash-co

Thanks
Laszlo



[Qemu-devel] [Bug 1129571] Re: libreoffice armhf FTBFS

2013-03-01 Thread John Rigby
Trying to build on a raring amd64 host in a raring armhf chroot, two
failures so far.  First time was a hang checking ant, an xlc-ls showed
several java threads hung.  Second time was a segfault again in java.
So I have no problems reproducing this now locally.   Hang seems like
thread waiting for futex not being awakened but that is just my
speculation.  I will chase this further.

One more point, these two failures were locally build 1.4.0 with my
FUTEX_WAIT_BITSET patches applied.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1129571

Title:
  libreoffice armhf FTBFS

Status in QEMU:
  New
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  We have been experiencing FTBFS of LibreOffice 3.5.7, 12.04, armhf in
  the launchpad buildds. We believe this is likely due to an error in
  qemu.

  While we do not have a small test case yet, we do have a build log
  (attaching here).

  The relevant snippet from the build log is:

  
3.5.7/solver/unxlngr.pro/bin/jaxp.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/juh.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/parser.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/xt.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/unoil.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/ridl.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/jurt.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/xmlsearch.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/LuceneHelpWrapper.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/HelpIndexerTool.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/lucene-core-2.3.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/lucene-analyzers-2.3.jar
 com.sun.star.help.HelpIndexerTool -lang cs -mod swriter -zipdir 
../../unxlngr.pro/misc/ziptmpswriter_cs -o 
../../unxlngr.pro/bin/swriter_cs.zip.unxlngr.pro
  dmake:  Error code 132, while making '../../unxlngr.pro/bin/swriter_cs.zip'

  We believe this is from bash error code 128 + 4, where 4 is illegal
  instruction, thus leading us to suspect qemu.

  Any help in tracking this down would be appreciated.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1129571/+subscriptions



Re: [Qemu-devel] libvirt-QEMU interfaces for CPU models

2013-03-01 Thread Jiri Denemark
On Thu, Feb 21, 2013 at 11:58:18 -0300, Eduardo Habkost wrote:
 Hi,
 
 After a long time trying to figure out the proper modelling inside QEMU,
 I believe the plans are now clearer in QEMU, so it's time to coordinate
 more closely with libvirt to try to make use of the new stuff.
 
 I tried to enumerate the libvirt requirements and current problems, and
 how we should be able to solve those problems using the X86CPU
 subclasses and properties, on the following wiki page:
 
 http://wiki.qemu.org/Features/CPUModels#Interfaces.2Frequirements_from_libvirt

 = Ensuring predictable set of guest features =
 
 Requirement: libvirt needs to ensure all features required on the command-line
 are present and exposed to the guest.
 
 Current problem: libvirt doesn't use the enforce flag so it can't guarantee
 that a given feature will be actually exposed to the guest.
 
 Solution: use the enforce flag on the -cpu option.

Definitely, we plan to start using enforce flag as soon as we have
better CPU probing interface with QEMU. Since libvirt does not currently
consult CPU specs with QEMU, some configurations in fact rely on QEMU
dropping features it can't provide. Of course, that's bad for several
reasons but we don't want such configurations to suddenly stop working.
We want to first fix the CPU specs libvirt creates so that we know they
will work with enforce.

 Limitation: no proper machine-friendly interface to report which features
 are missing.
 
 Workaround: See querying for host capabilities below.

I doubt we will be ready to start using enforce before the machine
friendly interface is available...


 = Listing CPU models =
 
 Requirement: libvirt needs to know which CPU models are available to be used
 with the -cpu option.
 
 Current problem: libvirt relies on help output parsing for that.
 
 Solution: use QMP qom-list-types command.
 
 Dependency: X86CPU subclasses.
 Limitation: needs a live QEMU process for the query.

No problem, we already run QEMU and use several QMP commands to probe
its capabilities. And qom-list-types is actually one of them. To get
the list of CPU models, we would just call

{
execute: qom-list-types,
arguments: {
implements: X86CPU
}
}

right? What about other non-x86 architectures? Will we need to use
different class name or is there a generic CPU class that could be used
universally?

 Solution: use QMP query-cpu-definitions command.
 
 Limitation: needs a live QEMU process for the query.

IIUC, the result of this command will depend on machine type and we
can't use -M none we currently use for probing, right?

 == Future plans ==
 
 It would be interesting to get rid of the requirement for a live QEMU process
 (with a complete machine being created) to be already running.

Hmm, so is this complete machine needed even for getting CPU models from
qom-list-types or only for querying exact definitions using
query-cpu-definitions command?

Actually, what is query-cpu-definitions supposed to return? Currently it
seems it's just the CPU model names rather than details about all CPU
models. From the command name, one would expect to get more than just
names.


 = Getting information about CPU models =
 
 Requirement: libvirt uses the predefined CPU models from QEMU, but it needs to
 be able to query for CPU model details, to find out how it can create a VM 
 that
 matches what was requested by the user.
 
 Current problem: libvirt has a copy of the CPU model definitions on its
 cpu_map.xml file, and the copy can be out of sync in case CPU models in QEMU
 change. libvirt also assumes that the set of features on each model is always
 the same on all machine-types, which is not true.
 
 Challenge: the resulting CPU features depend on lots of factors, including
 the machine-type.
 
 Workaround: start a paused VM and query for the CPU device information
 after the CPU was created.
 
 Solution: start a paused VM with no devices, but with the right
 machine-type and right CPU model. Use QMP QOM commands to query for CPU
 flags (especially the properties starting with the f- prefix).
 
 Dependency: X86CPU feature properties (f-* properties).
 Limitation: requires a live QEMU process with the right machine-type/
 CPU-model to be started, to make the query.

This would be very useful for ensuring the guest sees the exact same CPU
after it's been migrated or restored from a stored state or a snapshot.
Should we make sure the guest will always see the same CPU even after
shutdown or is it ok if the guest CPU changes a bit on next boot, e.g.,
in case the host kernel was upgraded and is able to provide more
features?

However, probing several CPU definitions for compatibility with
host/kernel/QEMU would be quite inefficient. Although I guess we should
be able to limit doing so only in case a specific API (e.g.,
virConnectCompareCPU or virConnectBaselineCPU) is called, 

[Qemu-devel] [Bug 1129571] Re: libreoffice armhf FTBFS

2013-03-01 Thread Peter Maydell
John: you might also like to try with this patchset applied:
http://lists.nongnu.org/archive/html/qemu-devel/2013-02/msg04207.html
as that fixes one category of races. There are still other races that can cause 
segfaults and other problems (as the cover letter describes) but it's possible 
this particular case will be fixed by it.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1129571

Title:
  libreoffice armhf FTBFS

Status in QEMU:
  New
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  We have been experiencing FTBFS of LibreOffice 3.5.7, 12.04, armhf in
  the launchpad buildds. We believe this is likely due to an error in
  qemu.

  While we do not have a small test case yet, we do have a build log
  (attaching here).

  The relevant snippet from the build log is:

  
3.5.7/solver/unxlngr.pro/bin/jaxp.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/juh.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/parser.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/xt.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/unoil.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/ridl.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/jurt.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/xmlsearch.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/LuceneHelpWrapper.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/HelpIndexerTool.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/lucene-core-2.3.jar:/build/buildd/libreoffice-3.5.7/solver/unxlngr.pro/bin/lucene-analyzers-2.3.jar
 com.sun.star.help.HelpIndexerTool -lang cs -mod swriter -zipdir 
../../unxlngr.pro/misc/ziptmpswriter_cs -o 
../../unxlngr.pro/bin/swriter_cs.zip.unxlngr.pro
  dmake:  Error code 132, while making '../../unxlngr.pro/bin/swriter_cs.zip'

  We believe this is from bash error code 128 + 4, where 4 is illegal
  instruction, thus leading us to suspect qemu.

  Any help in tracking this down would be appreciated.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1129571/+subscriptions



Re: [Qemu-devel] [PATCH] page_cache: use multiplicative hash for page position calculation

2013-03-01 Thread Peter Lieven

On 01.03.2013 13:50, Laszlo Ersek wrote:

On 03/01/13 12:53, Peter Lieven wrote:

instead of a linear mapping we use a multiplicative hash
with the golden ratio to derive the cache bucket from the
address. this helps to reduce collisions if memory positions
are multiple of the cache size and it avoids a division
in the position calculation.

Signed-off-by: Peter Lieven p...@kamp.de
---
  page_cache.c |5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/page_cache.c b/page_cache.c
index 376f1db..45d769a 100644
--- a/page_cache.c
+++ b/page_cache.c
@@ -24,6 +24,7 @@
  #include strings.h

  #include qemu-common.h
+#include qemu/host-utils.h
  #include migration/page_cache.h

  #ifdef DEBUG_CACHE
@@ -48,6 +49,7 @@ struct PageCache {
  int64_t max_num_items;
  uint64_t max_item_age;
  int64_t num_items;
+uint64_t hash_shift_bits;
  };

  PageCache *cache_init(int64_t num_pages, unsigned int page_size)
@@ -72,6 +74,7 @@ PageCache *cache_init(int64_t num_pages, unsigned int
page_size)
  cache-num_items = 0;
  cache-max_item_age = 0;
  cache-max_num_items = num_pages;
+cache-hash_shift_bits = clz64(num_pages-1);

  DPRINTF(Setting cache buckets to % PRId64 \n,
cache-max_num_items);

@@ -108,7 +111,7 @@ static size_t cache_get_cache_pos(const PageCache
*cache,
  size_t pos;

  g_assert(cache-max_num_items);
-pos = (address / cache-page_size)  (cache-max_num_items - 1);
+pos = (address * 0x9e3779b97f4a7c13)  cache-hash_shift_bits;
  return pos;
  }



According to http://www.brpreiss.com/books/opus4/html/page214.html,
the multiplier is chosen as the integer that is relatively prime to
2^64 which is closest to (sqrt(5)-1)/2 * 2^64.

(sqrt(5)-1)/2 * 2^64 ~= 11400714819323198485.86699842797038469120

hence the constant would be a=0x9e3779b97f4a7c15. Any reason why a-2 is
used in the patch?


no, actually I only googled this value and did not calculate it myself.

Peter




Re: [Qemu-devel] libvirt-QEMU interfaces for CPU models

2013-03-01 Thread Jiri Denemark
On Thu, Feb 21, 2013 at 11:58:18 -0300, Eduardo Habkost wrote:
 = Querying host capabilities =
 
 Requirement: libvirt needs to know which feature can really be enabled, before
 it tries to start a VM, and before it tries to start a live-migration process.
 
 The set of available capabilities depend on:
 
   • Host CPU (hardware) capabilities;
   • Kernel capabilities (reported by GET_SUPPORTED_CPUID);
   • QEMU capabilities;
   • Specific configuration options (e.g. in-kernel IRQ chip is required for
 some features).

Actually, one more thing. Can any of these requirements change while a
host is up and QEMU is not upgraded? I believe, host CPU capabilities
can only change when the host starts. Kernel capabilities are a bit less
clear since I guess they could possibly change when kvm module is
unloaded and loaded back with a different options. QEMU capabilities
should only change when different version is installed. And the specific
configuration options are the most unclear to me. The reason I'm asking
is whether libvirt could run-time cache CPU definitions (including all
model details) in the same way we currently cache QEMU capabilities,
such as availability of specific QMP commands.

Jirka



[Qemu-devel] [PATCH] migration: use XBZRLE only after bulk stage

2013-03-01 Thread Peter Lieven

at the beginning of migration all pages are marked dirty and
in the first round a bulk migration of all pages is performed.

currently all these pages are copied to the page cache regardless
if there are frequently updated or not. this doesn't make sense
since most of these pages are never transferred again.

this patch changes the XBZRLE transfer to only be used after
the bulk stage has been completed. that means a page is added
to the page cache the second time it is transferred and XBZRLE
can benefit from the third time of transfer.

since the page cache is likely smaller than the number of pages
its also likely that in the second round the page is missing in the
cache due to collisions in the bulk phase.

on the other hand a lot of unneccssary mallocs, memdups and frees
are saved.

Signed-off-by: Peter Lieven p...@kamp.de
---
 arch_init.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch_init.c b/arch_init.c
index 8da868b..24241e0 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -347,6 +347,7 @@ static ram_addr_t last_offset;
 static unsigned long *migration_bitmap;
 static uint64_t migration_dirty_pages;
 static uint32_t last_version;
+static bool ram_bulk_stage;

 static inline
 ram_addr_t migration_bitmap_find_and_reset_dirty(MemoryRegion *mr,
@@ -451,6 +452,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage)
 if (!block) {
 block = QTAILQ_FIRST(ram_list.blocks);
 complete_round = true;
+ram_bulk_stage = false;
 }
 } else {
 uint8_t *p;
@@ -467,7 +469,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage)
 RAM_SAVE_FLAG_COMPRESS);
 qemu_put_byte(f, *p);
 bytes_sent += 1;
-} else if (migrate_use_xbzrle()) {
+} else if (!ram_bulk_stage  migrate_use_xbzrle()) {
 current_addr = block-offset + offset;
 bytes_sent = save_xbzrle_page(f, p, current_addr, block,
   offset, cont, last_stage);
@@ -554,6 +556,7 @@ static void reset_ram_globals(void)
 last_sent_block = NULL;
 last_offset = 0;
 last_version = ram_list.version;
+ram_bulk_stage = true;
 }

 #define MAX_WAIT 50 /* ms, half buffered_file limit */
--
1.7.9.5



[Qemu-devel] [PATCH 02/18] hw: move fifo.[ch] to libqemuutil

2013-03-01 Thread Paolo Bonzini
fifo.c is generic code that can be easily unit tested.  So it
belongs in libqemuutil.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/Makefile.objs  | 1 -
 hw/xilinx_spi.c   | 2 +-
 hw/xilinx_spips.c | 2 +-
 include/migration/vmstate.h   | 2 ++
 hw/fifo.h = include/qemu/fifo8.h | 2 +-
 util/Makefile.objs| 1 +
 hw/fifo.c = util/fifo8.c | 3 ++-
 7 files changed, 8 insertions(+), 5 deletions(-)
 rename hw/fifo.h = include/qemu/fifo8.h (98%)
 rename hw/fifo.c = util/fifo8.c (97%)

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 5750332..6e2275b 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -44,7 +44,6 @@ common-obj-$(CONFIG_SMARTCARD_NSS) += ccid-card-emulated.o
 endif
 common-obj-$(CONFIG_I8259) += i8259_common.o i8259.o
 common-obj-$(CONFIG_SDHCI) += sdhci.o
-common-obj-y += fifo.o
 common-obj-y += pam.o
 
 # PPC devices
diff --git a/hw/xilinx_spi.c b/hw/xilinx_spi.c
index be581c2..e73c9bd 100644
--- a/hw/xilinx_spi.c
+++ b/hw/xilinx_spi.c
@@ -27,7 +27,7 @@
 #include sysbus.h
 #include sysemu/sysemu.h
 #include qemu/log.h
-#include fifo.h
+#include qemu/fifo8.h
 
 #include ssi.h
 
diff --git a/hw/xilinx_spips.c b/hw/xilinx_spips.c
index 42e019d..915eb96 100644
--- a/hw/xilinx_spips.c
+++ b/hw/xilinx_spips.c
@@ -26,7 +26,7 @@
 #include sysemu/sysemu.h
 #include ptimer.h
 #include qemu/log.h
-#include fifo.h
+#include qemu/fifo8.h
 #include ssi.h
 #include qemu/bitops.h
 
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f27276c..94a409b 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -26,6 +26,8 @@
 #ifndef QEMU_VMSTATE_H
 #define QEMU_VMSTATE_H 1
 
+#include migration/qemu-file.h
+
 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
 
diff --git a/hw/fifo.h b/include/qemu/fifo8.h
similarity index 98%
rename from hw/fifo.h
rename to include/qemu/fifo8.h
index f23890a..d318f71 100644
--- a/hw/fifo.h
+++ b/include/qemu/fifo8.h
@@ -1,7 +1,7 @@
 #ifndef FIFO_H
 #define FIFO_H
 
-#include hw.h
+#include migration/vmstate.h
 
 typedef struct {
 /* All fields are private */
diff --git a/util/Makefile.objs b/util/Makefile.objs
index 495a178..cad5ce8 100644
--- a/util/Makefile.objs
+++ b/util/Makefile.objs
@@ -3,6 +3,7 @@ util-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o 
event_notifier-win
 util-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o 
event_notifier-posix.o
 util-obj-y += envlist.o path.o host-utils.o cache-utils.o module.o
 util-obj-y += bitmap.o bitops.o hbitmap.o
+util-obj-y += fifo8.o
 util-obj-y += acl.o
 util-obj-y += error.o qemu-error.o
 util-obj-$(CONFIG_POSIX) += compatfd.o
diff --git a/hw/fifo.c b/util/fifo8.c
similarity index 97%
rename from hw/fifo.c
rename to util/fifo8.c
index 68a955a..013e903 100644
--- a/hw/fifo.c
+++ b/util/fifo8.c
@@ -12,7 +12,8 @@
  * with this program; if not, see http://www.gnu.org/licenses/.
  */
 
-#include fifo.h
+#include qemu-common.h
+#include qemu/fifo8.h
 
 void fifo8_create(Fifo8 *fifo, uint32_t capacity)
 {
-- 
1.8.1.4





[Qemu-devel] [PATCH 01/18] hw: move char backends to backends/

2013-03-01 Thread Paolo Bonzini
Braille and msmouse support is in hw/, but it is not hardware.
Move it to the backends/ directory.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 backends/Makefile.objs | 4 
 {hw = backends}/baum.c| 4 ++--
 {hw = backends}/msmouse.c | 2 +-
 hw/Makefile.objs   | 4 +---
 {hw = include/char}/baum.h| 0
 {hw = include/char}/msmouse.h | 0
 qemu-char.c| 4 ++--
 vl.c   | 2 +-
 8 files changed, 11 insertions(+), 9 deletions(-)
 rename {hw = backends}/baum.c (99%)
 rename {hw = backends}/msmouse.c (99%)
 rename {hw = include/char}/baum.h (100%)
 rename {hw = include/char}/msmouse.h (100%)

diff --git a/backends/Makefile.objs b/backends/Makefile.objs
index 8836761..464bc3e 100644
--- a/backends/Makefile.objs
+++ b/backends/Makefile.objs
@@ -1,2 +1,6 @@
 common-obj-y += rng.o rng-egd.o
 common-obj-$(CONFIG_POSIX) += rng-random.o
+
+common-obj-y += msmouse.o
+common-obj-$(CONFIG_BRLAPI) += baum.o
+$(obj)/baum.o: QEMU_CFLAGS += $(SDL_CFLAGS) 
diff --git a/hw/baum.c b/backends/baum.c
similarity index 99%
rename from hw/baum.c
rename to backends/baum.c
index 09dcb9c..37ccca8 100644
--- a/hw/baum.c
+++ b/backends/baum.c
@@ -24,8 +24,8 @@
 #include qemu-common.h
 #include char/char.h
 #include qemu/timer.h
-#include usb.h
-#include baum.h
+#include hw/usb.h
+#include char/baum.h
 #include brlapi.h
 #include brlapi_constants.h
 #include brlapi_keycodes.h
diff --git a/hw/msmouse.c b/backends/msmouse.c
similarity index 99%
rename from hw/msmouse.c
rename to backends/msmouse.c
index ef47aed..bf2ff2a 100644
--- a/hw/msmouse.c
+++ b/backends/msmouse.c
@@ -25,7 +25,7 @@
 #include qemu-common.h
 #include char/char.h
 #include ui/console.h
-#include msmouse.h
+#include char/msmouse.h
 
 #define MSMOUSE_LO6(n) ((n)  0x3f)
 #define MSMOUSE_HI2(n) (((n)  0xc0)  6)
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 40ebe46..5750332 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -190,10 +190,9 @@ common-obj-$(CONFIG_SSI_SD) += ssi-sd.o
 common-obj-$(CONFIG_SD) += sd.o
 common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
-common-obj-y += msmouse.o ps2.o
+common-obj-y += ps2.o
 common-obj-y += qdev-monitor.o
 common-obj-y += qdev-properties-system.o
-common-obj-$(CONFIG_BRLAPI) += baum.o
 
 # xen backend driver support
 common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o
@@ -218,5 +217,4 @@ obj-$(CONFIG_KVM) += ivshmem.o
 obj-$(CONFIG_LINUX) += vfio_pci.o
 endif
 
-$(obj)/baum.o: QEMU_CFLAGS += $(SDL_CFLAGS) 
 endif
diff --git a/hw/baum.h b/include/char/baum.h
similarity index 100%
rename from hw/baum.h
rename to include/char/baum.h
diff --git a/hw/msmouse.h b/include/char/msmouse.h
similarity index 100%
rename from hw/msmouse.h
rename to include/char/msmouse.h
diff --git a/qemu-char.c b/qemu-char.c
index 160decc..6dc1474 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -28,8 +28,8 @@
 #include qemu/timer.h
 #include char/char.h
 #include hw/usb.h
-#include hw/baum.h
-#include hw/msmouse.h
+#include char/baum.h
+#include char/msmouse.h
 #include qmp-commands.h
 
 #include unistd.h
diff --git a/vl.c b/vl.c
index c03edf1..e0a8eeb 100644
--- a/vl.c
+++ b/vl.c
@@ -119,7 +119,7 @@ int main(int argc, char **argv)
 #include hw/pcmcia.h
 #include hw/pc.h
 #include hw/isa.h
-#include hw/baum.h
+#include char/baum.h
 #include hw/bt.h
 #include hw/watchdog.h
 #include hw/smbios.h
-- 
1.8.1.4





[Qemu-devel] [PATCH 05/18] virtio-9p: use CONFIG_VIRTFS, not CONFIG_LINUX

2013-03-01 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/virtio-pci.h | 2 +-
 hw/virtio.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
index d24957c..e775525 100644
--- a/hw/virtio-pci.h
+++ b/hw/virtio-pci.h
@@ -75,7 +75,7 @@ struct VirtIOPCIProxy {
 VirtIOBlkConf blk;
 NICConf nic;
 uint32_t host_features;
-#ifdef CONFIG_LINUX
+#ifdef CONFIG_VIRTFS
 V9fsConf fsconf;
 #endif
 virtio_serial_conf serial;
diff --git a/hw/virtio.h b/hw/virtio.h
index 1e206b8..ae43d25 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -19,7 +19,7 @@
 #include qdev.h
 #include sysemu/sysemu.h
 #include qemu/event_notifier.h
-#ifdef CONFIG_LINUX
+#ifdef CONFIG_VIRTFS
 #include 9p.h
 #endif
 
@@ -252,7 +252,7 @@ typedef struct VirtIOSCSIConf VirtIOSCSIConf;
 VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *conf);
 typedef struct VirtIORNGConf VirtIORNGConf;
 VirtIODevice *virtio_rng_init(DeviceState *dev, VirtIORNGConf *conf);
-#ifdef CONFIG_LINUX
+#ifdef CONFIG_VIRTFS
 VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf);
 #endif
 
-- 
1.8.1.4





[Qemu-devel] [PATCH 00/18] hw/ reorganization, part 1: out of hw/ + into hw/ARCH

2013-03-01 Thread Paolo Bonzini
This series includes all the preparatory changes for reorganizing
hw/.  It also moves boards and CPU-specific files to hw/ARCH, for
which there was clear consensus.

The following changes since commit 288f1e3f87ec24abeac38399f175fe74243f7bc5:

  cadence_gem: Add debug msgs for rx desc movement (2013-02-28 18:49:24 +)

are available in the git repository at:

  git://github.com/bonzini/qemu.git hw-dirs

for you to fetch changes up to 883478014523b362be252b4874d327f950fad05d:

  sh: move files referencing CPU to hw/sh4/ (2013-03-01 14:08:07 +0100)

Paolo

Paolo Bonzini (18):
  hw: move char backends to backends/
  hw: move fifo.[ch] to libqemuutil
  hw: move qdev-monitor.o to toplevel directory
  hw: move device-hotplug.o to toplevel, compile it once
  virtio-9p: use CONFIG_VIRTFS, not CONFIG_LINUX
  virtio-9p: remove PCI dependencies from hw/9pfs/
  vt82c686: vt82c686 is not a PCI host bridge
  ppc: do not use ../ in include files
  hw: include hw header files with full paths
  build: always link device_tree.o into emulators if libfdt available
  ppc: express FDT dependency of pSeries and e500 boards via
default-configs/
  hw: move boards and other isolated files to hw/ARCH
  arm: move files referencing CPU to hw/arm/
  i386: move files referencing CPU to hw/i386/
  m68k: move files referencing CPU to hw/m68k/
  ppc: move files referencing CPU to hw/ppc/
  ppc: move more files to hw/ppc
  sh: move files referencing CPU to hw/sh4/

 Makefile.objs |  1 +
 Makefile.target   |  1 +
 backends/Makefile.objs|  4 ++
 {hw = backends}/baum.c   |  4 +-
 {hw = backends}/msmouse.c|  2 +-
 configure | 10 +---
 default-configs/ppc-softmmu.mak   |  1 +
 default-configs/ppc64-softmmu.mak |  2 +
 default-configs/ppcemb-softmmu.mak|  1 +
 hw/device-hotplug.c = device-hotplug.c   | 13 +---
 hw/9pfs/virtio-9p-device.c| 53 +
 hw/{9p.h = 9pfs/virtio-9p-device.h}  |  4 +-
 hw/9pfs/virtio-9p-proxy.c |  1 +
 hw/9pfs/virtio-9p.c   |  3 +-
 hw/9pfs/virtio-9p.h   |  1 -
 hw/Makefile.objs  |  8 +--
 hw/a15mpcore.c|  2 +-
 hw/a9mpcore.c |  2 +-
 hw/ac97.c |  6 +-
 hw/acpi.c |  6 +-
 hw/acpi_ich9.c| 10 ++--
 hw/acpi_ich9.h|  2 +-
 hw/acpi_piix4.c   | 14 ++---
 hw/adb.c  |  4 +-
 hw/adb.h  |  2 +-
 hw/adlib.c|  8 +--
 hw/ads7846.c  |  2 +-
 hw/alpha/Makefile.objs|  4 +-
 hw/{alpha_dp264.c = alpha/dp264.c}   | 16 ++---
 hw/{alpha_pci.c = alpha/pci.c}   |  2 +-
 hw/alpha_sys.h| 10 ++--
 hw/alpha_typhoon.c|  6 +-
 hw/apb_pci.c  | 12 ++--
 hw/apic.c | 12 ++--
 hw/apic_common.c  |  4 +-
 hw/apic_internal.h|  2 +-
 hw/apm.c  |  6 +-
 hw/apm.h  |  2 +-
 hw/applesmc.c |  4 +-
 hw/arm/Makefile.objs  | 43 +++---
 hw/{ = arm}/armv7m.c |  6 +-
 hw/{arm_boot.c = arm/boot.c} |  8 +--
 hw/{ = arm}/collie.c | 14 ++---
 hw/{ = arm}/exynos4210.c | 12 ++--
 hw/{ = arm}/exynos4_boards.c |  8 +--
 hw/{ = arm}/gumstix.c| 10 ++--
 hw/{ = arm}/highbank.c   | 12 ++--
 hw/{ = arm}/integratorcp.c   |  8 +--
 hw/{ = arm}/kzm.c| 14 ++---
 hw/{ = arm}/mainstone.c  | 14 ++---
 hw/{ = arm}/musicpal.c   | 16 ++---
 hw/{ = arm}/nseries.c| 22 +++
 hw/{ = arm}/omap1.c  | 10 ++--
 hw/{ = arm}/omap2.c  | 12 ++--
 hw/{ = arm}/omap_sx1.c   | 10 ++--
 hw/{ = arm}/palm.c   | 12 ++--
 hw/{arm_pic.c = arm/pic_cpu.c}   |  4 +-
 hw/{ = arm}/pxa2xx.c | 10 ++--
 hw/{ = arm}/pxa2xx_gpio.c|  6 +-
 

[Qemu-devel] [PATCH 03/18] hw: move qdev-monitor.o to toplevel directory

2013-03-01 Thread Paolo Bonzini
qdev-monitor.c is the only core qdev file that is not used in
user-mode emulation, and it does not define anything that is used
by hardware models.  Remove it from the hw/ directory and
remove hw/qdev-monitor.h from hw/qdev.h too; this requires
some files to have some new explicitly includes.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 Makefile.objs   | 1 +
 hw/9pfs/virtio-9p-proxy.c   | 1 +
 hw/Makefile.objs| 1 -
 hw/dataplane/virtio-blk.c   | 2 ++
 hw/dataplane/vring.c| 1 +
 hw/pc87312.c| 1 +
 hw/pc_sysfw.c   | 1 +
 hw/pci/shpc.c   | 3 ++-
 hw/pci/slotid_cap.c | 1 +
 hw/qdev-addr.c  | 1 +
 hw/qdev.c   | 1 +
 hw/qdev.h   | 1 -
 hw/s390x/sclpconsole.c  | 1 +
 hw/usb/dev-network.c| 1 +
 hw/virtio-rng.c | 1 +
 hw/virtio-scsi.c| 1 +
 hw/xilinx.h | 3 ++-
 hw/xilinx_axienet.c | 1 +
 hw/qdev-monitor.h = include/monitor/qdev.h | 3 +--
 monitor.c   | 2 +-
 hw/qdev-monitor.c = qdev-monitor.c | 3 ++-
 util/qemu-config.c  | 1 +
 vl.c| 1 +
 23 files changed, 25 insertions(+), 8 deletions(-)
 rename hw/qdev-monitor.h = include/monitor/qdev.h (80%)
 rename hw/qdev-monitor.c = qdev-monitor.c (99%)

diff --git a/Makefile.objs b/Makefile.objs
index a68cdac..2a8174d 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -51,6 +51,7 @@ ifeq ($(CONFIG_SOFTMMU),y)
 common-obj-y = $(block-obj-y) blockdev.o blockdev-nbd.o block/
 common-obj-y += net/
 common-obj-y += readline.o
+common-obj-y += qdev-monitor.o
 common-obj-$(CONFIG_WIN32) += os-win32.o
 common-obj-$(CONFIG_POSIX) += os-posix.o
 
diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index 54e9875..7300279 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -13,6 +13,7 @@
 #include sys/un.h
 #include hw/virtio.h
 #include virtio-9p.h
+#include qemu/error-report.h
 #include fsdev/qemu-fsdev.h
 #include virtio-9p-proxy.h
 
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 6e2275b..f7ee133 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -190,7 +190,6 @@ common-obj-$(CONFIG_SD) += sd.o
 common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += ps2.o
-common-obj-y += qdev-monitor.o
 common-obj-y += qdev-properties-system.o
 
 # xen backend driver support
diff --git a/hw/dataplane/virtio-blk.c b/hw/dataplane/virtio-blk.c
index 3f2da22..8588f93 100644
--- a/hw/dataplane/virtio-blk.c
+++ b/hw/dataplane/virtio-blk.c
@@ -16,9 +16,11 @@
 #include qemu/iov.h
 #include event-poll.h
 #include qemu/thread.h
+#include qemu/error-report.h
 #include vring.h
 #include ioq.h
 #include migration/migration.h
+#include block/block.h
 #include hw/virtio-blk.h
 #include hw/dataplane/virtio-blk.h
 
diff --git a/hw/dataplane/vring.c b/hw/dataplane/vring.c
index d5d4ef4..eff5ad8 100644
--- a/hw/dataplane/vring.c
+++ b/hw/dataplane/vring.c
@@ -16,6 +16,7 @@
 
 #include trace.h
 #include hw/dataplane/vring.h
+#include qemu/error-report.h
 
 /* Map the guest's vring to host memory */
 bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)
diff --git a/hw/pc87312.c b/hw/pc87312.c
index 38af4c1..0e9760e 100644
--- a/hw/pc87312.c
+++ b/hw/pc87312.c
@@ -24,6 +24,7 @@
  */
 
 #include pc87312.h
+#include qemu/error-report.h
 #include sysemu/blockdev.h
 #include sysemu/sysemu.h
 #include char/char.h
diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c
index 7f6c12c..8b65a7a 100644
--- a/hw/pc_sysfw.c
+++ b/hw/pc_sysfw.c
@@ -24,6 +24,7 @@
  */
 
 #include sysemu/blockdev.h
+#include qemu/error-report.h
 #include sysbus.h
 #include hw.h
 #include pc.h
diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index f07266d..d35c2ee 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -1,7 +1,8 @@
+#include qemu-common.h
 #include strings.h
 #include stdint.h
 #include qemu/range.h
-#include qemu/range.h
+#include qemu/error-report.h
 #include hw/pci/shpc.h
 #include hw/pci/pci.h
 #include hw/pci/pci_bus.h
diff --git a/hw/pci/slotid_cap.c b/hw/pci/slotid_cap.c
index 99a30f4..62f7bae 100644
--- a/hw/pci/slotid_cap.c
+++ b/hw/pci/slotid_cap.c
@@ -1,5 +1,6 @@
 #include hw/pci/slotid_cap.h
 #include hw/pci/pci.h
+#include qemu/error-report.h
 
 #define SLOTID_CAP_LENGTH 4
 #define SLOTID_NSLOTS_SHIFT (ffs(PCI_SID_ESR_NSLOTS) - 1)
diff --git a/hw/qdev-addr.c b/hw/qdev-addr.c
index b4388f6..fc2c437 100644
--- a/hw/qdev-addr.c
+++ b/hw/qdev-addr.c
@@ -1,6 +1,7 @@
 #include qdev.h
 #include qdev-addr.h
 #include exec/hwaddr.h
+#include qapi/qmp/qerror.h
 #include 

[Qemu-devel] [PATCH 07/18] vt82c686: vt82c686 is not a PCI host bridge

2013-03-01 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/vt82c686.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 2d8e398..c2b1bfc 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -26,8 +26,6 @@
 #include qemu/timer.h
 #include exec/address-spaces.h
 
-typedef uint32_t pci_addr_t;
-#include pci/pci_host.h
 //#define DEBUG_VT82C686B
 
 #ifdef DEBUG_VT82C686B
-- 
1.8.1.4





[Qemu-devel] [PATCH 12/18] hw: move boards and other isolated files to hw/ARCH

2013-03-01 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/Makefile.objs  |  1 -
 hw/alpha/Makefile.objs|  4 ++-
 hw/{alpha_dp264.c = alpha/dp264.c}   |  0
 hw/{alpha_pci.c = alpha/pci.c}   |  0
 hw/arm/Makefile.objs  | 31 ++-
 hw/{arm_boot.c = arm/boot.c} |  0
 hw/{ = arm}/collie.c |  0
 hw/{ = arm}/exynos4_boards.c |  0
 hw/{ = arm}/gumstix.c|  0
 hw/{ = arm}/highbank.c   |  0
 hw/{ = arm}/integratorcp.c   |  0
 hw/{ = arm}/kzm.c|  0
 hw/{ = arm}/mainstone.c  |  0
 hw/{ = arm}/musicpal.c   |  0
 hw/{ = arm}/nseries.c|  0
 hw/{ = arm}/omap_sx1.c   |  0
 hw/{ = arm}/palm.c   |  0
 hw/{arm_pic.c = arm/pic_cpu.c}   |  0
 hw/{ = arm}/realview.c   |  0
 hw/{ = arm}/spitz.c  |  0
 hw/{ = arm}/stellaris.c  |  0
 hw/{ = arm}/tosa.c   |  0
 hw/{ = arm}/versatilepb.c|  0
 hw/{ = arm}/vexpress.c   |  0
 hw/{ = arm}/xilinx_zynq.c|  0
 hw/{ = arm}/z2.c |  0
 hw/cris/Makefile.objs | 10 
 hw/{ = cris}/axis_dev88.c|  0
 hw/{cris-boot.c = cris/boot.c}   |  0
 hw/{cris_pic_cpu.c = cris/pic_cpu.c} |  0
 hw/i386/Makefile.objs | 13 ++
 hw/{ = i386}/multiboot.c |  0
 hw/{ = i386}/pc.c|  0
 hw/{ = i386}/pc_piix.c   |  0
 hw/{ = i386}/pc_q35.c|  0
 hw/{ = i386}/smbios.c|  0
 hw/{ = i386}/xen_domainbuild.c   |  0
 hw/{ = i386}/xen_machine_pv.c|  0
 hw/lm32/Makefile.objs |  8 +++---
 hw/{ = lm32}/lm32_boards.c   |  0
 hw/{ = lm32}/milkymist.c |  0
 hw/m68k/Makefile.objs |  7 +++--
 hw/{ = m68k}/an5206.c|  0
 hw/{ = m68k}/dummy_m68k.c|  0
 hw/{ = m68k}/mcf5208.c   |  0
 hw/microblaze/Makefile.objs   | 10 
 hw/{microblaze_boot.c = microblaze/boot.c}   |  0
 hw/{ = microblaze}/petalogix_ml605_mmu.c |  0
 hw/{ = microblaze}/petalogix_s3adsp1800_mmu.c|  0
 hw/{microblaze_pic_cpu.c = microblaze/pic_cpu.c} |  0
 hw/mips/Makefile.objs |  8 +++---
 hw/{mips_addr.c = mips/addr.c}   |  0
 hw/{mips_timer.c = mips/cputimer.c}  |  0
 hw/{ = mips}/mips_fulong2e.c |  0
 hw/{ = mips}/mips_int.c  |  0
 hw/{ = mips}/mips_jazz.c |  0
 hw/{ = mips}/mips_malta.c|  0
 hw/{ = mips}/mips_mipssim.c  |  0
 hw/{ = mips}/mips_r4k.c  |  0
 hw/openrisc/Makefile.objs |  5 ++--
 hw/{openrisc_timer.c = openrisc/cputimer.c}  |  0
 hw/{ = openrisc}/openrisc_sim.c  |  0
 hw/{openrisc_pic.c = openrisc/pic_cpu.c} |  0
 hw/ppc/Makefile.objs  | 17 -
 hw/{ = ppc}/ppc.c|  0
 hw/{ = ppc}/ppc405_boards.c  |  0
 hw/{ = ppc}/ppc405_uc.c  |  0
 hw/{ = ppc}/ppc440_bamboo.c  |  0
 hw/{ = ppc}/ppc_booke.c  |  0
 hw/{ = ppc}/spapr.c  |  0
 hw/{ = ppc}/virtex_ml507.c   |  0
 hw/sh4/Makefile.objs  |  4 ++-
 hw/{ = sh4}/r2d.c|  0
 hw/{ = sh4}/shix.c   |  0
 hw/sparc/Makefile.objs|  6 +++--
 hw/{ = sparc}/leon3.c|  0
 hw/{ = sparc}/sun4m.c|  0
 hw/sparc64/Makefile.objs  |  4 ++-
 hw/{ = sparc64}/sun4u.c  |  0
 hw/unicore32/Makefile.objs|  2 --
 hw/{ = unicore32}/puv3.c |  0
 hw/xtensa/Makefile.objs   |  4 +--
 hw/{xtensa_pic.c = xtensa/pic_cpu.c} |  0
 hw/{ = xtensa}/xtensa_lx60.c |  0
 hw/{ = xtensa}/xtensa_sim.c  |  0
 85 files changed, 72 insertions(+), 62 deletions(-)
 rename hw/{alpha_dp264.c = alpha/dp264.c} (100%)
 rename hw/{alpha_pci.c = 

[Qemu-devel] [PATCH 16/18] ppc: move files referencing CPU to hw/ppc/

2013-03-01 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/ppc/Makefile.objs| 13 ++---
 hw/{ = ppc}/mpc8544_guts.c |  0
 hw/{ = ppc}/ppc4xx_devs.c  |  0
 hw/{ = ppc}/ppce500_spin.c |  0
 hw/{ = ppc}/spapr_vio.c|  0
 hw/{ = ppc}/xics.c |  0
 6 files changed, 6 insertions(+), 7 deletions(-)
 rename hw/{ = ppc}/mpc8544_guts.c (100%)
 rename hw/{ = ppc}/ppc4xx_devs.c (100%)
 rename hw/{ = ppc}/ppce500_spin.c (100%)
 rename hw/{ = ppc}/spapr_vio.c (100%)
 rename hw/{ = ppc}/xics.c (100%)

diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index 294d0de..acc9961 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -1,14 +1,12 @@
 # PREP target
 obj-y += mc146818rtc.o
 # IBM pSeries (sPAPR)
-obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_rtas.o spapr_vio.o
-obj-$(CONFIG_PSERIES) += xics.o spapr_vty.o spapr_llan.o spapr_vscsi.o
+obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_rtas.o
+obj-$(CONFIG_PSERIES) += spapr_vty.o spapr_llan.o spapr_vscsi.o
 obj-$(CONFIG_PSERIES) += spapr_pci.o pci/pci-hotplug.o spapr_iommu.o
 obj-$(CONFIG_PSERIES) += spapr_events.o spapr_nvram.o
 # PowerPC 4xx boards
-obj-y += ppc4xx_devs.o ppc4xx_pci.o
-# PowerPC E500 boards
-obj-$(CONFIG_E500) += mpc8544_guts.o ppce500_spin.o
+obj-y += ppc4xx_pci.o
 # PowerPC OpenPIC
 obj-y += openpic.o
 
@@ -20,9 +18,9 @@ obj-y := $(addprefix ../,$(obj-y))
 # shared objects
 obj-y += ppc.o ppc_booke.o
 # IBM pSeries (sPAPR)
-obj-$(CONFIG_PSERIES) += spapr.o
+obj-$(CONFIG_PSERIES) += spapr.o xics.o spapr_vio.o
 # PowerPC 4xx boards
-obj-y += ppc405_boards.o ppc405_uc.o ppc440_bamboo.o
+obj-y += ppc405_boards.o ppc4xx_devs.o ppc405_uc.o ppc440_bamboo.o
 # PReP
 obj-y += prep.o
 # OldWorld PowerMac
@@ -31,5 +29,6 @@ obj-y += mac_oldworld.o
 obj-y += mac_newworld.o
 # e500
 obj-$(CONFIG_E500) += e500.o mpc8544ds.o e500plat.o
+obj-$(CONFIG_E500) += mpc8544_guts.o ppce500_spin.o
 # PowerPC 440 Xilinx ML507 reference board.
 obj-y += virtex_ml507.o
diff --git a/hw/mpc8544_guts.c b/hw/ppc/mpc8544_guts.c
similarity index 100%
rename from hw/mpc8544_guts.c
rename to hw/ppc/mpc8544_guts.c
diff --git a/hw/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c
similarity index 100%
rename from hw/ppc4xx_devs.c
rename to hw/ppc/ppc4xx_devs.c
diff --git a/hw/ppce500_spin.c b/hw/ppc/ppce500_spin.c
similarity index 100%
rename from hw/ppce500_spin.c
rename to hw/ppc/ppce500_spin.c
diff --git a/hw/spapr_vio.c b/hw/ppc/spapr_vio.c
similarity index 100%
rename from hw/spapr_vio.c
rename to hw/ppc/spapr_vio.c
diff --git a/hw/xics.c b/hw/ppc/xics.c
similarity index 100%
rename from hw/xics.c
rename to hw/ppc/xics.c
-- 
1.8.1.4





[Qemu-devel] [PATCH 08/18] ppc: do not use ../ in include files

2013-03-01 Thread Paolo Bonzini
This simplifies the scripted execution of the next patch.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/ppc/e500-ccsr.h | 2 +-
 hw/ppc/e500plat.c  | 2 +-
 hw/ppc/mpc8544ds.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/e500-ccsr.h b/hw/ppc/e500-ccsr.h
index f20f51b..12a2ba4 100644
--- a/hw/ppc/e500-ccsr.h
+++ b/hw/ppc/e500-ccsr.h
@@ -1,7 +1,7 @@
 #ifndef E500_CCSR_H
 #define E500_CCSR_H
 
-#include ../sysbus.h
+#include hw/sysbus.h
 
 typedef struct PPCE500CCSRState {
 /* private */
diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c
index 25ac4b1..4b30575 100644
--- a/hw/ppc/e500plat.c
+++ b/hw/ppc/e500plat.c
@@ -12,7 +12,7 @@
 #include config.h
 #include qemu-common.h
 #include e500.h
-#include ../boards.h
+#include hw/boards.h
 #include sysemu/device_tree.h
 #include hw/pci/pci.h
 #include hw/openpic.h
diff --git a/hw/ppc/mpc8544ds.c b/hw/ppc/mpc8544ds.c
index e25c70b..cf29788 100644
--- a/hw/ppc/mpc8544ds.c
+++ b/hw/ppc/mpc8544ds.c
@@ -12,7 +12,7 @@
 #include config.h
 #include qemu-common.h
 #include e500.h
-#include ../boards.h
+#include hw/boards.h
 #include sysemu/device_tree.h
 #include hw/openpic.h
 
-- 
1.8.1.4





[Qemu-devel] [PATCH 15/18] m68k: move files referencing CPU to hw/m68k/

2013-03-01 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/m68k/Makefile.objs| 3 ++-
 hw/{ = m68k}/mcf5206.c  | 0
 hw/{ = m68k}/mcf_intc.c | 0
 3 files changed, 2 insertions(+), 1 deletion(-)
 rename hw/{ = m68k}/mcf5206.c (100%)
 rename hw/{ = m68k}/mcf_intc.c (100%)

diff --git a/hw/m68k/Makefile.objs b/hw/m68k/Makefile.objs
index 7c033a8..ede32a7 100644
--- a/hw/m68k/Makefile.objs
+++ b/hw/m68k/Makefile.objs
@@ -1,7 +1,8 @@
-obj-y = mcf5206.o mcf_uart.o mcf_intc.o mcf_fec.o
+obj-y = mcf_uart.o mcf_fec.o
 
 obj-y := $(addprefix ../,$(obj-y))
 
 obj-y += an5206.o mcf5208.o
 obj-y += dummy_m68k.o
 
+obj-y += mcf5206.o mcf_intc.o
diff --git a/hw/mcf5206.c b/hw/m68k/mcf5206.c
similarity index 100%
rename from hw/mcf5206.c
rename to hw/m68k/mcf5206.c
diff --git a/hw/mcf_intc.c b/hw/m68k/mcf_intc.c
similarity index 100%
rename from hw/mcf_intc.c
rename to hw/m68k/mcf_intc.c
-- 
1.8.1.4





[Qemu-devel] [PATCH 06/18] virtio-9p: remove PCI dependencies from hw/9pfs/

2013-03-01 Thread Paolo Bonzini
Also move the 9p.h file to 9pfs/virtio-9p-device.h, for consistency
with the corresponding .c file.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/9pfs/virtio-9p-device.c   | 53 +---
 hw/{9p.h = 9pfs/virtio-9p-device.h} |  4 +--
 hw/9pfs/virtio-9p.c  |  3 +-
 hw/9pfs/virtio-9p.h  |  1 -
 hw/virtio-pci.c  | 50 +-
 hw/virtio-pci.h  |  2 +-
 hw/virtio.h  |  2 +-
 7 files changed, 55 insertions(+), 60 deletions(-)
 rename hw/{9p.h = 9pfs/virtio-9p-device.h} (85%)

diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 74155fb..d321c80 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -14,9 +14,9 @@
 #include hw/virtio.h
 #include hw/pc.h
 #include qemu/sockets.h
-#include hw/virtio-pci.h
 #include virtio-9p.h
 #include fsdev/qemu-fsdev.h
+#include virtio-9p-device.h
 #include virtio-9p-xattr.h
 #include virtio-9p-coth.h
 
@@ -136,54 +136,3 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf 
*conf)
 
 return s-vdev;
 }
-
-static int virtio_9p_init_pci(PCIDevice *pci_dev)
-{
-VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
-VirtIODevice *vdev;
-
-vdev = virtio_9p_init(pci_dev-qdev, proxy-fsconf);
-vdev-nvectors = proxy-nvectors;
-virtio_init_pci(proxy, vdev);
-/* make the actual value visible */
-proxy-nvectors = vdev-nvectors;
-return 0;
-}
-
-static Property virtio_9p_properties[] = {
-DEFINE_PROP_BIT(ioeventfd, VirtIOPCIProxy, flags, 
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
-DEFINE_PROP_UINT32(vectors, VirtIOPCIProxy, nvectors, 2),
-DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
-DEFINE_PROP_STRING(mount_tag, VirtIOPCIProxy, fsconf.tag),
-DEFINE_PROP_STRING(fsdev, VirtIOPCIProxy, fsconf.fsdev_id),
-DEFINE_PROP_END_OF_LIST(),
-};
-
-static void virtio_9p_class_init(ObjectClass *klass, void *data)
-{
-DeviceClass *dc = DEVICE_CLASS(klass);
-PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
-
-k-init = virtio_9p_init_pci;
-k-vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
-k-device_id = PCI_DEVICE_ID_VIRTIO_9P;
-k-revision = VIRTIO_PCI_ABI_VERSION;
-k-class_id = 0x2;
-dc-props = virtio_9p_properties;
-dc-reset = virtio_pci_reset;
-}
-
-static const TypeInfo virtio_9p_info = {
-.name  = virtio-9p-pci,
-.parent= TYPE_PCI_DEVICE,
-.instance_size = sizeof(VirtIOPCIProxy),
-.class_init= virtio_9p_class_init,
-};
-
-static void virtio_9p_register_types(void)
-{
-type_register_static(virtio_9p_info);
-virtio_9p_set_fd_limit();
-}
-
-type_init(virtio_9p_register_types)
diff --git a/hw/9p.h b/hw/9pfs/virtio-9p-device.h
similarity index 85%
rename from hw/9p.h
rename to hw/9pfs/virtio-9p-device.h
index d9951d6..65789db 100644
--- a/hw/9p.h
+++ b/hw/9pfs/virtio-9p-device.h
@@ -11,8 +11,8 @@
  *
  */
 
-#ifndef QEMU_9P_H
-#define QEMU_9P_H
+#ifndef QEMU_VIRTIO_9P_DEVICE_H
+#define QEMU_VIRTIO_9P_DEVICE_H
 
 typedef struct V9fsConf
 {
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index d3ea820..5cc4c92 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -14,7 +14,6 @@
 #include hw/virtio.h
 #include hw/pc.h
 #include qemu/sockets.h
-#include hw/virtio-pci.h
 #include virtio-9p.h
 #include fsdev/qemu-fsdev.h
 #include virtio-9p-xattr.h
@@ -3269,7 +3268,7 @@ void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
 free_pdu(s, pdu);
 }
 
-void virtio_9p_set_fd_limit(void)
+static void __attribute__((__constructor__)) virtio_9p_set_fd_limit(void)
 {
 struct rlimit rlim;
 if (getrlimit(RLIMIT_NOFILE, rlim)  0) {
diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h
index 406fe52..52b1c69 100644
--- a/hw/9pfs/virtio-9p.h
+++ b/hw/9pfs/virtio-9p.h
@@ -389,7 +389,6 @@ static inline uint8_t v9fs_request_cancelled(V9fsPDU *pdu)
 }
 
 extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq);
-extern void virtio_9p_set_fd_limit(void);
 extern void v9fs_reclaim_fd(V9fsPDU *pdu);
 extern void v9fs_path_init(V9fsPath *path);
 extern void v9fs_path_free(V9fsPath *path);
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index a869f53..df1dd77 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -255,7 +255,7 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
 proxy-ioeventfd_started = false;
 }
 
-void virtio_pci_reset(DeviceState *d)
+static void virtio_pci_reset(DeviceState *d)
 {
 VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
 virtio_pci_stop_ioeventfd(proxy);
@@ -1313,6 +1313,51 @@ static const TypeInfo virtio_scsi_info = {
 .class_init= virtio_scsi_class_init,
 };
 
+#ifdef CONFIG_VIRTFS
+static int virtio_9p_init_pci(PCIDevice *pci_dev)
+{
+VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
+VirtIODevice *vdev;
+
+vdev = 

[Qemu-devel] [PATCH 17/18] ppc: move more files to hw/ppc

2013-03-01 Thread Paolo Bonzini
These sPAPR files do not implement devices, move them over.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/ppc/Makefile.objs| 8 
 hw/{ = ppc}/spapr_events.c | 0
 hw/{ = ppc}/spapr_hcall.c  | 0
 hw/{ = ppc}/spapr_iommu.c  | 0
 hw/{ = ppc}/spapr_rtas.c   | 0
 5 files changed, 4 insertions(+), 4 deletions(-)
 rename hw/{ = ppc}/spapr_events.c (100%)
 rename hw/{ = ppc}/spapr_hcall.c (100%)
 rename hw/{ = ppc}/spapr_iommu.c (100%)
 rename hw/{ = ppc}/spapr_rtas.c (100%)

diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index acc9961..4de0209 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -1,10 +1,9 @@
 # PREP target
 obj-y += mc146818rtc.o
 # IBM pSeries (sPAPR)
-obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_rtas.o
 obj-$(CONFIG_PSERIES) += spapr_vty.o spapr_llan.o spapr_vscsi.o
-obj-$(CONFIG_PSERIES) += spapr_pci.o pci/pci-hotplug.o spapr_iommu.o
-obj-$(CONFIG_PSERIES) += spapr_events.o spapr_nvram.o
+obj-$(CONFIG_PSERIES) += spapr_pci.o pci/pci-hotplug.o
+obj-$(CONFIG_PSERIES) += spapr_nvram.o
 # PowerPC 4xx boards
 obj-y += ppc4xx_pci.o
 # PowerPC OpenPIC
@@ -18,7 +17,8 @@ obj-y := $(addprefix ../,$(obj-y))
 # shared objects
 obj-y += ppc.o ppc_booke.o
 # IBM pSeries (sPAPR)
-obj-$(CONFIG_PSERIES) += spapr.o xics.o spapr_vio.o
+obj-$(CONFIG_PSERIES) += spapr.o xics.o spapr_vio.o spapr_events.o
+obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
 # PowerPC 4xx boards
 obj-y += ppc405_boards.o ppc4xx_devs.o ppc405_uc.o ppc440_bamboo.o
 # PReP
diff --git a/hw/spapr_events.c b/hw/ppc/spapr_events.c
similarity index 100%
rename from hw/spapr_events.c
rename to hw/ppc/spapr_events.c
diff --git a/hw/spapr_hcall.c b/hw/ppc/spapr_hcall.c
similarity index 100%
rename from hw/spapr_hcall.c
rename to hw/ppc/spapr_hcall.c
diff --git a/hw/spapr_iommu.c b/hw/ppc/spapr_iommu.c
similarity index 100%
rename from hw/spapr_iommu.c
rename to hw/ppc/spapr_iommu.c
diff --git a/hw/spapr_rtas.c b/hw/ppc/spapr_rtas.c
similarity index 100%
rename from hw/spapr_rtas.c
rename to hw/ppc/spapr_rtas.c
-- 
1.8.1.4





[Qemu-devel] [PATCH 10/18] build: always link device_tree.o into emulators if libfdt available

2013-03-01 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 Makefile.target | 1 +
 configure   | 7 +--
 hw/arm/Makefile.objs| 1 -
 hw/microblaze/Makefile.objs | 1 -
 hw/ppc/Makefile.objs| 1 -
 5 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index ca657b3..2bd6d14 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -111,6 +111,7 @@ CONFIG_NO_CORE_DUMP = $(if $(subst 
n,,$(CONFIG_HAVE_CORE_DUMP)),n,y)
 obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o
 obj-y += qtest.o
 obj-y += hw/
+obj-$(CONFIG_FDT) += device_tree.o
 obj-$(CONFIG_KVM) += kvm-all.o
 obj-$(CONFIG_NO_KVM) += kvm-stub.o
 obj-y += memory.o savevm.o cputlb.o
diff --git a/configure b/configure
index 19738ac..8fdc2cf 100755
--- a/configure
+++ b/configure
@@ -2416,6 +2416,7 @@ int main(void) { return 0; }
 EOF
   if compile_prog  $fdt_libs ; then
 fdt=yes
+libs_softmmu=$libs_softmmu $fdt_libs
   else
 if test $fdt = yes ; then
   feature_not_found fdt
@@ -3981,7 +3982,6 @@ case $target_arch2 in
 target_nptl=yes
 gdb_xml_files=arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml
 target_llong_alignment=4
-target_libs_softmmu=$fdt_libs
   ;;
   cris)
 target_nptl=yes
@@ -4000,7 +4000,6 @@ case $target_arch2 in
 TARGET_ARCH=microblaze
 bflt=yes
 target_nptl=yes
-target_libs_softmmu=$fdt_libs
   ;;
   mips|mipsel)
 TARGET_ARCH=mips
@@ -4025,21 +4024,18 @@ case $target_arch2 in
   ppc)
 gdb_xml_files=power-core.xml power-fpu.xml power-altivec.xml 
power-spe.xml
 target_nptl=yes
-target_libs_softmmu=$fdt_libs
   ;;
   ppcemb)
 TARGET_BASE_ARCH=ppc
 TARGET_ABI_DIR=ppc
 gdb_xml_files=power-core.xml power-fpu.xml power-altivec.xml 
power-spe.xml
 target_nptl=yes
-target_libs_softmmu=$fdt_libs
   ;;
   ppc64)
 TARGET_BASE_ARCH=ppc
 TARGET_ABI_DIR=ppc
 gdb_xml_files=power64-core.xml power-fpu.xml power-altivec.xml 
power-spe.xml
 target_long_alignment=8
-target_libs_softmmu=$fdt_libs
   ;;
   ppc64abi32)
 TARGET_ARCH=ppc64
@@ -4047,7 +4043,6 @@ case $target_arch2 in
 TARGET_ABI_DIR=ppc
 echo TARGET_ABI32=y  $config_target_mak
 gdb_xml_files=power64-core.xml power-fpu.xml power-altivec.xml 
power-spe.xml
-target_libs_softmmu=$fdt_libs
   ;;
   sh4|sh4eb)
 TARGET_ARCH=sh4
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
index 4c10985..3eb1366 100644
--- a/hw/arm/Makefile.objs
+++ b/hw/arm/Makefile.objs
@@ -31,6 +31,5 @@ obj-y += strongarm.o
 obj-y += collie.o
 obj-y += imx_serial.o imx_ccm.o imx_timer.o imx_avic.o
 obj-y += kzm.o
-obj-$(CONFIG_FDT) += ../device_tree.o
 
 obj-y := $(addprefix ../,$(obj-y))
diff --git a/hw/microblaze/Makefile.objs b/hw/microblaze/Makefile.objs
index 3028e65..2ff8048 100644
--- a/hw/microblaze/Makefile.objs
+++ b/hw/microblaze/Makefile.objs
@@ -5,6 +5,5 @@ obj-y += xilinx_spi.o
 
 obj-y += microblaze_pic_cpu.o
 obj-y += xilinx_ethlite.o
-obj-$(CONFIG_FDT) += ../device_tree.o
 
 obj-y := $(addprefix ../,$(obj-y))
diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index f762050..bbbe78e 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -16,7 +16,6 @@ obj-$(CONFIG_FDT) += mpc8544_guts.o ppce500_spin.o
 obj-y += virtex_ml507.o
 # PowerPC OpenPIC
 obj-y += openpic.o
-obj-$(CONFIG_FDT) += ../device_tree.o
 
 # Xilinx PPC peripherals
 obj-y += xilinx_ethlite.o
-- 
1.8.1.4





[Qemu-devel] [PATCH 11/18] ppc: express FDT dependency of pSeries and e500 boards via default-configs/

2013-03-01 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 configure  | 3 ---
 default-configs/ppc-softmmu.mak| 1 +
 default-configs/ppc64-softmmu.mak  | 2 ++
 default-configs/ppcemb-softmmu.mak | 1 +
 hw/ppc/Makefile.objs   | 4 ++--
 5 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 8fdc2cf..ae3d9c5 100755
--- a/configure
+++ b/configure
@@ -4144,9 +4144,6 @@ case $target_arch2 in
   i386|x86_64)
 echo CONFIG_HAVE_GET_MEMORY_MAPPING=y  $config_target_mak
 esac
-if test $target_arch2 = ppc64 -a $fdt = yes; then
-  echo CONFIG_PSERIES=y  $config_target_mak
-fi
 if test $target_bigendian = yes ; then
   echo TARGET_WORDS_BIGENDIAN=y  $config_target_mak
 fi
diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.mak
index f9f8a81..c209a8d 100644
--- a/default-configs/ppc-softmmu.mak
+++ b/default-configs/ppc-softmmu.mak
@@ -40,3 +40,4 @@ CONFIG_PFLASH_CFI02=y
 CONFIG_PTIMER=y
 CONFIG_I8259=y
 CONFIG_XILINX=y
+CONFIG_E500=$(CONFIG_FDT)
diff --git a/default-configs/ppc64-softmmu.mak 
b/default-configs/ppc64-softmmu.mak
index dc44294..8d490bd 100644
--- a/default-configs/ppc64-softmmu.mak
+++ b/default-configs/ppc64-softmmu.mak
@@ -40,3 +40,5 @@ CONFIG_PFLASH_CFI02=y
 CONFIG_PTIMER=y
 CONFIG_I8259=y
 CONFIG_XILINX=y
+CONFIG_PSERIES=$(CONFIG_FDT)
+CONFIG_E500=$(CONFIG_FDT)
diff --git a/default-configs/ppcemb-softmmu.mak 
b/default-configs/ppcemb-softmmu.mak
index 1c6bcf9..7f13421 100644
--- a/default-configs/ppcemb-softmmu.mak
+++ b/default-configs/ppcemb-softmmu.mak
@@ -35,3 +35,4 @@ CONFIG_PFLASH_CFI02=y
 CONFIG_PTIMER=y
 CONFIG_I8259=y
 CONFIG_XILINX=y
+CONFIG_E500=$(CONFIG_FDT)
diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index bbbe78e..9141373 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -11,7 +11,7 @@ obj-$(CONFIG_PSERIES) += spapr_events.o spapr_nvram.o
 obj-y += ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o
 obj-y += ppc440_bamboo.o
 # PowerPC E500 boards
-obj-$(CONFIG_FDT) += mpc8544_guts.o ppce500_spin.o
+obj-$(CONFIG_E500) += mpc8544_guts.o ppce500_spin.o
 # PowerPC 440 Xilinx ML507 reference board.
 obj-y += virtex_ml507.o
 # PowerPC OpenPIC
@@ -29,4 +29,4 @@ obj-y += mac_oldworld.o
 # NewWorld PowerMac
 obj-y += mac_newworld.o
 # e500
-obj-$(CONFIG_FDT) += e500.o mpc8544ds.o e500plat.o
+obj-$(CONFIG_E500) += e500.o mpc8544ds.o e500plat.o
-- 
1.8.1.4





[Qemu-devel] [PATCH 14/18] i386: move files referencing CPU to hw/i386/

2013-03-01 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/i386/Makefile.objs| 4 +++-
 hw/{ = i386}/kvmvapic.c | 0
 2 files changed, 3 insertions(+), 1 deletion(-)
 rename hw/{ = i386}/kvmvapic.c (100%)

diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 5d071f4..a78c0b2 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -1,5 +1,5 @@
 obj-y += mc146818rtc.o
-obj-y += apic_common.o apic.o kvmvapic.o
+obj-y += apic_common.o apic.o
 obj-y += sga.o ioapic_common.o ioapic.o piix_pci.o
 obj-y += vmport.o
 obj-y += pci/pci-hotplug.o wdt_ib700.o
@@ -18,3 +18,5 @@ obj-y := $(addprefix ../,$(obj-y))
 obj-y += multiboot.o smbios.o
 obj-y += pc.o pc_piix.o pc_q35.o
 obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
+
+obj-y += kvmvapic.o
diff --git a/hw/kvmvapic.c b/hw/i386/kvmvapic.c
similarity index 100%
rename from hw/kvmvapic.c
rename to hw/i386/kvmvapic.c
-- 
1.8.1.4





Re: [Qemu-devel] [ARM] Cortex-R4F and VFP3-D16

2013-03-01 Thread Fabien Chouteau
On 03/01/2013 01:16 PM, Peter Maydell wrote:
 On 1 March 2013 12:07, Fabien Chouteau chout...@adacore.com wrote:
 On 03/01/2013 12:32 PM, Peter Maydell wrote:
 I think you're going to have to run some tests on the actual
 hardware to find out what it really does. Specifically, what
 are the values of SCTLR.IE, SCTLR.EE and CPSR.E when you think
 you're in big-endian mode?

 SCTLR.IE and SCTLR.EE are both set to 1 at reset and the values
 cannot be changed.

 OK, that makes sense. I think it's also a reasonable thing for
 qemu's qemu-system-armeb model to present to the guest. Have
 you changed QEMU to report IE and EE (and CPSR.E) as always-1,
 or does your guest code just not look at them?


We don't look at them so I didn't change anything, but maybe it's not
difficult to do.

-- 
Fabien Chouteau



Re: [Qemu-devel] [PATCH] Use qemu_open / qemu_close in rng backend

2013-03-01 Thread Eric Blake
[don't you also need to cc the main qemu list, even for trivial patches?]

On 03/01/2013 05:53 AM, Stefan Berger wrote:
 In the rng backend use qemu_open and qemu_close rather than POSIX
 open/close.
 
 Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com

Reviewed-by: Eric Blake ebl...@redhat.com

 
 diff --git a/backends/rng-random.c b/backends/rng-random.c
 index 0d11088..acd20af 100644
 --- a/backends/rng-random.c
 +++ b/backends/rng-random.c
 @@ -74,7 +74,7 @@ static void rng_random_opened(RngBackend *b, Error
 **errp)
  error_set(errp, QERR_INVALID_PARAMETER_VALUE,
filename, a valid filename);
  } else {
 -s-fd = open(s-filename, O_RDONLY | O_NONBLOCK);
 +s-fd = qemu_open(s-filename, O_RDONLY | O_NONBLOCK);
 
  if (s-fd == -1) {
  error_set(errp, QERR_OPEN_FILE_FAILED, s-filename);
 @@ -130,7 +130,7 @@ static void rng_random_finalize(Object *obj)
  qemu_set_fd_handler(s-fd, NULL, NULL, NULL);
 
  if (s-fd != -1) {
 -close(s-fd);
 +qemu_close(s-fd);
  }
 
  g_free(s-filename);
 
 
 

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] migration: use XBZRLE only after bulk stage

2013-03-01 Thread Eric Blake
On 03/01/2013 06:31 AM, Peter Lieven wrote:
 at the beginning of migration all pages are marked dirty and
 in the first round a bulk migration of all pages is performed.
 
 currently all these pages are copied to the page cache regardless
 if there are frequently updated or not. this doesn't make sense
 since most of these pages are never transferred again.
 
 this patch changes the XBZRLE transfer to only be used after
 the bulk stage has been completed. that means a page is added
 to the page cache the second time it is transferred and XBZRLE
 can benefit from the third time of transfer.
 
 since the page cache is likely smaller than the number of pages
 its also likely that in the second round the page is missing in the
 cache due to collisions in the bulk phase.
 
 on the other hand a lot of unneccssary mallocs, memdups and frees

s/unneccssary/unnecessary/

 are saved.
 
 Signed-off-by: Peter Lieven p...@kamp.de

Do you have any benchmark numbers?  At any rate, the explanation seems
sound, so a benchmark should show this.

 ---
  arch_init.c |5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Eric Blake ebl...@redhat.com

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] migration: use XBZRLE only after bulk stage

2013-03-01 Thread Paolo Bonzini
Il 01/03/2013 14:52, Eric Blake ha scritto:
 On 03/01/2013 06:31 AM, Peter Lieven wrote:
 at the beginning of migration all pages are marked dirty and
 in the first round a bulk migration of all pages is performed.

 currently all these pages are copied to the page cache regardless
 if there are frequently updated or not. this doesn't make sense
 since most of these pages are never transferred again.

 this patch changes the XBZRLE transfer to only be used after
 the bulk stage has been completed. that means a page is added
 to the page cache the second time it is transferred and XBZRLE
 can benefit from the third time of transfer.

 since the page cache is likely smaller than the number of pages
 its also likely that in the second round the page is missing in the
 cache due to collisions in the bulk phase.

 on the other hand a lot of unneccssary mallocs, memdups and frees
 
 s/unneccssary/unnecessary/
 
 are saved.

 Signed-off-by: Peter Lieven p...@kamp.de
 
 Do you have any benchmark numbers?  At any rate, the explanation seems
 sound, so a benchmark should show this.

It probably would be much less of a problem with the pending patches to
move RAM migration out of the big QEMU lock.  However, the explanation
makes sense.

Paolo

 ---
  arch_init.c |5 -
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 Reviewed-by: Eric Blake ebl...@redhat.com
 




[Qemu-devel] [PATCH 13/18] arm: move files referencing CPU to hw/arm/

2013-03-01 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/arm/Makefile.objs   | 13 -
 hw/{ = arm}/armv7m.c  |  0
 hw/{ = arm}/exynos4210.c  |  0
 hw/{ = arm}/omap1.c   |  0
 hw/{ = arm}/omap2.c   |  0
 hw/{ = arm}/pxa2xx.c  |  0
 hw/{ = arm}/pxa2xx_gpio.c |  0
 hw/{ = arm}/pxa2xx_pic.c  |  0
 8 files changed, 8 insertions(+), 5 deletions(-)
 rename hw/{ = arm}/armv7m.c (100%)
 rename hw/{ = arm}/exynos4210.c (100%)
 rename hw/{ = arm}/omap1.c (100%)
 rename hw/{ = arm}/omap2.c (100%)
 rename hw/{ = arm}/pxa2xx.c (100%)
 rename hw/{ = arm}/pxa2xx_gpio.c (100%)
 rename hw/{ = arm}/pxa2xx_pic.c (100%)

diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
index c09cc3a..aebbc86 100644
--- a/hw/arm/Makefile.objs
+++ b/hw/arm/Makefile.objs
@@ -3,18 +3,18 @@ obj-y += xilinx_spips.o
 obj-y += arm_gic.o arm_gic_common.o
 obj-y += a9scu.o
 obj-y += realview_gic.o arm_sysctl.o arm11mpcore.o a9mpcore.o
-obj-y += exynos4210_gic.o exynos4210_combiner.o exynos4210.o
+obj-y += exynos4210_gic.o exynos4210_combiner.o
 obj-y += exynos4210_uart.o exynos4210_pwm.o
 obj-y += exynos4210_pmu.o exynos4210_mct.o exynos4210_fimd.o
 obj-y += exynos4210_rtc.o exynos4210_i2c.o
 obj-y += arm_mptimer.o a15mpcore.o
-obj-y += armv7m.o armv7m_nvic.o stellaris_enet.o
-obj-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
+obj-y += armv7m_nvic.o stellaris_enet.o
+obj-y += pxa2xx_timer.o pxa2xx_dma.o
 obj-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
 obj-y += zaurus.o ide/microdrive.o tc6393xb.o
-obj-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o \
+obj-y += omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o \
 omap_gpio.o omap_intc.o omap_uart.o
-obj-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o \
+obj-y += omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o \
 omap_gpmc.o omap_sdrc.o omap_spi.o omap_tap.o omap_l4.o
 obj-y += tsc210x.o
 obj-y += blizzard.o onenand.o cbus.o tusb6010.o usb/hcd-musb.o
@@ -30,3 +30,6 @@ obj-y += boot.o collie.o exynos4_boards.o gumstix.o highbank.o
 obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o
 obj-y += omap_sx1.o palm.o pic_cpu.o realview.o spitz.o stellaris.o
 obj-y += tosa.o versatilepb.o vexpress.o xilinx_zynq.o z2.o
+
+obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
+obj-y += omap1.o omap2.o
diff --git a/hw/armv7m.c b/hw/arm/armv7m.c
similarity index 100%
rename from hw/armv7m.c
rename to hw/arm/armv7m.c
diff --git a/hw/exynos4210.c b/hw/arm/exynos4210.c
similarity index 100%
rename from hw/exynos4210.c
rename to hw/arm/exynos4210.c
diff --git a/hw/omap1.c b/hw/arm/omap1.c
similarity index 100%
rename from hw/omap1.c
rename to hw/arm/omap1.c
diff --git a/hw/omap2.c b/hw/arm/omap2.c
similarity index 100%
rename from hw/omap2.c
rename to hw/arm/omap2.c
diff --git a/hw/pxa2xx.c b/hw/arm/pxa2xx.c
similarity index 100%
rename from hw/pxa2xx.c
rename to hw/arm/pxa2xx.c
diff --git a/hw/pxa2xx_gpio.c b/hw/arm/pxa2xx_gpio.c
similarity index 100%
rename from hw/pxa2xx_gpio.c
rename to hw/arm/pxa2xx_gpio.c
diff --git a/hw/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c
similarity index 100%
rename from hw/pxa2xx_pic.c
rename to hw/arm/pxa2xx_pic.c
-- 
1.8.1.4





Re: [Qemu-devel] [PATCH] migration: use XBZRLE only after bulk stage

2013-03-01 Thread Peter Lieven

On 01.03.2013 14:52, Eric Blake wrote:

On 03/01/2013 06:31 AM, Peter Lieven wrote:

at the beginning of migration all pages are marked dirty and
in the first round a bulk migration of all pages is performed.

currently all these pages are copied to the page cache regardless
if there are frequently updated or not. this doesn't make sense
since most of these pages are never transferred again.

this patch changes the XBZRLE transfer to only be used after
the bulk stage has been completed. that means a page is added
to the page cache the second time it is transferred and XBZRLE
can benefit from the third time of transfer.

since the page cache is likely smaller than the number of pages
its also likely that in the second round the page is missing in the
cache due to collisions in the bulk phase.

on the other hand a lot of unneccssary mallocs, memdups and frees


s/unneccssary/unnecessary/


are saved.

Signed-off-by: Peter Lieven p...@kamp.de


Do you have any benchmark numbers?  At any rate, the explanation seems
sound, so a benchmark should show this.


Do you have a particular test pattern in mind? If there is nothing going on
in the VM XBZRLE will not be better than normal copy at all.

Otherwise you will have N xbzrle misses and 0 xbzrle pages without the patch
and 0 xbzrle misses and 0 xbzrle pages with the patch.

Peter




---
  arch_init.c |5 -
  1 file changed, 4 insertions(+), 1 deletion(-)


Reviewed-by: Eric Blake ebl...@redhat.com






[Qemu-devel] [PATCH 04/18] hw: move device-hotplug.o to toplevel, compile it once

2013-03-01 Thread Paolo Bonzini
The situation with device-hotplug.c is similar to qdev-monitor.c.
Add a stub for pci_drive_hot_add, so that it can be compiled once,
and move it out of hw/.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 Makefile.objs   |  2 +-
 hw/device-hotplug.c = device-hotplug.c | 13 ++---
 hw/Makefile.objs|  1 -
 stubs/Makefile.objs |  1 +
 stubs/pci-drive-hot-add.c   | 10 ++
 5 files changed, 14 insertions(+), 13 deletions(-)
 rename hw/device-hotplug.c = device-hotplug.c (88%)
 create mode 100644 stubs/pci-drive-hot-add.c

diff --git a/Makefile.objs b/Makefile.objs
index 2a8174d..8c90b92 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -51,7 +51,7 @@ ifeq ($(CONFIG_SOFTMMU),y)
 common-obj-y = $(block-obj-y) blockdev.o blockdev-nbd.o block/
 common-obj-y += net/
 common-obj-y += readline.o
-common-obj-y += qdev-monitor.o
+common-obj-y += qdev-monitor.o device-hotplug.o
 common-obj-$(CONFIG_WIN32) += os-win32.o
 common-obj-$(CONFIG_POSIX) += os-posix.o
 
diff --git a/hw/device-hotplug.c b/device-hotplug.c
similarity index 88%
rename from hw/device-hotplug.c
rename to device-hotplug.c
index 88da145..103d34a 100644
--- a/hw/device-hotplug.c
+++ b/device-hotplug.c
@@ -22,8 +22,8 @@
  * THE SOFTWARE.
  */
 
-#include hw.h
-#include boards.h
+#include hw/hw.h
+#include hw/boards.h
 #include sysemu/blockdev.h
 #include qemu/config-file.h
 #include sysemu/sysemu.h
@@ -47,15 +47,6 @@ DriveInfo *add_init_drive(const char *optstr)
 return dinfo;
 }
 
-#if !defined(TARGET_I386)
-int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo)
-{
-/* On non-x86 we don't do PCI hotplug */
-monitor_printf(mon, Can't hot-add drive to type %d\n, dinfo-type);
-return -1;
-}
-#endif
-
 void drive_hot_add(Monitor *mon, const QDict *qdict)
 {
 DriveInfo *dinfo = NULL;
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index f7ee133..43f467a 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -206,7 +206,6 @@ obj-$(CONFIG_SOFTMMU) += vhost_net.o
 obj-$(CONFIG_VHOST_NET) += vhost.o
 obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/
 obj-$(CONFIG_VGA) += vga.o
-obj-$(CONFIG_SOFTMMU) += device-hotplug.o
 obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
 
 # Inter-VM PCI shared memory  VFIO PCI device assignment
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index a260394..9c55b34 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -15,6 +15,7 @@ stub-obj-y += mon-printf.o
 stub-obj-y += mon-print-filename.o
 stub-obj-y += mon-protocol-event.o
 stub-obj-y += mon-set-error.o
+stub-obj-y += pci-drive-hot-add.o
 stub-obj-y += reset.o
 stub-obj-y += set-fd-handler.o
 stub-obj-y += slirp.o
diff --git a/stubs/pci-drive-hot-add.c b/stubs/pci-drive-hot-add.c
new file mode 100644
index 000..1d98145
--- /dev/null
+++ b/stubs/pci-drive-hot-add.c
@@ -0,0 +1,10 @@
+#include monitor/monitor.h
+#include sysemu/sysemu.h
+#include sysemu/blockdev.h
+
+int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo)
+{
+/* On non-x86 we don't do PCI hotplug */
+monitor_printf(mon, Can't hot-add drive to type %d\n, dinfo-type);
+return -1;
+}
-- 
1.8.1.4





Re: [Qemu-devel] [PATCH] migration: use XBZRLE only after bulk stage

2013-03-01 Thread Eric Blake
On 03/01/2013 07:06 AM, Peter Lieven wrote:
 Do you have any benchmark numbers?  At any rate, the explanation seems
 sound, so a benchmark should show this.
 
 Do you have a particular test pattern in mind? If there is nothing going on
 in the VM XBZRLE will not be better than normal copy at all.
 
 Otherwise you will have N xbzrle misses and 0 xbzrle pages without the
 patch
 and 0 xbzrle misses and 0 xbzrle pages with the patch.

How about a migration of a guest running the synthetic r/w load
generator in docs/xbzrle.txt?

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] migration: use XBZRLE only after bulk stage

2013-03-01 Thread Peter Lieven

On 01.03.2013 15:08, Eric Blake wrote:

On 03/01/2013 07:06 AM, Peter Lieven wrote:

Do you have any benchmark numbers?  At any rate, the explanation seems
sound, so a benchmark should show this.


Do you have a particular test pattern in mind? If there is nothing going on
in the VM XBZRLE will not be better than normal copy at all.

Otherwise you will have N xbzrle misses and 0 xbzrle pages without the
patch
and 0 xbzrle misses and 0 xbzrle pages with the patch.


How about a migration of a guest running the synthetic r/w load
generator in docs/xbzrle.txt?


Good idea. I will leave max downtime and bandwidth at default values.

Would you be happy with 1GB vRAM and 256MB page cache?

Peter




[Qemu-devel] [PATCH 18/18] sh: move files referencing CPU to hw/sh4/

2013-03-01 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/sh4/Makefile.objs   | 4 +++-
 hw/{ = sh4}/sh7750.c  | 0
 hw/{ = sh4}/sh7750_regnames.c | 0
 3 files changed, 3 insertions(+), 1 deletion(-)
 rename hw/{ = sh4}/sh7750.c (100%)
 rename hw/{ = sh4}/sh7750_regnames.c (100%)

diff --git a/hw/sh4/Makefile.objs b/hw/sh4/Makefile.objs
index b2e1f1e..72b6a1f 100644
--- a/hw/sh4/Makefile.objs
+++ b/hw/sh4/Makefile.objs
@@ -1,7 +1,9 @@
-obj-y = sh7750.o sh7750_regnames.o tc58128.o
+obj-y = tc58128.o
 obj-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o
 obj-y += ide/mmio.o
 
 obj-y := $(addprefix ../,$(obj-y))
 
 obj-y += shix.o r2d.o
+
+obj-y += sh7750.o sh7750_regnames.o
diff --git a/hw/sh7750.c b/hw/sh4/sh7750.c
similarity index 100%
rename from hw/sh7750.c
rename to hw/sh4/sh7750.c
diff --git a/hw/sh7750_regnames.c b/hw/sh4/sh7750_regnames.c
similarity index 100%
rename from hw/sh7750_regnames.c
rename to hw/sh4/sh7750_regnames.c
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH] migration: use XBZRLE only after bulk stage

2013-03-01 Thread Eric Blake
On 03/01/2013 07:13 AM, Peter Lieven wrote:
 On 01.03.2013 15:08, Eric Blake wrote:
 On 03/01/2013 07:06 AM, Peter Lieven wrote:
 Do you have any benchmark numbers?  At any rate, the explanation seems
 sound, so a benchmark should show this.

 Do you have a particular test pattern in mind? If there is nothing
 going on
 in the VM XBZRLE will not be better than normal copy at all.

 Otherwise you will have N xbzrle misses and 0 xbzrle pages without the
 patch
 and 0 xbzrle misses and 0 xbzrle pages with the patch.

 How about a migration of a guest running the synthetic r/w load
 generator in docs/xbzrle.txt?

 Good idea. I will leave max downtime and bandwidth at default values.
 
 Would you be happy with 1GB vRAM and 256MB page cache?

Sure - just any run that you can do that shows before and after numbers,
and that is described well enough to be a reproducible test.  Final
statistics on the migration (pages transferred, cache hits and misses,
etc) and time spent on the migration will hopefully show an improvement,
but most important is that they do not show a regression.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v2] pci: Teach PCI Bridges about VGA routing

2013-03-01 Thread Michael S. Tsirkin
On Thu, Feb 28, 2013 at 02:58:13PM -0700, Alex Williamson wrote:
 Each PCI Bridge has a set of implied VGA regions that are enabled
 when the VGA bit is set in the bridge control register.  This allows
 VGA devices behind bridges.
 
 Signed-off-by: Alex Williamson alex.william...@redhat.com

Off-topic:

As I was reviewing this, I noted an unrelated bug: we don't make
palette snooping bit writeable.

Bridges are not required to implement the VGA support mechanisms
described in the following sections. However, if a bridge implements the
support mechanisms for VGA compatible addressing, it must also implement
the mechanisms for VGA palette snooping and vice versa.

Though I don't think we need to bother implementing palette snooping
just yet, I wonder whether we need to make it writeable.

Here's a list of things we don't implement:
- palette snooping
- subtractive decoding (optional)
- 10-bit addressing (isa aliases)

more?
I think we should have a comment in code for all this.


 ---
 
 v2: BRIDGE_CONTROL is 2 bytes
 
  hw/pci/pci_bridge.c |   45 +++--
  hw/pci/pci_bus.h|   15 +++
  2 files changed, 58 insertions(+), 2 deletions(-)
 
 diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
 index 995842a..ced0e95 100644
 --- a/hw/pci/pci_bridge.c
 +++ b/hw/pci/pci_bridge.c
 @@ -151,6 +151,37 @@ static void pci_bridge_init_alias(PCIBridge *bridge, 
 MemoryRegion *alias,
  memory_region_add_subregion_overlap(parent_space, base, alias, 1);
  }
  
 +static void pci_bridge_init_vga_aliases(PCIBridge *br, PCIBus *parent,
 +PCIBridgeVgaWindows *vga)
 +{
 +uint16_t cmd = pci_get_word(br-dev.config + PCI_COMMAND);
 +uint16_t brctl = pci_get_word(br-dev.config + PCI_BRIDGE_CONTROL);
 +
 +memory_region_init_alias(vga-alias_io_lo, pci_bridge_vga_io_lo,
 + br-address_space_io, 0x3b0, 0xc);
 +memory_region_add_subregion_overlap(parent-address_space_io, 0x3b0,
 +vga-alias_io_lo, 1);
 +
 +memory_region_init_alias(vga-alias_io_hi, pci_bridge_vga_io_hi,
 + br-address_space_io, 0x3c0, 0x20);
 +memory_region_add_subregion_overlap(parent-address_space_io, 0x3c0,
 +vga-alias_io_hi, 1);
 +
 +if (!(cmd  PCI_COMMAND_IO) || !(brctl  PCI_BRIDGE_CTL_VGA)) {
 +memory_region_set_enabled(vga-alias_io_lo, false);
 +memory_region_set_enabled(vga-alias_io_hi, false);
 +}
 +
 +memory_region_init_alias(vga-alias_mem, pci_bridge_vga_mem,
 + br-address_space_mem, 0xa, 0x2);
 +memory_region_add_subregion_overlap(parent-address_space_mem, 0xa,
 +vga-alias_mem, 1);
 +
 +if (!(cmd  PCI_COMMAND_MEMORY) || !(brctl  PCI_BRIDGE_CTL_VGA)) {
 +memory_region_set_enabled(vga-alias_mem, false);
 +}
 +}
 +
  static PCIBridgeWindows *pci_bridge_region_init(PCIBridge *br)
  {
  PCIBus *parent = br-dev.bus;
 @@ -175,7 +206,8 @@ static PCIBridgeWindows *pci_bridge_region_init(PCIBridge 
 *br)
br-address_space_io,
parent-address_space_io,
cmd  PCI_COMMAND_IO);
 -   /* TODO: optinal VGA and VGA palette snooping support. */
 +
 +pci_bridge_init_vga_aliases(br, parent, w-vga);
  
  return w;
  }
 @@ -187,6 +219,9 @@ static void pci_bridge_region_del(PCIBridge *br, 
 PCIBridgeWindows *w)
  memory_region_del_subregion(parent-address_space_io, w-alias_io);
  memory_region_del_subregion(parent-address_space_mem, w-alias_mem);
  memory_region_del_subregion(parent-address_space_mem, 
 w-alias_pref_mem);
 +memory_region_del_subregion(parent-address_space_io, 
 w-vga.alias_io_lo);
 +memory_region_del_subregion(parent-address_space_io, 
 w-vga.alias_io_hi);
 +memory_region_del_subregion(parent-address_space_mem, 
 w-vga.alias_mem);
  }
  
  static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)
 @@ -194,6 +229,9 @@ static void pci_bridge_region_cleanup(PCIBridge *br, 
 PCIBridgeWindows *w)
  memory_region_destroy(w-alias_io);
  memory_region_destroy(w-alias_mem);
  memory_region_destroy(w-alias_pref_mem);
 +memory_region_destroy(w-vga.alias_io_lo);
 +memory_region_destroy(w-vga.alias_io_hi);
 +memory_region_destroy(w-vga.alias_mem);
  g_free(w);
  }
  
 @@ -227,7 +265,10 @@ void pci_bridge_write_config(PCIDevice *d,
  
  /* memory base/limit, prefetchable base/limit and
 io base/limit upper 16 */
 -ranges_overlap(address, len, PCI_MEMORY_BASE, 20)) {
 +ranges_overlap(address, len, PCI_MEMORY_BASE, 20) ||
 +
 +/* vga enable */
 +ranges_overlap(address, len, PCI_BRIDGE_CONTROL, 2)) {
  pci_bridge_update_mappings(s);
  }
  
 diff --git 

Re: [Qemu-devel] [PATCH] migration: use XBZRLE only after bulk stage

2013-03-01 Thread Peter Lieven

On 01.03.2013 15:23, Eric Blake wrote:

On 03/01/2013 07:13 AM, Peter Lieven wrote:

On 01.03.2013 15:08, Eric Blake wrote:

On 03/01/2013 07:06 AM, Peter Lieven wrote:

Do you have any benchmark numbers?  At any rate, the explanation seems
sound, so a benchmark should show this.


Do you have a particular test pattern in mind? If there is nothing
going on
in the VM XBZRLE will not be better than normal copy at all.

Otherwise you will have N xbzrle misses and 0 xbzrle pages without the
patch
and 0 xbzrle misses and 0 xbzrle pages with the patch.


How about a migration of a guest running the synthetic r/w load
generator in docs/xbzrle.txt?


Good idea. I will leave max downtime and bandwidth at default values.

Would you be happy with 1GB vRAM and 256MB page cache?


Sure - just any run that you can do that shows before and after numbers,
and that is described well enough to be a reproducible test.  Final
statistics on the migration (pages transferred, cache hits and misses,
etc) and time spent on the migration will hopefully show an improvement,
but most important is that they do not show a regression.



just a quick test on my desktop:

~/git/qemu$ x86_64-softmmu/qemu-system-x86_64 -k de -enable-kvm -m 1024 -drive 
if=virtio,file=iscsi://172.21.200.31/iqn.2001-05.com.equallogic:0-8a0906-16470e107-713001aa6de511e0-001-test/0
 -vnc :1 -boot dc -monitor stdio

using ubuntu 12.04.1 desktop and the example from docs/xbzrle.txt

a) with the patch

(qemu) info migrate
capabilities: xbzrle: on
Migration status: completed
total time: 22185 milliseconds
downtime: 29 milliseconds
transferred ram: 706034 kbytes
remaining ram: 0 kbytes
total ram: 1057216 kbytes
duplicate: 108556 pages
normal: 175146 pages
normal bytes: 700584 kbytes
cache size: 67108864 bytes
xbzrle transferred: 3127 kbytes
xbzrle pages: 117811 pages
xbzrle cache miss: 18750
xbzrle overflow : 0

b) without the patch

(qemu) info migrate
capabilities: xbzrle: on
Migration status: completed
total time: 22410 milliseconds
downtime: 21 milliseconds
transferred ram: 721318 kbytes
remaining ram: 0 kbytes
total ram: 1057216 kbytes
duplicate: 105553 pages
normal: 179589 pages
normal bytes: 718356 kbytes
cache size: 67108864 bytes
xbzrle transferred: 630 kbytes
xbzrle pages: 21527 pages
xbzrle cache miss: 179589
xbzrle overflow : 0



Re: [Qemu-devel] libvirt-QEMU interfaces for CPU models

2013-03-01 Thread Eduardo Habkost

On Fri, Mar 01, 2013 at 02:12:38PM +0100, Jiri Denemark wrote:
 On Thu, Feb 21, 2013 at 11:58:18 -0300, Eduardo Habkost wrote:
  Hi,
  
  After a long time trying to figure out the proper modelling inside QEMU,
  I believe the plans are now clearer in QEMU, so it's time to coordinate
  more closely with libvirt to try to make use of the new stuff.
  
  I tried to enumerate the libvirt requirements and current problems, and
  how we should be able to solve those problems using the X86CPU
  subclasses and properties, on the following wiki page:
  
  http://wiki.qemu.org/Features/CPUModels#Interfaces.2Frequirements_from_libvirt
 
  = Ensuring predictable set of guest features =
  
  Requirement: libvirt needs to ensure all features required on the 
  command-line
  are present and exposed to the guest.
  
  Current problem: libvirt doesn't use the enforce flag so it can't 
  guarantee
  that a given feature will be actually exposed to the guest.
  
  Solution: use the enforce flag on the -cpu option.
 
 Definitely, we plan to start using enforce flag as soon as we have
 better CPU probing interface with QEMU. Since libvirt does not currently
 consult CPU specs with QEMU, some configurations in fact rely on QEMU
 dropping features it can't provide. Of course, that's bad for several
 reasons but we don't want such configurations to suddenly stop working.
 We want to first fix the CPU specs libvirt creates so that we know they
 will work with enforce.

Also: more important than fixing the CPU definitions from libvirt, is to
ask QEMU for host capabilities and CPU model definitions. The whole
point of this is to solve the CPU model data duplication/synchronization
problems between libvirt and QEMU.

Once you are able to query CPU model definitions on runtime, you don't
even need to make cpu_map.xml agree with QEMU. You can simply ask QEMU
how each model looks like, and remove/add features from the command-line
as necessary, so the resulting VM matches what the user asked for.


 
  Limitation: no proper machine-friendly interface to report which 
  features
  are missing.
  
  Workaround: See querying for host capabilities below.
 
 I doubt we will be ready to start using enforce before the machine
 friendly interface is available...

If you query for the -cpu host capabilities first and ensure all
features from a CPU model is available, enforce is supposed to not fail.

I understand that a machine-friendly error reporting for enforce would
be very useful, but note that if enforce fails, it is probably already
too late for libvirt, and that means that what libvirt thinks about host
capabilities and CPU models is already incorrect.


The main problem preventing us from making a machine-friendly interface
is that enforce makes QEMU abort immediately, making us lose the main
machine-friendly communication mechanism, that is QMP.

(But I had an idea to solve that, look for removed-features below for
a description).


 
 
  = Listing CPU models =
  
  Requirement: libvirt needs to know which CPU models are available to be used
  with the -cpu option.
  
  Current problem: libvirt relies on help output parsing for that.
  
  Solution: use QMP qom-list-types command.
  
  Dependency: X86CPU subclasses.
  Limitation: needs a live QEMU process for the query.
 
 No problem, we already run QEMU and use several QMP commands to probe
 its capabilities. And qom-list-types is actually one of them. To get
 the list of CPU models, we would just call
 
 {
 execute: qom-list-types,
 arguments: {
 implements: X86CPU
 }
 }
 
 right? What about other non-x86 architectures? Will we need to use
 different class name or is there a generic CPU class that could be used
 universally?

Actually I don't know much about the QMP command syntax and didn't test
it a lot. But that's basically how I think it will look like. Except
that instead of X86CPU, the type name is x86_64-cpu (on
qemu-system-x86_64) and i386-cpu (on qemu-system-i386). Maybe it is
easier to simply use: implements: cpu, abstract: false }.

We may also end up with different CPU model classes for KVM and TCG,
this is still under discussion.

Another caveat: the CPU model class names will be longer than the names
used on the -cpu command-line: something like model-arch-cpu or
model-kvm-arch-cpu.


 
  Solution: use QMP query-cpu-definitions command.
  
  Limitation: needs a live QEMU process for the query.
 
 IIUC, the result of this command will depend on machine type and we
 can't use -M none we currently use for probing, right?

The class data don't depend on machine-types. But the resulting CPU
objects may look different depending on machine type.

In other words: you don't need -M to list CPU models, but you need -M if
you want to know which features are going to be available on each model,
exactly.

 
  == Future plans ==
  
  It would be interesting to get rid of the requirement for a live QEMU 
  

Re: [Qemu-devel] [ARM] Cortex-R4F and VFP3-D16

2013-03-01 Thread Fabien Chouteau
On 03/01/2013 02:43 PM, Fabien Chouteau wrote:
 On 03/01/2013 01:16 PM, Peter Maydell wrote:
 On 1 March 2013 12:07, Fabien Chouteau chout...@adacore.com wrote:
 On 03/01/2013 12:32 PM, Peter Maydell wrote:
 I think you're going to have to run some tests on the actual
 hardware to find out what it really does. Specifically, what
 are the values of SCTLR.IE, SCTLR.EE and CPSR.E when you think
 you're in big-endian mode?

 SCTLR.IE and SCTLR.EE are both set to 1 at reset and the values
 cannot be changed.

 OK, that makes sense. I think it's also a reasonable thing for
 qemu's qemu-system-armeb model to present to the guest. Have
 you changed QEMU to report IE and EE (and CPSR.E) as always-1,
 or does your guest code just not look at them?

 
 We don't look at them so I didn't change anything, but maybe it's not
 difficult to do.
 

These fields are ARMv6/7 only, right?

-- 
Fabien Chouteau



Re: [Qemu-devel] [ARM] Cortex-R4F and VFP3-D16

2013-03-01 Thread Peter Maydell
On 1 March 2013 15:10, Fabien Chouteau chout...@adacore.com wrote:
 On 03/01/2013 02:43 PM, Fabien Chouteau wrote:
 On 03/01/2013 01:16 PM, Peter Maydell wrote:
 OK, that makes sense. I think it's also a reasonable thing for
 qemu's qemu-system-armeb model to present to the guest. Have
 you changed QEMU to report IE and EE (and CPSR.E) as always-1,
 or does your guest code just not look at them?


 We don't look at them so I didn't change anything, but maybe it's not
 difficult to do.

 These fields are ARMv6/7 only, right?

That's correct -- they're part of the BE8 big-endian model which
was introduced with ARMv6. (The old v5 BE32 model uses SCTLR.B,
ie bit 7 -- on a BE8-only core, which all v7 cores are, SCTLR.B is
always 0.) On older versions of the architecture the IE and EE bits
were reserved, and read as zero. (Technically we are supposed to
implement reserved bits as 'read zero, writes ignored' but QEMU
often ignores this and implements as reads-as-written. Well
behaved guests will not notice the difference.)

-- PMM



[Qemu-devel] [PATCH v11 1/7] trace: [tracetool] Explicitly identify public backends

2013-03-01 Thread Lluís Vilanova
Public backends are those printed by --list-backends and thus considered valid
by the configure script.

Signed-off-by: Lluís Vilanova vilan...@ac.upc.edu
---
 scripts/tracetool.py  |4 ++--
 scripts/tracetool/backend/__init__.py |   16 +++-
 scripts/tracetool/backend/dtrace.py   |3 +++
 scripts/tracetool/backend/simple.py   |4 
 scripts/tracetool/backend/stderr.py   |3 +++
 scripts/tracetool/backend/ust.py  |3 +++
 6 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index c003cf6..a79ec0f 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -90,8 +90,8 @@ def main(args):
 arg_format = arg
 
 elif opt == --list-backends:
-backends = tracetool.backend.get_list()
-out(, .join([ b for b,_ in backends ]))
+public_backends = tracetool.backend.get_list(only_public = True)
+out(, .join([ b for b,_ in public_backends ]))
 sys.exit(0)
 elif opt == --check-backend:
 check_backend = True
diff --git a/scripts/tracetool/backend/__init__.py 
b/scripts/tracetool/backend/__init__.py
index be43472..f0314ee 100644
--- a/scripts/tracetool/backend/__init__.py
+++ b/scripts/tracetool/backend/__init__.py
@@ -17,6 +17,16 @@ considered its short description.
 All backends must generate their contents through the 'tracetool.out' routine.
 
 
+Backend attributes
+--
+
+= 
+Attribute Description
+= 
+PUBLICIf exists and is set to 'True', the backend is considered public.
+= 
+
+
 Backend functions
 -
 
@@ -42,7 +52,7 @@ import os
 import tracetool
 
 
-def get_list():
+def get_list(only_public = False):
 Get a list of (name, description) pairs.
 res = [(nop, Tracing disabled.)]
 modnames = []
@@ -57,6 +67,10 @@ def get_list():
 continue
 module = module[1]
 
+public = getattr(module, PUBLIC, False)
+if only_public and not public:
+continue
+
 doc = module.__doc__
 if doc is None:
 doc = 
diff --git a/scripts/tracetool/backend/dtrace.py 
b/scripts/tracetool/backend/dtrace.py
index ad5eb3b..e31bc79 100644
--- a/scripts/tracetool/backend/dtrace.py
+++ b/scripts/tracetool/backend/dtrace.py
@@ -16,6 +16,9 @@ __email__  = stefa...@linux.vnet.ibm.com
 from tracetool import out
 
 
+PUBLIC = True
+
+
 PROBEPREFIX = None
 
 def _probeprefix():
diff --git a/scripts/tracetool/backend/simple.py 
b/scripts/tracetool/backend/simple.py
index e4b4a7f..ac864f3 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -15,6 +15,10 @@ __email__  = stefa...@linux.vnet.ibm.com
 
 from tracetool import out
 
+
+PUBLIC = True
+
+
 def is_string(arg):
 strtype = ('const char*', 'char*', 'const char *', 'char *')
 if arg.lstrip().startswith(strtype):
diff --git a/scripts/tracetool/backend/stderr.py 
b/scripts/tracetool/backend/stderr.py
index 917fde7..a10fbb8 100644
--- a/scripts/tracetool/backend/stderr.py
+++ b/scripts/tracetool/backend/stderr.py
@@ -16,6 +16,9 @@ __email__  = stefa...@linux.vnet.ibm.com
 from tracetool import out
 
 
+PUBLIC = True
+
+
 def c(events):
 out('#include trace.h',
 '',
diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/ust.py
index 31a2ff0..ea36995 100644
--- a/scripts/tracetool/backend/ust.py
+++ b/scripts/tracetool/backend/ust.py
@@ -16,6 +16,9 @@ __email__  = stefa...@linux.vnet.ibm.com
 from tracetool import out
 
 
+PUBLIC = True
+
+
 def c(events):
 out('#include ust/marker.h',
 '#undef mutex_lock',




[Qemu-devel] [PATCH v11 0/7] trace: Generic event state description

2013-03-01 Thread Lluís Vilanova
Provides a generic event state description structure (TraceEvent) and a more
detailed event control and query interface.

This is achieved by creating a new non-public tracing backend (i.e., not
selectable by the user at configure time) that will generate the appropriate
event description information.

Signed-off-by: Lluís Vilanova vilan...@ac.upc.edu
---

Changes in v11:

* Rebase on a4bcea3 from master.

Changes in v10:

* Add suggestions by Stefan Hajnoczi:
  * Merge paths in 'do_trace_event_set_state'.
  * Add header guards in trace/control-internal.h.
  * Remove TODO from docs in 'trace_print_events'.
  * Rename 'glob' in trace/control.c as 'pattern_glob'.
  * Implement 'trace_event_is_pattern' in terms of 'strchr'.

Changes in v9:

* Rebase on 7cd5da7 from master.
* Change dynamic tracing state from monitor only in enabled events.
* Assert dynamic tracing state changes are performed only on enabled events.
* Split 'trace_event_set_state_dynamic' into a generic and a backend-specific
  part.

Changes in v8:

* Rebase on a2685bc from master.
* Fixed typo in commit message for trace: Provide a detailed event control
  interface.

Changes in v7:

* Rebase on a8a826a from master.
* Moved compilation  code generation for trace/ into a separate makefile.
* Renamed targets and moved rules according to the new makefile structure.

Changes in v6:

* Fixed typos in the documentation of the 'TraceEvent' struct.

Changes in v5:

* Rebase on dbaf26b3 from master.
* Always initialize temporary 'ev' in 'trace_backend_init_events'.
* Make common sanity checks in 'trace_event_set_state_dynamic' and delay
  backend-specific code to 'trace_event_set_state_dynamic_backend'.

Changes in v4:

* Documentation fixes and (re)formatting.

Changes in v3:

* Add some assertions.

* Remove debugging printf's.

* Improve documentation.

* Make 'trace_event_get_state_static' use run-time information, and leave
  TRACE_*_ENABLED for compile-time checks.


Changes in v2:

* Minor compilation fixes.


Lluís Vilanova (7):
  trace: [tracetool] Explicitly identify public backends
  trace: Provide a generic tracing event descriptor
  trace: Provide a detailed event control interface
  trace: [monitor] Use new event control interface
  trace: [default] Port to generic event information and new control 
interface
  trace: [simple] Port to generic event information and new control 
interface
  trace: [stderr] Port to generic event information and new control 
interface


 Makefile  |3 +
 docs/tracing.txt  |   44 +++-
 monitor.c |   13 ++
 scripts/tracetool.py  |4 -
 scripts/tracetool/backend/__init__.py |   16 +++
 scripts/tracetool/backend/dtrace.py   |3 +
 scripts/tracetool/backend/events.py   |   23 
 scripts/tracetool/backend/simple.py   |   22 ++--
 scripts/tracetool/backend/stderr.py   |   28 ++---
 scripts/tracetool/backend/ust.py  |3 +
 scripts/tracetool/format/events_c.py  |   39 +++
 scripts/tracetool/format/events_h.py  |   50 +
 scripts/tracetool/format/h.py |9 --
 trace/Makefile.objs   |   24 
 trace/control-internal.h  |   67 
 trace/control.c   |  106 --
 trace/control.h   |  190 ++---
 trace/default.c   |5 -
 trace/event-internal.h|   33 ++
 trace/simple.c|   32 +-
 trace/simple.h|6 -
 trace/stderr.c|   34 +-
 trace/stderr.h|   11 --
 23 files changed, 588 insertions(+), 177 deletions(-)
 create mode 100644 scripts/tracetool/backend/events.py
 create mode 100644 scripts/tracetool/format/events_c.py
 create mode 100644 scripts/tracetool/format/events_h.py
 create mode 100644 trace/control-internal.h
 create mode 100644 trace/event-internal.h
 delete mode 100644 trace/stderr.h


To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi stefa...@gmail.com
Cc: Blue Swirl blauwir...@gmail.com



[Qemu-devel] [PATCH v11 2/7] trace: Provide a generic tracing event descriptor

2013-03-01 Thread Lluís Vilanova
Uses tracetool to generate a backend-independent tracing event description
(struct TraceEvent).

The values for such structure are generated with the non-public events
backend (events-c frontend).

The generation of the defines to check if an event is statically enabled is also
moved to the events backend (events-h frontend).

Signed-off-by: Lluís Vilanova vilan...@ac.upc.edu
---
 Makefile |3 ++
 scripts/tracetool/backend/events.py  |   23 
 scripts/tracetool/format/events_c.py |   39 +++
 scripts/tracetool/format/events_h.py |   50 ++
 scripts/tracetool/format/h.py|9 +-
 trace/Makefile.objs  |   24 
 trace/event-internal.h   |   33 ++
 7 files changed, 172 insertions(+), 9 deletions(-)
 create mode 100644 scripts/tracetool/backend/events.py
 create mode 100644 scripts/tracetool/format/events_c.py
 create mode 100644 scripts/tracetool/format/events_h.py
 create mode 100644 trace/event-internal.h

diff --git a/Makefile b/Makefile
index 2262410..9a240fb 100644
--- a/Makefile
+++ b/Makefile
@@ -35,6 +35,9 @@ GENERATED_HEADERS = config-host.h qemu-options.def
 GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h
 GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c
 
+GENERATED_HEADERS += trace/generated-events.h
+GENERATED_SOURCES += trace/generated-events.c
+
 GENERATED_HEADERS += trace/generated-tracers.h
 ifeq ($(TRACE_BACKEND),dtrace)
 GENERATED_HEADERS += trace/generated-tracers-dtrace.h
diff --git a/scripts/tracetool/backend/events.py 
b/scripts/tracetool/backend/events.py
new file mode 100644
index 000..5afce3e
--- /dev/null
+++ b/scripts/tracetool/backend/events.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+Generic event description.
+
+This is a dummy backend to establish appropriate frontend/backend compatibility
+checks.
+
+
+__author__ = Lluís Vilanova vilan...@ac.upc.edu
+__copyright__  = Copyright 2012, Lluís Vilanova vilan...@ac.upc.edu
+__license__= GPL version 2 or (at your option) any later version
+
+__maintainer__ = Stefan Hajnoczi
+__email__  = stefa...@linux.vnet.ibm.com
+
+
+def events_h(events):
+pass
+
+def events_c(events):
+pass
diff --git a/scripts/tracetool/format/events_c.py 
b/scripts/tracetool/format/events_c.py
new file mode 100644
index 000..d670ec8
--- /dev/null
+++ b/scripts/tracetool/format/events_c.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+Generate .c for event description.
+
+
+__author__ = Lluís Vilanova vilan...@ac.upc.edu
+__copyright__  = Copyright 2012, Lluís Vilanova vilan...@ac.upc.edu
+__license__= GPL version 2 or (at your option) any later version
+
+__maintainer__ = Stefan Hajnoczi
+__email__  = stefa...@linux.vnet.ibm.com
+
+
+from tracetool import out
+
+
+def begin(events):
+out('/* This file is autogenerated by tracetool, do not edit. */',
+'',
+'#include trace.h',
+'#include trace/generated-events.h',
+'#include trace/control.h',
+'',
+)
+
+out('TraceEvent trace_events[TRACE_EVENT_COUNT] = {')
+
+for e in events:
+out('{ .id = %(id)s, .name = \%(name)s\, .sstate = %(sstate)s, 
.dstate = 0 },',
+id = TRACE_ + e.name.upper(),
+name = e.name,
+sstate = TRACE_%s_ENABLED % e.name.upper(),
+)
+
+out('};',
+'',
+)
diff --git a/scripts/tracetool/format/events_h.py 
b/scripts/tracetool/format/events_h.py
new file mode 100644
index 000..d30ccea
--- /dev/null
+++ b/scripts/tracetool/format/events_h.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+Generate .h for event description.
+
+
+__author__ = Lluís Vilanova vilan...@ac.upc.edu
+__copyright__  = Copyright 2012, Lluís Vilanova vilan...@ac.upc.edu
+__license__= GPL version 2 or (at your option) any later version
+
+__maintainer__ = Stefan Hajnoczi
+__email__  = stefa...@linux.vnet.ibm.com
+
+
+from tracetool import out
+
+
+def begin(events):
+out('/* This file is autogenerated by tracetool, do not edit. */',
+'',
+'#ifndef TRACE__GENERATED_EVENTS_H',
+'#define TRACE__GENERATED_EVENTS_H',
+'',
+'#include stdbool.h',
+''
+)
+
+# event identifiers
+out('typedef enum {')
+
+for e in events:
+out('TRACE_%s,' % e.name.upper())
+
+out('TRACE_EVENT_COUNT',
+'} TraceEventID;',
+)
+
+# static state
+for e in events:
+if 'disable' in e.properties:
+enabled = 0
+else:
+enabled = 1
+out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled))
+
+out('#include trace/event-internal.h',
+'',
+'#endif  /* TRACE__GENERATED_EVENTS_H */',
+)
diff --git 

Re: [Qemu-devel] libvirt-QEMU interfaces for CPU models

2013-03-01 Thread Eduardo Habkost
On Fri, Mar 01, 2013 at 02:28:37PM +0100, Jiri Denemark wrote:
 On Thu, Feb 21, 2013 at 11:58:18 -0300, Eduardo Habkost wrote:
  = Querying host capabilities =
  
  Requirement: libvirt needs to know which feature can really be enabled, 
  before
  it tries to start a VM, and before it tries to start a live-migration 
  process.
  
  The set of available capabilities depend on:
  
• Host CPU (hardware) capabilities;
• Kernel capabilities (reported by GET_SUPPORTED_CPUID);
• QEMU capabilities;
• Specific configuration options (e.g. in-kernel IRQ chip is required for
  some features).
 
 Actually, one more thing. Can any of these requirements change while a
 host is up and QEMU is not upgraded? I believe, host CPU capabilities
 can only change when the host starts. Kernel capabilities are a bit less
 clear since I guess they could possibly change when kvm module is
 unloaded and loaded back with a different options. QEMU capabilities
 should only change when different version is installed. And the specific
 configuration options are the most unclear to me. The reason I'm asking
 is whether libvirt could run-time cache CPU definitions (including all
 model details) in the same way we currently cache QEMU capabilities,
 such as availability of specific QMP commands.


That's a good question. Let's check each item so I don't forget any
detail:

• Host CPU (hardware) capabilities;

This shouldn't change without a host reboot.

• Kernel capabilities (reported by GET_SUPPORTED_CPUID);

This may possibly change if the KVM module is unloaded and reloaded with
different options, but... I guess we should simply require libvirtd to
be restarted if any user does that?

• QEMU capabilities;

This shouldn't change as long as the QEMU binary doesn't change.


• Specific configuration options (e.g. in-kernel IRQ chip is required for
  some features).

This part seems tricky. Currently kernel-irqchip is probably the only
option that affects which features are available, but what if other QEMU
options affect the set of features too?

I believe the answer is to rely on machine-types. I mean: if a new
option that affects -cpu host and the set of available CPU features is
created, there are two options:

  1) Using the default value;
  2) Setting the option explicitly.

1) If using the default value, the default will depend on machine-type, so
libvirt should already consider machine-type as an option that affects
available-CPU-features.

2) If using an explicit value, libvirt should use the explicit value only
after being changed to take into account the fact that the option
affects available-CPU-features.

So, let's add one more item to the list. The set of available
capabilities depend on:

  • Host CPU (hardware) capabilities;
  • Kernel capabilities (reported by GET_SUPPORTED_CPUID);
  • QEMU capabilities;
  • Specific configuration options:
• kernel-irqchip (currently affects tsc-deadline and x2apic, but may
  affect other features in the future)
• machine-type (may affect any feature in the future)

-- 
Eduardo



[Qemu-devel] APIC-V and QEMU block IO performance

2013-03-01 Thread Benoît Canet

Hello lists,

As a QEMU developper I am looking for a way to help improving qemu/kvm block
performance for $customer.

Having read about APIC-V on #qemu I looked at the intel manual in order to have
an idea of what is an APIC and what is APIC-V.

Here is a summary that I am posting so it can help people like me with the
acronyms.

Feel free to correct me if I am saying something incorrect or incomplete or just
ignore the post if it's too trivial.

From Intel manual volume 3A chapter 6 interruptions:
--

There are 256 interruptions possible on an x86 system and the first 32 are
reserved.

The IDT (interrupt descriptor table) is indexed by the interruption vector
and it's size can be at most 256.

From Intel manual volume 3A chapter 10 APIC:
--

The local APIC (Advanced Programable Interrupt Controller)'s job is to forward
local interrupts (timer, thermal events) or external interrupts (IO-APIC on the
PCI bus for example) to the CPU.
When the APIC does this the cpu program counter jump to the routine located
at IDT[vector].

When an interrupt routine is ending and EIO (End Of Interrupt) can be written
is a dedicated register of the local APIC to inform it that the interrupt has
been processed.
The local APIC can propagate EIOs automatically.
EIOs can also be sent directly at the I/O APIC located on the PCI bus to avoid
the need of propagation.

The configuration of the local APIC is in most case done on a 4KB region which
address is configurable in the IA32_APIC_BASE register.

An IPI (Inter Processor Interrupt) can be send by a local APIC after a serie of
writes in a single APIC register.

On a modern intel machine IPIs travels on the system bus.

The periferals located on the PCI bus send MSI (Message Signalled Interrupts)
to locals APICs.
These interruptions are done with a write at a specific address.

From Intel Manual volume 3B chapter 29 APIC virtualization


APIC-V allow each VM to have a partially virtualized APIC in order to reduce the
number of vmexits (going back from the vm code to the hypervisor code).
Intel marketing is talking about a reduction by 50% of the vm exits count.
As a consequence of APIC-V IO performance should go up.

A 4KB page looking like the one of a local APIC is available for the guest to
use.

Depending on the specific access type done by the guest in this 4KB page
some vmexit will be triggered in order to emulate the access or the access will
be virtualized without vmexit.

Interrupts can be posted by the hypervisor in a descriptor so the
guest receive the interrupt without a vm exit.This is called Posted Interrupts.

The hardware is not available yet and the posted interrupt code is currently
being written (probably around/after 2.6.10)

Looking for the best way to contribute
--

As it's seems too early to benchmark APIC-V I am looking the the best way
I could take to help improve $customer block IO performance with my current
skill set which is mainly fiddling qemu block drivers.

Best regards

Benoît



[Qemu-devel] [PATCH v11 3/7] trace: Provide a detailed event control interface

2013-03-01 Thread Lluís Vilanova
This interface decouples event obtaining from interaction.

Events can be obtained through three different methods:

* identifier
* name
* simple wildcard pattern

Signed-off-by: Lluís Vilanova vilan...@ac.upc.edu
---
 docs/tracing.txt |   44 ---
 trace/control-internal.h |   67 
 trace/control.c  |  106 +++---
 trace/control.h  |  190 +-
 4 files changed, 349 insertions(+), 58 deletions(-)
 create mode 100644 trace/control-internal.h

diff --git a/docs/tracing.txt b/docs/tracing.txt
index 14db3bf..cf53c17 100644
--- a/docs/tracing.txt
+++ b/docs/tracing.txt
@@ -100,49 +100,37 @@ respectively.  This ensures portability between 32- and 
64-bit platforms.
 
 == Generic interface and monitor commands ==
 
-You can programmatically query and control the dynamic state of trace events
-through a backend-agnostic interface:
+You can programmatically query and control the state of trace events through a
+backend-agnostic interface provided by the header trace/control.h.
 
-* trace_print_events
+Note that some of the backends do not provide an implementation for some parts
+of this interface, in which case QEMU will just print a warning (please refer 
to
+header trace/control.h to see which routines are backend-dependent).
 
-* trace_event_set_state
-  Enables or disables trace events at runtime inside QEMU.
-  The function returns true if the state of the event has been successfully
-  changed, or false otherwise:
-
-#include trace/control.h
-
-trace_event_set_state(virtio_irq, true); /* enable */
-[...]
-trace_event_set_state(virtio_irq, false); /* disable */
-
-Note that some of the backends do not provide an implementation for this
-interface, in which case QEMU will just print a warning.
-
-This functionality is also provided through monitor commands:
+The state of events can also be queried and modified through monitor commands:
 
 * info trace-events
   View available trace events and their state.  State 1 means enabled, state 0
   means disabled.
 
 * trace-event NAME on|off
-  Enable/disable a given trace event or a group of events having common prefix
-  through wildcard.
+  Enable/disable a given trace event or a group of events (using wildcards).
 
 The -trace events=file command line argument can be used to enable the
 events listed in file from the very beginning of the program. This file must
 contain one event name per line.
 
-A basic wildcard matching is supported in both the monitor command trace
--event and the events list file. That means you can enable/disable the events
-having a common prefix in a batch. For example, virtio-blk trace events could
-be enabled using:
-  trace-event virtio_blk_* on
-
 If a line in the -trace events=file file begins with a '-', the trace event
 will be disabled instead of enabled.  This is useful when a wildcard was used
 to enable an entire family of events but one noisy event needs to be disabled.
 
+Wildcard matching is supported in both the monitor command trace-event and 
the
+events list file. That means you can enable/disable the events having a common
+prefix in a batch. For example, virtio-blk trace events could be enabled using
+the following monitor command:
+
+trace-event virtio_blk_* on
+
 == Trace backends ==
 
 The tracetool script automates tedious trace event code generation and also
@@ -263,3 +251,7 @@ guard such computations and avoid its compilation when the 
event is disabled:
 }
 return ptr;
 }
+
+You can check both if the event has been disabled and is dynamically enabled at
+the same time using the 'trace_event_get_state' routine (see header
+trace/control.h for more information).
diff --git a/trace/control-internal.h b/trace/control-internal.h
new file mode 100644
index 000..cce2da4
--- /dev/null
+++ b/trace/control-internal.h
@@ -0,0 +1,67 @@
+/*
+ * Interface for configuring and controlling the state of tracing events.
+ *
+ * Copyright (C) 2011-2012 Lluís Vilanova vilan...@ac.upc.edu
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef TRACE__CONTROL_INTERNAL_H
+#define TRACE__CONTROL_INTERNAL_H
+
+#include string.h
+
+
+extern TraceEvent trace_events[];
+
+
+static inline TraceEvent *trace_event_id(TraceEventID id)
+{
+assert(id  trace_event_count());
+return trace_events[id];
+}
+
+static inline TraceEventID trace_event_count(void)
+{
+return TRACE_EVENT_COUNT;
+}
+
+static inline bool trace_event_is_pattern(const char *str)
+{
+assert(str != NULL);
+return strchr(str, '*') != NULL;
+}
+
+static inline TraceEventID trace_event_get_id(TraceEvent *ev)
+{
+assert(ev != NULL);
+return ev-id;
+}
+
+static inline const char * trace_event_get_name(TraceEvent *ev)
+{
+assert(ev != NULL);
+return ev-name;
+}
+
+static inline bool 

[Qemu-devel] [PATCH v11 4/7] trace: [monitor] Use new event control interface

2013-03-01 Thread Lluís Vilanova
Signed-off-by: Lluís Vilanova vilan...@ac.upc.edu
---
 monitor.c |   13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/monitor.c b/monitor.c
index 32a6e74..e287c06 100644
--- a/monitor.c
+++ b/monitor.c
@@ -740,9 +740,18 @@ static void do_trace_event_set_state(Monitor *mon, const 
QDict *qdict)
 {
 const char *tp_name = qdict_get_str(qdict, name);
 bool new_state = qdict_get_bool(qdict, option);
-int ret = trace_event_set_state(tp_name, new_state);
 
-if (!ret) {
+bool found = false;
+TraceEvent *ev = NULL;
+while ((ev = trace_event_pattern(tp_name, ev)) != NULL) {
+found = true;
+if (!trace_event_get_state_static(ev)) {
+monitor_printf(mon, event \%s\ is not traceable\n, tp_name);
+} else {
+trace_event_set_state_dynamic(ev, new_state);
+}
+}
+if (!trace_event_is_pattern(tp_name)  !found) {
 monitor_printf(mon, unknown event name \%s\\n, tp_name);
 }
 }




[Qemu-devel] [PATCH v11 5/7] trace: [default] Port to generic event information and new control interface

2013-03-01 Thread Lluís Vilanova
Signed-off-by: Lluís Vilanova vilan...@ac.upc.edu
---
 trace/default.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/trace/default.c b/trace/default.c
index c9b27a2..6e07a47 100644
--- a/trace/default.c
+++ b/trace/default.c
@@ -1,7 +1,7 @@
 /*
  * Default implementation for backend initialization from commandline.
  *
- * Copyright (C) 2011 Lluís Vilanova vilan...@ac.upc.edu
+ * Copyright (C) 2011-2012 Lluís Vilanova vilan...@ac.upc.edu
  *
  * This work is licensed under the terms of the GNU GPL, version 2.  See
  * the COPYING file in the top-level directory.
@@ -18,11 +18,10 @@ void trace_print_events(FILE *stream, fprintf_function 
stream_printf)
   operation not supported with the current backend\n);
 }
 
-bool trace_event_set_state(const char *name, bool state)
+void trace_event_set_state_dynamic_backend(TraceEvent *ev, bool state)
 {
 fprintf(stderr, warning: 
 cannot set the state of a trace event with the current 
backend\n);
-return false;
 }
 
 bool trace_backend_init(const char *events, const char *file)




[Qemu-devel] [PATCH v11 7/7] trace: [stderr] Port to generic event information and new control interface

2013-03-01 Thread Lluís Vilanova
Signed-off-by: Lluís Vilanova vilan...@ac.upc.edu
---
 scripts/tracetool/backend/stderr.py |   27 ---
 trace/stderr.c  |   34 ++
 trace/stderr.h  |   11 ---
 3 files changed, 14 insertions(+), 58 deletions(-)
 delete mode 100644 trace/stderr.h

diff --git a/scripts/tracetool/backend/stderr.py 
b/scripts/tracetool/backend/stderr.py
index a10fbb8..6f93dbd 100644
--- a/scripts/tracetool/backend/stderr.py
+++ b/scripts/tracetool/backend/stderr.py
@@ -20,40 +20,29 @@ PUBLIC = True
 
 
 def c(events):
-out('#include trace.h',
-'',
-'TraceEvent trace_list[] = {')
-
-for e in events:
-out('{.tp_name = %(name)s, .state=0},',
-name = e.name,
-)
-
-out('};')
+pass
 
 def h(events):
 out('#include stdio.h',
-'#include trace/stderr.h',
+'#include trace/control.h',
 '',
-'extern TraceEvent trace_list[];')
+)
 
-for num, e in enumerate(events):
+for e in events:
 argnames = , .join(e.args.names())
 if len(e.args)  0:
 argnames = ,  + argnames
 
 out('static inline void trace_%(name)s(%(args)s)',
 '{',
-'if (trace_list[%(event_num)s].state != 0) {',
+'bool _state = trace_event_get_state(%(event_id)s);',
+'if (_state) {',
 'fprintf(stderr, %(name)s  %(fmt)s \\n %(argnames)s);',
 '}',
 '}',
 name = e.name,
 args = e.args,
-event_num = num,
-fmt = e.fmt,
+event_id = TRACE_ + e.name.upper(),
+fmt = e.fmt.rstrip(\n),
 argnames = argnames,
 )
-
-out('',
-'#define NR_TRACE_EVENTS %d' % len(events))
diff --git a/trace/stderr.c b/trace/stderr.c
index 0810d6f..e212efd 100644
--- a/trace/stderr.c
+++ b/trace/stderr.c
@@ -4,40 +4,18 @@
 
 void trace_print_events(FILE *stream, fprintf_function stream_printf)
 {
-unsigned int i;
+TraceEventID i;
 
-for (i = 0; i  NR_TRACE_EVENTS; i++) {
+for (i = 0; i  trace_event_count(); i++) {
+TraceEvent *ev = trace_event_id(i);
 stream_printf(stream, %s [Event ID %u] : state %u\n,
-  trace_list[i].tp_name, i, trace_list[i].state);
+  trace_event_get_name(ev), i, 
trace_event_get_state_dynamic(ev));
 }
 }
 
-bool trace_event_set_state(const char *name, bool state)
+void trace_event_set_state_dynamic_backend(TraceEvent *ev, bool state)
 {
-unsigned int i;
-unsigned int len;
-bool wildcard = false;
-bool matched = false;
-
-len = strlen(name);
-if (len  0  name[len - 1] == '*') {
-wildcard = true;
-len -= 1;
-}
-for (i = 0; i  NR_TRACE_EVENTS; i++) {
-if (wildcard) {
-if (!strncmp(trace_list[i].tp_name, name, len)) {
-trace_list[i].state = state;
-matched = true;
-}
-continue;
-}
-if (!strcmp(trace_list[i].tp_name, name)) {
-trace_list[i].state = state;
-return true;
-}
-}
-return matched;
+ev-dstate = state;
 }
 
 bool trace_backend_init(const char *events, const char *file)
diff --git a/trace/stderr.h b/trace/stderr.h
deleted file mode 100644
index d575b61..000
--- a/trace/stderr.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef TRACE_STDERR_H
-#define TRACE_STDERR_H
-
-typedef uint64_t TraceEventID;
-
-typedef struct {
-const char *tp_name;
-bool state;
-} TraceEvent;
-
-#endif /* ! TRACE_STDERR_H */




[Qemu-devel] [PATCH v11 6/7] trace: [simple] Port to generic event information and new control interface

2013-03-01 Thread Lluís Vilanova
Signed-off-by: Lluís Vilanova vilan...@ac.upc.edu
---
 scripts/tracetool/backend/simple.py |   18 +-
 trace/simple.c  |   32 +---
 trace/simple.h  |6 +-
 3 files changed, 11 insertions(+), 45 deletions(-)

diff --git a/scripts/tracetool/backend/simple.py 
b/scripts/tracetool/backend/simple.py
index ac864f3..37ef599 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -28,17 +28,10 @@ def is_string(arg):
 
 def c(events):
 out('#include trace.h',
+'#include trace/control.h',
 '#include trace/simple.h',
 '',
-'TraceEvent trace_list[] = {')
-
-for e in events:
-out('{.tp_name = %(name)s, .state=0},',
-name = e.name,
-)
-
-out('};',
-'')
+)
 
 for num, event in enumerate(events):
 out('void trace_%(name)s(%(args)s)',
@@ -63,7 +56,9 @@ def c(events):
 
 
 out('',
-'if (!trace_list[%(event_id)s].state) {',
+'TraceEvent *eventp = trace_event_id(%(event_id)s);',
+'bool _state = trace_event_get_state_dynamic(eventp);',
+'if (!_state) {',
 'return;',
 '}',
 '',
@@ -106,6 +101,3 @@ def h(events):
 name = event.name,
 args = event.args,
 )
-out('')
-out('#define NR_TRACE_EVENTS %d' % len(events))
-out('extern TraceEvent trace_list[NR_TRACE_EVENTS];')
diff --git a/trace/simple.c b/trace/simple.c
index 375d98f..5bb905c 100644
--- a/trace/simple.c
+++ b/trace/simple.c
@@ -359,38 +359,16 @@ void trace_print_events(FILE *stream, fprintf_function 
stream_printf)
 {
 unsigned int i;
 
-for (i = 0; i  NR_TRACE_EVENTS; i++) {
+for (i = 0; i  trace_event_count(); i++) {
+TraceEvent *ev = trace_event_id(i);
 stream_printf(stream, %s [Event ID %u] : state %u\n,
-  trace_list[i].tp_name, i, trace_list[i].state);
+  trace_event_get_name(ev), i, 
trace_event_get_state_dynamic(ev));
 }
 }
 
-bool trace_event_set_state(const char *name, bool state)
+void trace_event_set_state_dynamic_backend(TraceEvent *ev, bool state)
 {
-unsigned int i;
-unsigned int len;
-bool wildcard = false;
-bool matched = false;
-
-len = strlen(name);
-if (len  0  name[len - 1] == '*') {
-wildcard = true;
-len -= 1;
-}
-for (i = 0; i  NR_TRACE_EVENTS; i++) {
-if (wildcard) {
-if (!strncmp(trace_list[i].tp_name, name, len)) {
-trace_list[i].state = state;
-matched = true;
-}
-continue;
-}
-if (!strcmp(trace_list[i].tp_name, name)) {
-trace_list[i].state = state;
-return true;
-}
-}
-return matched;
+ev-dstate = state;
 }
 
 /* Helper function to create a thread with signals blocked.  Use glib's
diff --git a/trace/simple.h b/trace/simple.h
index 2ab96a8..5260d9a 100644
--- a/trace/simple.h
+++ b/trace/simple.h
@@ -15,12 +15,8 @@
 #include stdbool.h
 #include stdio.h
 
-typedef uint64_t TraceEventID;
+#include trace/generated-events.h
 
-typedef struct {
-const char *tp_name;
-bool state;
-} TraceEvent;
 
 void st_print_trace_file_status(FILE *stream, fprintf_function stream_printf);
 void st_set_trace_file_enabled(bool enable);




Re: [Qemu-devel] Advice on some configuration parameters

2013-03-01 Thread Fabio Fantoni

Il 01/03/2013 13:45, Paolo Bonzini ha scritto:

Il 12/02/2013 14:05, Fabio Fantoni ha scritto:

I'm making patches to enable some qemu upstream features in xen that are
missing in libxl.
I'm trying to do it just by giving arguments to qemu, and I want them to
be dynamic (e.g. without physical addresses if possible) and concise.

They should use physical addresses, otherwise changing the VM hardware
in trivial ways may cause a waterfall effect and cause Windows to
reactivate.


If I try to set up virt-manager so that it doesn't point to a file, it
uses this configuration:

-device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x5.0x7
-device
ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5

-device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x5.0x1
-device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x5.0x2

This seems to differ from the configuration file, e.g. you have
multifunzion=on only on the first uhci

That doesn't matter.


, besides I can't understand how many physical ports are defined.

There are 6 ports, controlled by either the EHCI for USB 2.0 devices
(the EHCI controls 6 ports) or by one of the three UHCI for USB 1.1
ports (one UHCI has 2 ports).


I tried setting 9 usbredirection
channels in virt-manager but that configuration doesn't change and no
errors are reported, but I doubt that physical ports are being define
dynamically.

QEMU creates hubs automatically I think in that case.


About spice vdagent at the moment I'm using this configuration that
seems to work:
-device virtio-serial -chardev spicevmc,id=vdagent,name=vdagent -device
virtserialport,chardev=vdagent,name=com.redhat.spice.0

But I noticed that virt-manager use this slightly different one:
-chardev pty,id=charserial0 -device
isa-serial,chardev=charserial0,id=serial0 -chardev
spicevmc,id=charchannel0,name=vdagent -device
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0

Are there any problem with the more concise one I'm using?

It is the same.

Paolo




Thanks for reply.
I have another questions:
What exactly does the -usb parameter that seems to be necessary for usb 
passthrough?

I mean usb devices passed through host (with -usbdevice).
Is the number of such passthrough usb devices limiting the number of 
available channel for usb redirection devices?





smime.p7s
Description: Firma crittografica S/MIME


Re: [Qemu-devel] [PATCH] migration: use XBZRLE only after bulk stage

2013-03-01 Thread Eric Blake
On 03/01/2013 07:50 AM, Peter Lieven wrote:

 just a quick test on my desktop:
 
 ~/git/qemu$ x86_64-softmmu/qemu-system-x86_64 -k de -enable-kvm -m 1024
 -drive
 if=virtio,file=iscsi://172.21.200.31/iqn.2001-05.com.equallogic:0-8a0906-16470e107-713001aa6de511e0-001-test/0
 -vnc :1 -boot dc -monitor stdio
 
 using ubuntu 12.04.1 desktop and the example from docs/xbzrle.txt

Thanks.  Reformatting a bit:

 
 a) with the patch

designated with '+'

 b) without the patch

designated with '-'

+ total time: 22185 milliseconds
- total time: 22410 milliseconds

Shaved 0.3 seconds, better than 1%!

+ downtime: 29 milliseconds
- downtime: 21 milliseconds

Not sure why downtime seemed worse, but probably not the end of the world.

+ transferred ram: 706034 kbytes
- transferred ram: 721318 kbytes

Fewer bytes sent - good.

+ remaining ram: 0 kbytes
- remaining ram: 0 kbytes
+ total ram: 1057216 kbytes
- total ram: 1057216 kbytes
+ duplicate: 108556 pages
- duplicate: 105553 pages
+ normal: 175146 pages
- normal: 179589 pages
+ normal bytes: 700584 kbytes
- normal bytes: 718356 kbytes

Fewer normal bytes...

+ cache size: 67108864 bytes
- cache size: 67108864 bytes
+ xbzrle transferred: 3127 kbytes
- xbzrle transferred: 630 kbytes

...and more compressed pages sent - good.

+ xbzrle pages: 117811 pages
- xbzrle pages: 21527 pages
+ xbzrle cache miss: 18750
- xbzrle cache miss: 179589

And very good improvement on the cache miss rate.

+ xbzrle overflow : 0
- xbzrle overflow : 0

Thanks, this proves it's a good patch.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] check-qjson: More thorough testing of UTF-8 in strings

2013-03-01 Thread Markus Armbruster
Blue Swirl blauwir...@gmail.com writes:

 On Thu, Feb 28, 2013 at 7:42 PM, Markus Armbruster arm...@redhat.com wrote:
 Blue Swirl blauwir...@gmail.com writes:

 On Thu, Feb 28, 2013 at 8:14 AM, Markus Armbruster arm...@redhat.com 
 wrote:
[...]
 Looks like the JSON formatter is not just broken (we knew that already),
 it's broken in machine-dependent ways.  Good to know, thanks for
 reporting.

 Obvious ways to get make check pass for you again *now*:

 * Disable check-qjson.  That's too big a hammer for me.

 * Disable test case 2.1.4 with a comment explaining why.

 * Suitable #ifdeffery around the expected value.

 Preferences?

 * Fix JSON formatter :-)

 I want that too, but I'm afraid we can't have it *now* :)

 Disabling 2.1.4 only reveals the next problem:
 GTESTER tests/check-qjson
 GTester: last random seed: R02S6754f3523201dc81bb21de42e2ba843c
 **
 ERROR:/src/qemu/tests/check-qjson.c:777:utf8_string: assertion failed
 (qstring_get_str(str) == json_out): (\\\u8200\200\200\ ==
 \\\u8200\\u\\u\)

 All right, I give up.  I can't fix to_json() tonight (I have maybe 30
 minutes of usable brain left), but I can make it portably wrong.  Please
 try the appended patch.

 GTESTER tests/check-qjson
 GTester: last random seed: R02Scc9b8a0a880770aaee720c8f98cc953d
 **
 ERROR:/src/qemu/tests/check-qjson.c:775:utf8_string: assertion failed
 (qstring_get_str(str) == json_out): (\\\u0400\200\ ==
 \\\u0400\\u\)

Working on a real fix, please be patient.



[Qemu-devel] [Bug 1130769] Re: VirtFS (virtio-9p-pci) error: Parameter 'driver' expects device type

2013-03-01 Thread Tim Comer
Same result:

-fsdev 
local,id=fsdev-fs0,path=/srv/files,security_model=passthrough,writeout=immediate
-device virtio-9p-pci,fsdev=fsdev-fs0,mount_tag=files

qemu-kvm: -device virtio-9p-pci,fsdev=fsdev-fs0,mount_tag=files:
Parameter 'driver' expects device type

Same result with a shortcut argument:
qemu-kvm: -virtfs 
local,id=fsdev-fs0,path=/srv/files,security_model=passthrough,writeout=immediate,mount_tag=files:
 Parameter 'driver' expects device type

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1130769

Title:
  VirtFS (virtio-9p-pci) error: Parameter 'driver' expects device type

Status in QEMU:
  New
Status in “qemu-kvm” package in Gentoo Linux:
  New

Bug description:
  Getting error Parameter 'driver' expects device type when trying to
  share a file system with a guest.

  Command line:
  qemu-kvm
  -m 4096 -cpu host -smp 4,sockets=1
  -net nic,model=virtio,macaddr=00:00:00:00:00:00 -net 
tap,ifname=tap0,script=no,downscript=no
  -rtc base=localtime
  -drive file=/vm/VM.img,cache=none,if=virtio
  -curses
  -boot menu=off
  -fsdev 
fsdriver,id=fsdev-fs0,path=/srv/files,security_model=passthrough,writeout=writeout
  -device virtio-9p-pci,fsdev=fsdev-fs0,mount_tag=files

  OS (host/guest): Gentoo
  Kernel (host/guest): 3.7.5-hardened
  CPU: AMD Opteron(TM) Processor 6272 (host: 16 cores, guest: 4)
  Arch (host/guest): x86_64
  Version: QEMU emulator version 1.2.2 (qemu-kvm-1.2.0), Copyright (c) 
2003-2008 Fabrice Bellard
  Package: app-emulation/qemu-1.2.2-r3

  -no-kvm-irqchip  did not have effect
  -no-kvm-pit   did not have effect other than Warning: KVM PIT can no 
longer be disabled separately.
  -no-kvmdid not work with Could not allocate dynamic translator 
buffer

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1130769/+subscriptions



Re: [Qemu-devel] [PATCH v13 1/8] save/load cpu runstate

2013-03-01 Thread Eric Blake
On 03/01/2013 12:36 AM, Hu Tao wrote:
 On Thu, Feb 28, 2013 at 02:12:37PM -0700, Eric Blake wrote:
 On 02/28/2013 05:13 AM, Hu Tao wrote:
 This patch enables preservation of cpu runstate during save/load vm.
 So when a vm is restored from snapshot, the cpu runstate is restored,
 too.

 What happens if a management app wants to override the runstate when
 restoring the domain?  I can think of several useful scenarios:

 1. management app pauses the guest, then saves domain state and other
 things (management state, or disk clones), then resumes the guest.
 Later, the management wants to revert to the saved state, but have the
 guest running right away.  I guess here, knowing that the guest was
 saved in a paused state doesn't hurt, since the management app can
 resume it right away.

 2. management app saves domain state of a live guest, then copies that
 state elsewhere.  In its new location, the management app wants to
 investigate the state for forensic analysis - so even though the guest
 remembers that it was running, management wants to start it paused.
 Here, it is important that there must not be a window of time where the
 guest can run, otherwise, the results are not reproducible.
 
 -S takes precedence in the case. But for in-migration, runstate is
 loaded from src.

Given your answer, I think we're okay from the libvirt perspective.  My
biggest worry about a window where the guest runs unchecked is not a
problem, given that libvirt always uses -S on incoming migration.  In
turn, libvirt has its own mechanisms for tracking whether the outgoing
migration was started from a running state, along with API overrides to
let a user override whether libvirt will resume the guest on the
incoming migration side.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v13 5/8] add a new qevent: QEVENT_GUEST_PANICKED

2013-03-01 Thread Eric Blake
On 02/28/2013 05:13 AM, Hu Tao wrote:
 This event will be emited when the guest is panicked.
 
 Signed-off-by: Wen Congyang we...@cn.fujitsu.com
 ---
  include/monitor/monitor.h | 1 +
  monitor.c | 1 +
  2 files changed, 2 insertions(+)

Missing documentation in QMP/qmp-events.txt

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] pci vga: Support VGA behind bridges

2013-03-01 Thread Alex Williamson
On Thu, 2013-02-28 at 23:03 -0500, Kevin O'Connor wrote:
 On Thu, Feb 28, 2013 at 10:52:49AM -0700, Alex Williamson wrote:
  We currently expect to find VGA devices on the root bus but we will
  also support them below bridges iff the VGA routing across the bridges
  is pre-configured.  This patch maintains that behavior, but also
  enables SeaBIOS to enable VGA routing to the first VGA class device it
  finds when there is no preconfigured device.  This allows us to
  support VGA devices behind root ports and bridges without special
  setup from QEMU.
 [...]
  --- a/src/optionroms.c
  +++ b/src/optionroms.c
  @@ -439,13 +439,47 @@ vgarom_setup(void)
 
 I don't think that optionroms.c is the right place for this logic.  On
 coreboot, Xen, and CSM, SeaBIOS shouldn't be touching the PCI config.
 It's only QEMU that would need this logic, so something like pciinit.c
 is where this logic should go.

Ok, I can look at finding a spot for it in pciinit.  Note though that
there's nothing QEMU specific about this, if other platforms are already
enabling a route to a VGA device, there's no change.  If something
sneaks through without a VGA device enabled, this should generically
enable the first device.  Thanks,

Alex




[Qemu-devel] [PATCH v3] pci: Teach PCI Bridges about VGA routing

2013-03-01 Thread Alex Williamson
Each PCI Bridge has a set of implied VGA regions that are enabled when
the VGA bit is set in the bridge control register.  This allows VGA
devices behind bridges.  Unfortunately with VGA Enable, which we
formerly allowed but didn't back, comes along some required VGA
baggage.  VGA Palette Snooping is required, along with VGA 16-bit
decoding.  We don't yet have support for palette snooping, but we do
make the bit writable on bridges.  We also don't have support for
10-bit VGA aliases, the default mode, but we enable the register, even
on root ports, to avoid confusing guests.  Fortunately there's likely
nothing from this century that requires these features, so the missing
bits are noted with TODOs.

Signed-off-by: Alex Williamson alex.william...@redhat.com
---
v2: BRIDGE_CONTROL is 2 bytes
v3: Add missing comments and bits around VGA Palette Snooping and aliases

 hw/pci/pci.c|4 
 hw/pci/pci_bridge.c |   56 +--
 hw/pci/pci_bus.h|   15 ++
 hw/pci/pcie_port.c  |2 ++
 4 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 2f45c8f..2ea831d 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -674,6 +674,10 @@ static void pci_init_mask_bridge(PCIDevice *d)
 #define  PCI_BRIDGE_CTL_SEC_DISCARD0x200   /* Secondary discard timer */
 #define  PCI_BRIDGE_CTL_DISCARD_STATUS 0x400   /* Discard timer status */
 #define  PCI_BRIDGE_CTL_DISCARD_SERR   0x800   /* Discard timer SERR# enable */
+/*
+ * TODO: Bridges default to 10-bit VGA decoding but we currently only
+ * implement 16-bit decoding (no alias support).
+ */
 pci_set_word(d-wmask + PCI_BRIDGE_CONTROL,
  PCI_BRIDGE_CTL_PARITY |
  PCI_BRIDGE_CTL_SERR |
diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
index 995842a..5f9d686 100644
--- a/hw/pci/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -151,6 +151,37 @@ static void pci_bridge_init_alias(PCIBridge *bridge, 
MemoryRegion *alias,
 memory_region_add_subregion_overlap(parent_space, base, alias, 1);
 }
 
+static void pci_bridge_init_vga_aliases(PCIBridge *br, PCIBus *parent,
+PCIBridgeVgaWindows *vga)
+{
+uint16_t cmd = pci_get_word(br-dev.config + PCI_COMMAND);
+uint16_t brctl = pci_get_word(br-dev.config + PCI_BRIDGE_CONTROL);
+
+memory_region_init_alias(vga-alias_io_lo, pci_bridge_vga_io_lo,
+ br-address_space_io, 0x3b0, 0xc);
+memory_region_add_subregion_overlap(parent-address_space_io, 0x3b0,
+vga-alias_io_lo, 1);
+
+memory_region_init_alias(vga-alias_io_hi, pci_bridge_vga_io_hi,
+ br-address_space_io, 0x3c0, 0x20);
+memory_region_add_subregion_overlap(parent-address_space_io, 0x3c0,
+vga-alias_io_hi, 1);
+
+if (!(cmd  PCI_COMMAND_IO) || !(brctl  PCI_BRIDGE_CTL_VGA)) {
+memory_region_set_enabled(vga-alias_io_lo, false);
+memory_region_set_enabled(vga-alias_io_hi, false);
+}
+
+memory_region_init_alias(vga-alias_mem, pci_bridge_vga_mem,
+ br-address_space_mem, 0xa, 0x2);
+memory_region_add_subregion_overlap(parent-address_space_mem, 0xa,
+vga-alias_mem, 1);
+
+if (!(cmd  PCI_COMMAND_MEMORY) || !(brctl  PCI_BRIDGE_CTL_VGA)) {
+memory_region_set_enabled(vga-alias_mem, false);
+}
+}
+
 static PCIBridgeWindows *pci_bridge_region_init(PCIBridge *br)
 {
 PCIBus *parent = br-dev.bus;
@@ -175,7 +206,8 @@ static PCIBridgeWindows *pci_bridge_region_init(PCIBridge 
*br)
   br-address_space_io,
   parent-address_space_io,
   cmd  PCI_COMMAND_IO);
-   /* TODO: optinal VGA and VGA palette snooping support. */
+
+pci_bridge_init_vga_aliases(br, parent, w-vga);
 
 return w;
 }
@@ -187,6 +219,9 @@ static void pci_bridge_region_del(PCIBridge *br, 
PCIBridgeWindows *w)
 memory_region_del_subregion(parent-address_space_io, w-alias_io);
 memory_region_del_subregion(parent-address_space_mem, w-alias_mem);
 memory_region_del_subregion(parent-address_space_mem, w-alias_pref_mem);
+memory_region_del_subregion(parent-address_space_io, w-vga.alias_io_lo);
+memory_region_del_subregion(parent-address_space_io, w-vga.alias_io_hi);
+memory_region_del_subregion(parent-address_space_mem, w-vga.alias_mem);
 }
 
 static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)
@@ -194,6 +229,9 @@ static void pci_bridge_region_cleanup(PCIBridge *br, 
PCIBridgeWindows *w)
 memory_region_destroy(w-alias_io);
 memory_region_destroy(w-alias_mem);
 memory_region_destroy(w-alias_pref_mem);
+memory_region_destroy(w-vga.alias_io_lo);
+memory_region_destroy(w-vga.alias_io_hi);
+memory_region_destroy(w-vga.alias_mem);
 

[Qemu-devel] [PATCH] pci_host: Drop write-only address_space field

2013-03-01 Thread Peter Maydell
The address_space field of PCIHostState was only ever written, never used.
Drop it completely.

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
Noticed this when looking at converting versatile_pci to be a subclass
of pci_host; it's nice to be able to drop the ugly fishing around in
the object struct that the two users here were doing...

 hw/pci/pci_host.h |1 -
 hw/piix_pci.c |1 -
 hw/ppc/prep.c |1 -
 3 files changed, 3 deletions(-)

diff --git a/hw/pci/pci_host.h b/hw/pci/pci_host.h
index 1845d4d..236cd0f 100644
--- a/hw/pci/pci_host.h
+++ b/hw/pci/pci_host.h
@@ -40,7 +40,6 @@ struct PCIHostState {
 MemoryRegion conf_mem;
 MemoryRegion data_mem;
 MemoryRegion mmcfg;
-MemoryRegion *address_space;
 uint32_t config_reg;
 PCIBus *bus;
 };
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 6c77e49..9246983 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -244,7 +244,6 @@ static PCIBus *i440fx_common_init(const char *device_name,
 
 dev = qdev_create(NULL, i440FX-pcihost);
 s = PCI_HOST_BRIDGE(dev);
-s-address_space = address_space_mem;
 b = pci_bus_new(dev, NULL, pci_address_space,
 address_space_io, 0);
 s-bus = b;
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index e06dded..2920911 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -567,7 +567,6 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
 
 dev = qdev_create(NULL, raven-pcihost);
 pcihost = PCI_HOST_BRIDGE(dev);
-pcihost-address_space = get_system_memory();
 object_property_add_child(qdev_get_machine(), raven, OBJECT(dev), NULL);
 qdev_init_nofail(dev);
 pci_bus = (PCIBus *)qdev_get_child_bus(dev, pci.0);
-- 
1.7.9.5




Re: [Qemu-devel] [PATCH 1/2] qga: add guest-get-time command

2013-03-01 Thread Eric Blake
On 03/01/2013 02:32 AM, Lei Li wrote:
 Signed-off-by: Lei Li li...@linux.vnet.ibm.com
 ---
  qga/commands-posix.c | 16 
  qga/qapi-schema.json | 16 
  2 files changed, 32 insertions(+)
 
 diff --git a/qga/commands-posix.c b/qga/commands-posix.c
 index 0ad73f3..f159e25 100644
 --- a/qga/commands-posix.c
 +++ b/qga/commands-posix.c
 @@ -119,6 +119,22 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, 
 Error **err)
  /* succeded */
  }
  
 +int64_t qmp_guest_get_time(Error **errp)
 +{
 +   int ret;
 +   qemu_timeval tq;
 +   int64_t time_ns;
 +
 +   ret = qemu_gettimeofday(tq);
 +   if (ret  0) {
 +   error_setg_errno(errp, errno, Failed to get time);
 +   return -1;
 +   }
 +
 +   time_ns = tq.tv_sec * 10LL + tq.tv_usec * 1000;

Is it worth a sanity check that the tv_sec scaling doesn't overflow?  Of
course, that won't happen until far into the future (well beyond the
2038 overflow of 32-bit seconds since Epoch), so it won't hit in OUR
lifetime, so I can look the other way.

  
  ##
 +# @guest-get-time:
 +#
 +# Get the information about guest time relative to the Epoch
 +# of 1970-01-01 in UTC/GMT.

UTC and GMT are not the same thing.  I'd drop the '/GMT'.
http://www.diffen.com/difference/GMT_vs_UTC

 +#
 +# This command try to get the guest's notion of the current
 +# time.

This sentence is redundant with the first one, and has grammar issues.
Drop it.

 +#
 +# Returns: Time in nanoseconds on success.
 +#
 +# Since 1.5
 +##
 +{ 'command': 'guest-get-time',
 +  'returns': 'int' }
 +
 +##
  # @GuestAgentCommandInfo:
  #
  # Information about guest agent commands.
 

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH v2] exec: make -mem-path filenames deterministic

2013-03-01 Thread peter
From: Peter Feiner pe...@gridcentric.ca

Adds ramblocks' names to their backing files when using -mem-path.  Eases
introspection and debugging.

Signed-off-by: Peter Feiner pe...@gridcentric.ca
---

On Tue, Jan 8, 2013 at 2:04 PM, Anthony Liguori aligu...@us.ibm.com wrote:

 Yes, please submit the oneliner.

Here it is :)

The commit should probably be called exec: add ramblocks' names to -mem-path
files since the paths aren't deterministic.

v1 - v2: Just add ramblock name to mkstemp template. 

Thanks,
Peter

 exec.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/exec.c b/exec.c
index a41bcb8..16a5452 100644
--- a/exec.c
+++ b/exec.c
@@ -865,7 +865,8 @@ static void *file_ram_alloc(RAMBlock *block,
 return NULL;
 }
 
-filename = g_strdup_printf(%s/qemu_back_mem.XX, path);
+filename = g_strdup_printf(%s/qemu_back_mem.%s.XX, path,
+   block-mr-name);
 
 fd = mkstemp(filename);
 if (fd  0) {
-- 
1.7.10.4




[Qemu-devel] [PATCH 3/4] target-arm: Fix VFP register byte order in GDB remote

2013-03-01 Thread Fabien Chouteau
From GDB Remote Serial Protocol doc:

The bytes with the register are transmitted in target byte order.

Signed-off-by: Fabien Chouteau chout...@adacore.com
---
 target-arm/helper.c |   13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/target-arm/helper.c b/target-arm/helper.c
index e97e1a5..75ee0dc 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -16,18 +16,17 @@ static int vfp_gdb_get_reg(CPUARMState *env, uint8_t *buf, 
int reg)
 {
 int nregs;
 
-/* VFP data registers are always little-endian.  */
 nregs = arm_feature(env, ARM_FEATURE_VFP3) ? 32 : 16;
 if (reg  nregs) {
-stfq_le_p(buf, env-vfp.regs[reg]);
+stfq_p(buf, env-vfp.regs[reg]);
 return 8;
 }
 if (arm_feature(env, ARM_FEATURE_NEON)) {
 /* Aliases for Q regs.  */
 nregs += 16;
 if (reg  nregs) {
-stfq_le_p(buf, env-vfp.regs[(reg - 32) * 2]);
-stfq_le_p(buf + 8, env-vfp.regs[(reg - 32) * 2 + 1]);
+stfq_p(buf, env-vfp.regs[(reg - 32) * 2]);
+stfq_p(buf + 8, env-vfp.regs[(reg - 32) * 2 + 1]);
 return 16;
 }
 }
@@ -45,14 +44,14 @@ static int vfp_gdb_set_reg(CPUARMState *env, uint8_t *buf, 
int reg)
 
 nregs = arm_feature(env, ARM_FEATURE_VFP3) ? 32 : 16;
 if (reg  nregs) {
-env-vfp.regs[reg] = ldfq_le_p(buf);
+env-vfp.regs[reg] = ldfq_p(buf);
 return 8;
 }
 if (arm_feature(env, ARM_FEATURE_NEON)) {
 nregs += 16;
 if (reg  nregs) {
-env-vfp.regs[(reg - 32) * 2] = ldfq_le_p(buf);
-env-vfp.regs[(reg - 32) * 2 + 1] = ldfq_le_p(buf + 8);
+env-vfp.regs[(reg - 32) * 2] = ldfq_p(buf);
+env-vfp.regs[(reg - 32) * 2 + 1] = ldfq_p(buf + 8);
 return 16;
 }
 }
-- 
1.7.9.5




[Qemu-devel] [PATCH 2/4] Add default config for armeb-softmmu

2013-03-01 Thread Fabien Chouteau
Just create one that includes arm-softmmu.mak.

Signed-off-by: Fabien Chouteau chout...@adacore.com
---
 default-configs/armeb-softmmu.mak |3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 default-configs/armeb-softmmu.mak

diff --git a/default-configs/armeb-softmmu.mak 
b/default-configs/armeb-softmmu.mak
new file mode 100644
index 000..17670c0
--- /dev/null
+++ b/default-configs/armeb-softmmu.mak
@@ -0,0 +1,3 @@
+# Default configuration for armeb-softmmu
+
+include arm-softmmu.mak
-- 
1.7.9.5




[Qemu-devel] [PATCH 1/4] QAPI: Add ARMEB target-type

2013-03-01 Thread Fabien Chouteau

Signed-off-by: Fabien Chouteau chout...@adacore.com
---
 qapi-schema.json |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 28b070f..0615715 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2993,10 +2993,11 @@
 # Since: 1.2.0
 ##
 { 'enum': 'TargetType',
-  'data': [ 'alpha', 'arm', 'cris', 'i386', 'lm32', 'm68k', 'microblazeel',
-'microblaze', 'mips64el', 'mips64', 'mipsel', 'mips', 'or32',
-'ppc64', 'ppcemb', 'ppc', 's390x', 'sh4eb', 'sh4', 'sparc64',
-'sparc', 'unicore32', 'x86_64', 'xtensaeb', 'xtensa' ] }
+  'data': [ 'alpha', 'arm', 'armeb','cris', 'i386', 'lm32', 'm68k',
+'microblazeel', 'microblaze', 'mips64el', 'mips64', 'mipsel',
+'mips', 'or32', 'ppc64', 'ppcemb', 'ppc', 's390x', 'sh4eb',
+'sh4', 'sparc64', 'sparc', 'unicore32', 'x86_64', 'xtensaeb',
+'xtensa' ] }
 
 ##
 # @TargetInfo:
-- 
1.7.9.5




[Qemu-devel] [PATCH 4/4] target-arm: always set endian bits in big-endian mode

2013-03-01 Thread Fabien Chouteau
CPSR.E, SCTLR.EE and SCTLR.IE

Signed-off-by: Fabien Chouteau chout...@adacore.com
---
 target-arm/cpu.c|   11 +++
 target-arm/helper.c |   18 ++
 2 files changed, 29 insertions(+)

diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index 5dfcb74..354843e 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -112,6 +112,17 @@ static void arm_cpu_reset(CPUState *s)
 }
 env-vfp.xregs[ARM_VFP_FPEXC] = 0;
 #endif
+
+#ifdef TARGET_WORDS_BIGENDIAN
+if (arm_feature(env, ARM_FEATURE_V6) || arm_feature(env, ARM_FEATURE_V7)) {
+/* Set IE and EE bits for big-endian */
+env-cp15.c1_sys |= (1  31) | (1  25);
+
+/* Set E bit for big-endian */
+env-uncached_cpsr |= CPSR_E;
+}
+#endif
+
 set_flush_to_zero(1, env-vfp.standard_fp_status);
 set_flush_inputs_to_zero(1, env-vfp.standard_fp_status);
 set_default_nan_mode(1, env-vfp.standard_fp_status);
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 75ee0dc..e539186 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -1017,6 +1017,15 @@ static const ARMCPRegInfo lpae_cp_reginfo[] = {
 static int sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t 
value)
 {
 env-cp15.c1_sys = value;
+
+#ifdef TARGET_WORDS_BIGENDIAN
+if (arm_feature(env, ARM_FEATURE_V6)
+|| arm_feature(env, ARM_FEATURE_V7)) {
+/* IE and EE bits stay set for big-endian */
+env-cp15.c1_sys |= (1  31) | (1  25);
+}
+#endif
+
 /* ??? Lots of these bits are not implemented.  */
 /* This may enable/disable the MMU, so do a TLB flush.  */
 tlb_flush(env, 1);
@@ -1509,6 +1518,15 @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t 
mask)
 }
 mask = ~CACHED_CPSR_BITS;
 env-uncached_cpsr = (env-uncached_cpsr  ~mask) | (val  mask);
+
+#ifdef TARGET_WORDS_BIGENDIAN
+if (arm_feature(env, ARM_FEATURE_V6)
+|| arm_feature(env, ARM_FEATURE_V7)) {
+/* E bit stays set for big-endian */
+env-uncached_cpsr |= CPSR_E;
+}
+#endif
+
 }
 
 /* Sign/zero extend */
-- 
1.7.9.5




[Qemu-devel] [PATCH 0/4] ARM: Misc ARM big-endian bug fixes

2013-03-01 Thread Fabien Chouteau

Fabien Chouteau (4):
  QAPI: Add ARMEB target-type
  Add default config for armeb-softmmu
  target-arm: Fix VFP register byte order in GDB remote
  target-arm: always set endian bits in big-endian mode

 default-configs/armeb-softmmu.mak |3 +++
 qapi-schema.json  |9 +
 target-arm/cpu.c  |   11 +++
 target-arm/helper.c   |   31 ---
 4 files changed, 43 insertions(+), 11 deletions(-)
 create mode 100644 default-configs/armeb-softmmu.mak

-- 
1.7.9.5




Re: [Qemu-devel] [PATCH 2/2] qga: add guest-set-time command

2013-03-01 Thread Eric Blake
On 03/01/2013 02:33 AM, Lei Li wrote:
 Signed-off-by: Lei Li li...@linux.vnet.ibm.com
 ---
  qga/commands-posix.c | 55 
 
  qga/qapi-schema.json | 27 ++
  2 files changed, 82 insertions(+)
 
 diff --git a/qga/commands-posix.c b/qga/commands-posix.c
 index f159e25..e246a0d 100644
 --- a/qga/commands-posix.c
 +++ b/qga/commands-posix.c
 @@ -135,6 +135,61 @@ int64_t qmp_guest_get_time(Error **errp)
 return time_ns; 
  }
  
 +void qmp_guest_set_time(int64_t time_ns, Error **errp)
 +{
 +int ret;
 +int status;
 +pid_t pid;
 +Error *local_err = NULL;
 +struct timeval tv;
 +
 +/* year-2038 will overflow in case time_t is 32bit */
 +if ((sizeof(time_t) = 4)  ((unsigned long) time_ns  (1ul  31))) {

Wrong.  If 'unsigned long' and 'time_t' are both 32 bits, but time_ns is
0x1000, then the cast truncates to 0 and you don't report
overflow.  Conversely, if time_ns is 0x8000, you report overflow,
even though this value fits in 32-bit time_t after you do division from
nanoseconds back to seconds.  What you WANT is:

if (time_ns / 10 != (time_t)(time_ns / 10)) {

 +error_setg_errno(errp, errno, Invalid time %ld for overflow,
 + time_ns);

That wording sounds awkward.  Worse, errno is NOT set to anything sane,
so you do NOT want error_setg_errno.  And %ld is wrong for int64_t on
32-bit platforms.  How about:

error_setg(errp, Time % PRI64D  is too large, time_ns);

 +++ b/qga/qapi-schema.json
 @@ -99,6 +99,33 @@
'returns': 'int' }
  
  ##
 +# @guest-set-time:
 +#
 +# Set guest time.
 +#
 +# Right now, when a guest is paused or migrated to a file

s/Right now, when/When/

 +# then loaded from that file, the guest OS has no idea that
 +# there was a big gap in the time. Depending on how long
 +# the gap was, NTP might not be able to resynchronize the
 +# guest.
 +#
 +# This command tries to set guest time based on the information
 +# from host or an absolute value given by management app, and
 +# set the Hardware Clock to the current System Time. This
 +# will make it easier for a guest to resynchronize without
 +# waiting for NTP.
 +#
 +# @time: time of nanoseconds, relative to the Epoch of
 +#1970-01-01 in UTC/GMT.

drop '/GMT'

 +#
 +# Returns: Nothing on success.
 +#
 +# Since: 1.5
 +##
 +{ 'command': 'guest-set-time',
 +  'data': { 'time': 'int' } }
 +
 +##
  # @GuestAgentCommandInfo:
  #
  # Information about guest agent commands.
 

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [Bug 1130769] Re: VirtFS (virtio-9p-pci) error: Parameter 'driver' expects device type

2013-03-01 Thread Markus Armbruster
Tim Comer co...@safetymail.info writes:

 Same result:

 -fsdev
 local,id=fsdev-fs0,path=/srv/files,security_model=passthrough,writeout=immediate
 -device virtio-9p-pci,fsdev=fsdev-fs0,mount_tag=files

 qemu-kvm: -device virtio-9p-pci,fsdev=fsdev-fs0,mount_tag=files:
 Parameter 'driver' expects device type

Please try

$ upstream-qemu -device help 21 | grep virtio-9p

and report back.

[...]



[Qemu-devel] [PATCH] qemu-ga: use key-value store to avoid recycling fd handles after restart

2013-03-01 Thread Michael Roth
Hosts hold on to handles provided by guest-file-open for periods that can
span beyond the life of the qemu-ga process that issued them. Since these
are issued starting from 0 on every restart, we run the risk of issuing
duplicate handles after restarts/reboots.

As a result, users with a stale copy of these handles may end up
reading/writing corrupted data due to their existing handles effectively
being re-assigned to an unexpected file or offset.

We unfortunately do not issue handles as strings, but as integers, so a
solution such as using UUIDs can't be implemented without introducing a
new interface.

As a workaround, we fix this by implementing a persistent key-value store
that will be used to track the value of the last handle that was issued
across restarts/reboots to avoid issuing duplicates.

The store is automatically written to the same directory we currently
set via --statedir to track fsfreeze state, and so should be applicable
for stable releases where this flag is supported.

A follow-up can use this same store for handling fsfreeze state, but
that change is cosmetic and left out for now.

Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com
Cc: qemu-sta...@nongnu.org
---
 qga/commands-posix.c   |   25 +--
 qga/guest-agent-core.h |1 +
 qga/main.c |  184 
 3 files changed, 204 insertions(+), 6 deletions(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 7a0202e..5d12716 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -129,14 +129,22 @@ static struct {
 QTAILQ_HEAD(, GuestFileHandle) filehandles;
 } guest_file_state;
 
-static void guest_file_handle_add(FILE *fh)
+static uint64_t guest_file_handle_add(FILE *fh, Error **errp)
 {
 GuestFileHandle *gfh;
+uint64_t handle;
+
+handle = ga_get_fd_handle(ga_state, errp);
+if (error_is_set(errp)) {
+return 0;
+}
 
 gfh = g_malloc0(sizeof(GuestFileHandle));
-gfh-id = fileno(fh);
+gfh-id = handle;
 gfh-fh = fh;
 QTAILQ_INSERT_TAIL(guest_file_state.filehandles, gfh, next);
+
+return handle;
 }
 
 static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
@@ -158,7 +166,7 @@ int64_t qmp_guest_file_open(const char *path, bool 
has_mode, const char *mode, E
 {
 FILE *fh;
 int fd;
-int64_t ret = -1;
+int64_t ret = -1, handle;
 
 if (!has_mode) {
 mode = r;
@@ -184,9 +192,14 @@ int64_t qmp_guest_file_open(const char *path, bool 
has_mode, const char *mode, E
 return -1;
 }
 
-guest_file_handle_add(fh);
-slog(guest-file-open, handle: %d, fd);
-return fd;
+handle = guest_file_handle_add(fh, err);
+if (error_is_set(err)) {
+fclose(fh);
+return -1;
+}
+
+slog(guest-file-open, handle: %d, handle);
+return handle;
 }
 
 void qmp_guest_file_close(int64_t handle, Error **err)
diff --git a/qga/guest-agent-core.h b/qga/guest-agent-core.h
index 3354598..624a559 100644
--- a/qga/guest-agent-core.h
+++ b/qga/guest-agent-core.h
@@ -35,6 +35,7 @@ bool ga_is_frozen(GAState *s);
 void ga_set_frozen(GAState *s);
 void ga_unset_frozen(GAState *s);
 const char *ga_fsfreeze_hook(GAState *s);
+int64_t ga_get_fd_handle(GAState *s, Error **errp);
 
 #ifndef _WIN32
 void reopen_fd_to_null(int fd);
diff --git a/qga/main.c b/qga/main.c
index db281a5..3635430 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -15,6 +15,7 @@
 #include stdbool.h
 #include glib.h
 #include getopt.h
+#include glib/gstdio.h
 #ifndef _WIN32
 #include syslog.h
 #include sys/wait.h
@@ -30,6 +31,7 @@
 #include qapi/qmp/qerror.h
 #include qapi/qmp/dispatch.h
 #include qga/channel.h
+#include qemu/bswap.h
 #ifdef _WIN32
 #include qga/service-win32.h
 #include windows.h
@@ -53,6 +55,11 @@
 #endif
 #define QGA_SENTINEL_BYTE 0xFF
 
+typedef struct GAPersistentState {
+#define QGA_PSTATE_DEFAULT_FD_COUNTER 1000
+int64_t fd_counter;
+} GAPersistentState;
+
 struct GAState {
 JSONMessageParser parser;
 GMainLoop *main_loop;
@@ -76,6 +83,8 @@ struct GAState {
 #ifdef CONFIG_FSFREEZE
 const char *fsfreeze_hook;
 #endif
+const gchar *pstate_filepath;
+GAPersistentState pstate;
 };
 
 struct GAState *ga_state;
@@ -724,6 +733,171 @@ VOID WINAPI service_main(DWORD argc, TCHAR *argv[])
 }
 #endif
 
+static void set_persistent_state_defaults(GAPersistentState *pstate)
+{
+g_assert(pstate);
+pstate-fd_counter = QGA_PSTATE_DEFAULT_FD_COUNTER;
+}
+
+static void persistent_state_from_keyfile(GAPersistentState *pstate,
+  GKeyFile *keyfile)
+{
+g_assert(pstate);
+g_assert(keyfile);
+/* if any fields are missing, either because the file was tampered with
+ * by agents of chaos, or because the field wasn't present at the time the
+ * file was created, the best we can ever do is start over with the default
+ * values. so load them now, and ignore any errors in accessing key-value
+ * pairs
+ 

  1   2   >