Skip to contentSkip to conversation

Queue/ui patches

GIT PULL Applied Gerd Hoffmann 5 participants 12 messages Jun 21, 2017 – Jul 23, 2017

lore
Share & tools
lore
#0 lore raw

The following changes since commit 8dfaf23ae1f2273a9730a9b309cc8471269bb524:

tcg/tci: fix tcg-interpreter build (2017-06-20 18:39:15 +0100)

are available in the git repository at:

git://git.kraxel.org/qemu tags/queue/ui-pull-request

for you to fetch changes up to 95e92000c8b1e81fce6a7f54ef22656a94793096:

ui: Remove inclusion of "hw/qdev.h" (2017-06-21 14:26:15 +0200)

----------------------------------------------------------------

----------------------------------------------------------------

Gerd Hoffmann (5):
egl-helpers: add helpers to handle opengl framebuffers
egl-headless: use framebuffer helper functions.
sdl2: use framebuffer helper functions.
gtk: use framebuffer helper functions.
console: remove do_safe_dpy_refresh

Thomas Huth (1):
ui: Remove inclusion of "hw/qdev.h"

 include/ui/egl-helpers.h | 15 ++++++++++
 include/ui/gtk.h         |  4 +--
 include/ui/sdl2.h        |  8 +++--
 ui/console.c             | 25 +---------------
 ui/egl-headless.c        | 67 +++++++++++-------------------------------
 ui/egl-helpers.c         | 76 ++++++++++++++++++++++++++++++++++++++++++++++++
 ui/gtk-egl.c             | 36 +++++------------------
 ui/gtk-gl-area.c         | 26 +++++------------
 ui/input.c               |  1 -
 ui/sdl2-gl.c             | 36 +++++------------------
 ui/vnc.c                 |  1 -
 11 files changed, 138 insertions(+), 157 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

[Qemu-devel] [PULL 6/6] ui: Remove inclusion of "hw/qdev.h"

From: Thomas Huth <[email protected]>

Looks like #include "hw/qdev.h" is not needed here, so remove it.

Message-id: [email protected]

---
 ui/input.c | 1 -
 ui/vnc.c   | 1 -
 2 files changed, 2 deletions(-)
ui/input.c +0 -1
index 290ca9f54d..2abd46de93 100644
@@ -1,5 +1,4 @@
 #include "qemu/osdep.h"
-#include "hw/qdev.h"
 #include "sysemu/sysemu.h"
 #include "qapi-types.h"
 #include "qemu/error-report.h"
ui/vnc.c +0 -1
index 47b49c7318..26136f5d29 100644
@@ -28,7 +28,6 @@
 #include "vnc.h"
 #include "vnc-jobs.h"
 #include "trace.h"
-#include "hw/qdev.h"
 #include "sysemu/sysemu.h"
 #include "qemu/error-report.h"
 #include "qemu/sockets.h"
Signature · 1 line
2.9.3
#2 lore raw

[Qemu-devel] [PULL 1/6] egl-helpers: add helpers to handle opengl framebuffers

In reply to Gerd Hoffmann

Add a collection of egl_fb_*() helper functions to manage and use opengl framebuffers, which is a common pattern in UI code with opengl support.

Message-id: [email protected]

---
 include/ui/egl-helpers.h | 15 ++++++++++
 ui/egl-helpers.c         | 76 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+)
include/ui/egl-helpers.h +15 -0
index c785d60e91..be8908737c 100644
@@ -8,6 +8,21 @@
 extern EGLDisplay *qemu_egl_display;
 extern EGLConfig qemu_egl_config;
 
+typedef struct egl_fb {
+    int width;
+    int height;
+    GLuint texture;
+    GLuint framebuffer;
+    bool delete_texture;
+} egl_fb;
+
+void egl_fb_destroy(egl_fb *fb);
+void egl_fb_setup_default(egl_fb *fb, int width, int height);
+void egl_fb_create_for_tex(egl_fb *fb, int width, int height, GLuint texture);
+void egl_fb_create_new_tex(egl_fb *fb, int width, int height);
+void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip);
+void egl_fb_read(void *dst, egl_fb *src);
+
 #ifdef CONFIG_OPENGL_DMABUF
 
 extern int qemu_egl_rn_fd;
ui/egl-helpers.c +76 -0

82 lines not on this page · raw message

Signature · 1 line
2.9.3
#3 lore raw

[Qemu-devel] [PULL 4/6] gtk: use framebuffer helper functions.

In reply to Gerd Hoffmann

Message-id: [email protected]

---
 include/ui/gtk.h |  4 ++--
 ui/gtk-egl.c     | 36 +++++++-----------------------------
 ui/gtk-gl-area.c | 26 +++++++-------------------
 3 files changed, 16 insertions(+), 50 deletions(-)
include/ui/gtk.h +2 -2
index ca9a2268de..2f7b720358 100644
@@ -52,8 +52,8 @@ typedef struct VirtualGfxConsole {
     EGLSurface esurface;
     int glupdates;
     int x, y, w, h;
-    GLuint tex_id;
-    GLuint fbo_id;
+    egl_fb guest_fb;
+    egl_fb win_fb;
     bool y0_top;
     bool scanout_mode;
 #endif
ui/gtk-egl.c +7 -29
index cf48cca259..0d5cab2bc8 100644
@@ -30,14 +30,7 @@ static void gtk_egl_set_scanout_mode(VirtualConsole *vc, bool scanout)
 
     vc->gfx.scanout_mode = scanout;
     if (!vc->gfx.scanout_mode) {
-        if (vc->gfx.fbo_id) {
-            glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
-                                      GL_COLOR_ATTACHMENT0_EXT,
-                                      GL_TEXTURE_2D, 0, 0);
-            glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
-            glDeleteFramebuffers(1, &vc->gfx.fbo_id);
-            vc->gfx.fbo_id = 0;
-        }
+        egl_fb_destroy(&vc->gfx.guest_fb);
         if (vc->gfx.surface) {
             surface_gl_destroy_texture(vc->gfx.gls, vc->gfx.ds);
             surface_gl_create_texture(vc->gfx.gls, vc->gfx.ds);
@@ -176,7 +169,6 @@ void gd_egl_scanout_disable(DisplayChangeListener *dcl)
 
     vc->gfx.w = 0;
     vc->gfx.h = 0;
-    vc->gfx.tex_id = 0;
     gtk_egl_set_scanout_mode(vc, false);
 }
 
@@ -192,20 +184,14 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
     vc->gfx.y = y;
     vc->gfx.w = w;
     vc->gfx.h = h;
-    vc->gfx.tex_id = backing_id;
     vc->gfx.y0_top = backing_y_0_top;
 
     eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
                    vc->gfx.esurface, vc->gfx.ectx);
 
     gtk_egl_set_scanout_mode(vc, true);
-    if (!vc->gfx.fbo_id) {
-        glGenFramebuffers(1, &vc->gfx.fbo_id);
-    }
-
-    glBindFramebuffer(GL_FRAMEBUFFER_EXT, vc->gfx.fbo_id);
-    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
-                              GL_TEXTURE_2D, vc->gfx.tex_id, 0);
+    egl_fb_create_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
+                          backing_id);
 }
 
 void gd_egl_scanout_flush(DisplayChangeListener *dcl,
@@ -213,30 +199,22 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
 {
     VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
     GdkWindow *window;
-    int ww, wh, y1, y2;
+    int ww, wh;
 
     if (!vc->gfx.scanout_mode) {
         return;
     }
-    if (!vc->gfx.fbo_id) {
+    if (!vc->gfx.guest_fb.framebuffer) {
         return;
     }
 
     eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
                    vc->gfx.esurface, vc->gfx.ectx);
 
-    glBindFramebuffer(GL_READ_FRAMEBUFFER, vc->gfx.fbo_id);
-    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
-
     window = gtk_widget_get_window(vc->gfx.drawing_area);
     gdk_drawable_get_size(window, &ww, &wh);
-    glViewport(0, 0, ww, wh);
-    y1 = vc->gfx.y0_top ? 0 : vc->gfx.h;
-    y2 = vc->gfx.y0_top ? vc->gfx.h : 0;
-    glBlitFramebuffer(0, y1, vc->gfx.w, y2,
-                      0, 0, ww, wh,
-                      GL_COLOR_BUFFER_BIT, GL_NEAREST);
-    glBindFramebuffer(GL_FRAMEBUFFER_EXT, vc->gfx.fbo_id);
+    egl_fb_setup_default(&vc->gfx.win_fb, ww, wh);
+    egl_fb_blit(&vc->gfx.win_fb, &vc->gfx.guest_fb, !vc->gfx.y0_top);
 
     eglSwapBuffers(qemu_egl_display, vc->gfx.esurface);
 }
ui/gtk-gl-area.c +7 -19
index b05c665cbb..18b298fc21 100644
@@ -26,14 +26,7 @@ static void gtk_gl_area_set_scanout_mode(VirtualConsole *vc, bool scanout)
 
     vc->gfx.scanout_mode = scanout;
     if (!vc->gfx.scanout_mode) {
-        if (vc->gfx.fbo_id) {
-            glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
-                                      GL_COLOR_ATTACHMENT0_EXT,
-                                      GL_TEXTURE_2D, 0, 0);
-            glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
-            glDeleteFramebuffers(1, &vc->gfx.fbo_id);
-            vc->gfx.fbo_id = 0;
-        }
+        egl_fb_destroy(&vc->gfx.guest_fb);
         if (vc->gfx.surface) {
             surface_gl_destroy_texture(vc->gfx.gls, vc->gfx.ds);
             surface_gl_create_texture(vc->gfx.gls, vc->gfx.ds);
@@ -56,11 +49,11 @@ void gd_gl_area_draw(VirtualConsole *vc)
     wh = gtk_widget_get_allocated_height(vc->gfx.drawing_area);
 
     if (vc->gfx.scanout_mode) {
-        if (!vc->gfx.fbo_id) {
+        if (!vc->gfx.guest_fb.framebuffer) {
             return;
         }
 
-        glBindFramebuffer(GL_READ_FRAMEBUFFER, vc->gfx.fbo_id);
+        glBindFramebuffer(GL_READ_FRAMEBUFFER, vc->gfx.guest_fb.framebuffer);
         /* GtkGLArea sets GL_DRAW_FRAMEBUFFER for us */
 
         glViewport(0, 0, ww, wh);
@@ -181,24 +174,19 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
     vc->gfx.y = y;
     vc->gfx.w = w;
     vc->gfx.h = h;
-    vc->gfx.tex_id = backing_id;
     vc->gfx.y0_top = backing_y_0_top;
 
     gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
 
-    if (vc->gfx.tex_id == 0 || vc->gfx.w == 0 || vc->gfx.h == 0) {
+    if (vc->gfx.guest_fb.framebuffer  == 0 ||
+        vc->gfx.w == 0 || vc->gfx.h == 0) {
         gtk_gl_area_set_scanout_mode(vc, false);
         return;
     }
 
     gtk_gl_area_set_scanout_mode(vc, true);
-    if (!vc->gfx.fbo_id) {
-        glGenFramebuffers(1, &vc->gfx.fbo_id);
-    }
-
-    glBindFramebuffer(GL_FRAMEBUFFER_EXT, vc->gfx.fbo_id);
-    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
-                              GL_TEXTURE_2D, vc->gfx.tex_id, 0);
+    egl_fb_create_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
+                          backing_id);
 }
 
 void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
Signature · 1 line
2.9.3
#4 lore raw

[Qemu-devel] [PULL 5/6] console: remove do_safe_dpy_refresh

In reply to Gerd Hoffmann

Drop the temporary workaround for the broken display updates. All display adapters are updated, so this should be safe without causing regressions.

Message-id: [email protected]

---
 ui/console.c | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)
ui/console.c +1 -24
index d914cced53..af0c56c600 100644
@@ -1579,36 +1579,13 @@ bool dpy_gfx_check_format(QemuConsole *con,
     return true;
 }
 
-/*
- * Safe DPY refresh for TCG guests. We use the exclusive mechanism to
- * ensure the TCG vCPUs are quiescent so we can avoid races between
- * dirty page tracking for direct frame-buffer access by the guest.
- *
- * This is a temporary stopgap until we've fixed the dirty tracking
- * races in display adapters.
- */
-static void do_safe_dpy_refresh(DisplayChangeListener *dcl)
-{
-    qemu_mutex_unlock_iothread();
-    start_exclusive();
-    qemu_mutex_lock_iothread();
-    dcl->ops->dpy_refresh(dcl);
-    qemu_mutex_unlock_iothread();
-    end_exclusive();
-    qemu_mutex_lock_iothread();
-}
-
 static void dpy_refresh(DisplayState *s)
 {
     DisplayChangeListener *dcl;
 
     QLIST_FOREACH(dcl, &s->listeners, next) {
         if (dcl->ops->dpy_refresh) {
-            if (tcg_enabled()) {
-                do_safe_dpy_refresh(dcl);
-            } else {
-                dcl->ops->dpy_refresh(dcl);
-            }
+            dcl->ops->dpy_refresh(dcl);
         }
     }
 }
Signature · 1 line
2.9.3
#9 lore raw

[Qemu-devel] [PULL 3/6] sdl2: use framebuffer helper functions.

In reply to Gerd Hoffmann

Message-id: [email protected]

---
 include/ui/sdl2.h |  8 ++++++--
 ui/sdl2-gl.c      | 36 +++++++-----------------------------
 2 files changed, 13 insertions(+), 31 deletions(-)
include/ui/sdl2.h +6 -2
index aaf226c2c0..454367ac84 100644
@@ -7,6 +7,10 @@
 #include <SDL.h>
 #include <SDL_syswm.h>
 
+#ifdef CONFIG_OPENGL
+# include "ui/egl-helpers.h"
+#endif
+
 struct sdl2_console {
     DisplayChangeListener dcl;
     DisplaySurface *surface;
@@ -23,8 +27,8 @@ struct sdl2_console {
     SDL_GLContext winctx;
 #ifdef CONFIG_OPENGL
     ConsoleGLState *gls;
-    GLuint tex_id;
-    GLuint fbo_id;
+    egl_fb guest_fb;
+    egl_fb win_fb;
     bool y0_top;
     bool scanout_mode;
 #endif
ui/sdl2-gl.c +7 -29
index 1cd77e2c16..dcad3d0d26 100644
@@ -42,14 +42,7 @@ static void sdl2_set_scanout_mode(struct sdl2_console *scon, bool scanout)
 
     scon->scanout_mode = scanout;
     if (!scon->scanout_mode) {
-        if (scon->fbo_id) {
-            glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
-                                      GL_COLOR_ATTACHMENT0_EXT,
-                                      GL_TEXTURE_2D, 0, 0);
-            glDeleteFramebuffers(1, &scon->fbo_id);
-            glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
-            scon->fbo_id = 0;
-        }
+        egl_fb_destroy(&scon->guest_fb);
         if (scon->surface) {
             surface_gl_destroy_texture(scon->gls, scon->surface);
             surface_gl_create_texture(scon->gls, scon->surface);
@@ -191,7 +184,6 @@ void sdl2_gl_scanout_disable(DisplayChangeListener *dcl)
     assert(scon->opengl);
     scon->w = 0;
     scon->h = 0;
-    scon->tex_id = 0;
     sdl2_set_scanout_mode(scon, false);
 }
 
@@ -210,48 +202,34 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
     scon->y = y;
     scon->w = w;
     scon->h = h;
-    scon->tex_id = backing_id;
     scon->y0_top = backing_y_0_top;
 
     SDL_GL_MakeCurrent(scon->real_window, scon->winctx);
 
     sdl2_set_scanout_mode(scon, true);
-    if (!scon->fbo_id) {
-        glGenFramebuffers(1, &scon->fbo_id);
-    }
-
-    glBindFramebuffer(GL_FRAMEBUFFER_EXT, scon->fbo_id);
-    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
-                              GL_TEXTURE_2D, scon->tex_id, 0);
+    egl_fb_create_for_tex(&scon->guest_fb, backing_width, backing_height,
+                          backing_id);
 }
 
 void sdl2_gl_scanout_flush(DisplayChangeListener *dcl,
                            uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 {
     struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
-    int ww, wh, y1, y2;
+    int ww, wh;
 
     assert(scon->opengl);
     if (!scon->scanout_mode) {
         return;
     }
-    if (!scon->fbo_id) {
+    if (!scon->guest_fb.framebuffer) {
         return;
     }
 
     SDL_GL_MakeCurrent(scon->real_window, scon->winctx);
 
-    glBindFramebuffer(GL_READ_FRAMEBUFFER, scon->fbo_id);
-    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
-
     SDL_GetWindowSize(scon->real_window, &ww, &wh);
-    glViewport(0, 0, ww, wh);
-    y1 = scon->y0_top ? 0 : scon->h;
-    y2 = scon->y0_top ? scon->h : 0;
-    glBlitFramebuffer(0, y1, scon->w, y2,
-                      0, 0, ww, wh,
-                      GL_COLOR_BUFFER_BIT, GL_NEAREST);
-    glBindFramebuffer(GL_FRAMEBUFFER_EXT, scon->fbo_id);
+    egl_fb_setup_default(&scon->win_fb, ww, wh);
+    egl_fb_blit(&scon->win_fb, &scon->guest_fb, !scon->y0_top);
 
     SDL_GL_SwapWindow(scon->real_window);
 }
Signature · 1 line
2.9.3
#10 lore raw

[Qemu-devel] [PULL 2/6] egl-headless: use framebuffer helper functions.

In reply to Gerd Hoffmann

Message-id: [email protected]

---
 ui/egl-headless.c | 67 ++++++++++++++-----------------------------------------
 1 file changed, 17 insertions(+), 50 deletions(-)
ui/egl-headless.c +17 -50
index d8d800f8a6..809bfde99c 100644
@@ -8,14 +8,13 @@
 typedef struct egl_dpy {
     DisplayChangeListener dcl;
     DisplaySurface *ds;
-    int width, height;
-    GLuint texture;
-    GLuint framebuffer;
-    GLuint blit_texture;
-    GLuint blit_framebuffer;
+    egl_fb guest_fb;
+    egl_fb blit_fb;
     bool y_0_top;
 } egl_dpy;
 
+/* ------------------------------------------------------------------ */
+
 static void egl_refresh(DisplayChangeListener *dcl)
 {
     graphic_hw_update(dcl->con);
@@ -38,8 +37,8 @@ static void egl_scanout_disable(DisplayChangeListener *dcl)
 {
     egl_dpy *edpy = container_of(dcl, egl_dpy, dcl);
 
-    edpy->texture = 0;
-    /* XXX: delete framebuffers here ??? */
+    egl_fb_destroy(&edpy->guest_fb);
+    egl_fb_destroy(&edpy->blit_fb);
 }
 
 static void egl_scanout_texture(DisplayChangeListener *dcl,
@@ -52,34 +51,17 @@ static void egl_scanout_texture(DisplayChangeListener *dcl,
 {
     egl_dpy *edpy = container_of(dcl, egl_dpy, dcl);
 
-    edpy->texture = backing_id;
     edpy->y_0_top = backing_y_0_top;
 
     /* source framebuffer */
-    if (!edpy->framebuffer) {
-        glGenFramebuffers(1, &edpy->framebuffer);
-    }
-    glBindFramebuffer(GL_FRAMEBUFFER_EXT, edpy->framebuffer);
-    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
-                              GL_TEXTURE_2D, edpy->texture, 0);
+    egl_fb_create_for_tex(&edpy->guest_fb,
+                          backing_width, backing_height, backing_id);
 
     /* dest framebuffer */
-    if (!edpy->blit_framebuffer) {
-        glGenFramebuffers(1, &edpy->blit_framebuffer);
-        glGenTextures(1, &edpy->blit_texture);
-        edpy->width = 0;
-        edpy->height = 0;
-    }
-    if (edpy->width != backing_width || edpy->height != backing_height) {
-        edpy->width   = backing_width;
-        edpy->height  = backing_height;
-        glBindTexture(GL_TEXTURE_2D, edpy->blit_texture);
-        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
-                     edpy->width, edpy->height,
-                     0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
-        glBindFramebuffer(GL_FRAMEBUFFER_EXT, edpy->blit_framebuffer);
-        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
-                                  GL_TEXTURE_2D, edpy->blit_texture, 0);
+    if (edpy->blit_fb.width  != backing_width ||
+        edpy->blit_fb.height != backing_height) {
+        egl_fb_destroy(&edpy->blit_fb);
+        egl_fb_create_new_tex(&edpy->blit_fb, backing_width, backing_height);
     }
 }
 
@@ -88,32 +70,17 @@ static void egl_scanout_flush(DisplayChangeListener *dcl,
                               uint32_t w, uint32_t h)
 {
     egl_dpy *edpy = container_of(dcl, egl_dpy, dcl);
-    GLuint y1, y2;
 
-    if (!edpy->texture || !edpy->ds) {
+    if (!edpy->guest_fb.texture || !edpy->ds) {
         return;
     }
-    assert(surface_width(edpy->ds)  == edpy->width);
-    assert(surface_height(edpy->ds) == edpy->height);
+    assert(surface_width(edpy->ds)  == edpy->guest_fb.width);
+    assert(surface_height(edpy->ds) == edpy->guest_fb.height);
     assert(surface_format(edpy->ds) == PIXMAN_x8r8g8b8);
 
-    /* blit framebuffer, flip if needed */
-    glBindFramebuffer(GL_READ_FRAMEBUFFER, edpy->framebuffer);
-    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, edpy->blit_framebuffer);
-    glViewport(0, 0, edpy->width, edpy->height);
-    y1 = edpy->y_0_top ? edpy->height : 0;
-    y2 = edpy->y_0_top ? 0 : edpy->height;
-    glBlitFramebuffer(0, y1, edpy->width, y2,
-                      0, 0, edpy->width, edpy->height,
-                      GL_COLOR_BUFFER_BIT, GL_NEAREST);
+    egl_fb_blit(&edpy->blit_fb, &edpy->guest_fb, edpy->y_0_top);
+    egl_fb_read(surface_data(edpy->ds), &edpy->blit_fb);
 
-    /* read pixels to surface */
-    glBindFramebuffer(GL_READ_FRAMEBUFFER, edpy->blit_framebuffer);
-    glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
-    glReadPixels(0, 0, edpy->width, edpy->height,
-                 GL_BGRA, GL_UNSIGNED_BYTE, surface_data(edpy->ds));
-
-    /* notify about updates */
     dpy_gfx_update(edpy->dcl.con, x, y, w, h);
 }
 
Signature · 1 line
2.9.3
#11 lore raw
In reply to Gerd Hoffmann
Quoted 8 lines · Gerd Hoffmann

The following changes since commit 8dfaf23ae1f2273a9730a9b309cc8471269bb524:

tcg/tci: fix tcg-interpreter build (2017-06-20 18:39:15 +0100)

are available in the git repository at:

git://git.kraxel.org/qemu tags/queue/ui-pull-request

Quoted 7 lines

for you to fetch changes up to 95e92000c8b1e81fce6a7f54ef22656a94793096:

ui: Remove inclusion of "hw/qdev.h" (2017-06-21 14:26:15 +0200)

----------------------------------------------------------------

----------------------------------------------------------------

Applied, thanks.

-- PMM

#5 lore raw

Re: [Qemu-devel] [PULL 5/6] console: remove do_safe_dpy_refresh

In reply to Gerd Hoffmann
Quoted 3 lines · Gerd Hoffmann

Drop the temporary workaround for the broken display updates. All display adapters are updated, so this should be safe without causing regressions.

It seems it breaks QMP command 'migrate "exec:cat>mig"'.

The command hangs and doesn't create the file.

It happens with qemu-system-ppc64 on x86 (so TCG mode).

my command:

./ppc64-softmmu/qemu-system-ppc64 -serial mon:stdio

I wait SLOF fails to find an OS, and:

Ctrl-a c
(qemu) migrate -d "exec:cat>mig"

The file is not created and the command hangs:

#0  in __lll_lock_wait
#1  in pthread_mutex_lock
#2  in qemu_mutex_lock
#3  in rcu_init_lock
#4  in fork
#5  in qemu_fork
#6  in qio_channel_command_new_spawn
#7  in exec_start_outgoing_migration
#8  in qmp_migrate

...

It looks like a deadlock.

Laurent

Quoted 50 lines

Message-id: [email protected]

---
 ui/console.c | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)
ui/console.c +1 -24
index d914cced53..af0c56c600 100644
@@ -1579,36 +1579,13 @@ bool dpy_gfx_check_format(QemuConsole *con,
     return true;
 }
 
-/*
- * Safe DPY refresh for TCG guests. We use the exclusive mechanism to
- * ensure the TCG vCPUs are quiescent so we can avoid races between
- * dirty page tracking for direct frame-buffer access by the guest.
- *
- * This is a temporary stopgap until we've fixed the dirty tracking
- * races in display adapters.
- */
-static void do_safe_dpy_refresh(DisplayChangeListener *dcl)
-{
-    qemu_mutex_unlock_iothread();
-    start_exclusive();
-    qemu_mutex_lock_iothread();
-    dcl->ops->dpy_refresh(dcl);
-    qemu_mutex_unlock_iothread();
-    end_exclusive();
-    qemu_mutex_lock_iothread();
-}
-
 static void dpy_refresh(DisplayState *s)
 {
     DisplayChangeListener *dcl;
 
     QLIST_FOREACH(dcl, &s->listeners, next) {
         if (dcl->ops->dpy_refresh) {
-            if (tcg_enabled()) {
-                do_safe_dpy_refresh(dcl);
-            } else {
-                dcl->ops->dpy_refresh(dcl);
-            }
+            dcl->ops->dpy_refresh(dcl);
         }
     }
 }
#6 lore raw

Re: [Qemu-devel] [PULL 5/6] console: remove do_safe_dpy_refresh

Quoted 31 lines · Laurent Vivier
Quoted 3 lines · Gerd Hoffmann

Drop the temporary workaround for the broken display updates. All display adapters are updated, so this should be safe without causing regressions.

It seems it breaks QMP command 'migrate "exec:cat>mig"'.

The command hangs and doesn't create the file.

It happens with qemu-system-ppc64 on x86 (so TCG mode).

my command:

./ppc64-softmmu/qemu-system-ppc64 -serial mon:stdio

I wait SLOF fails to find an OS, and:

Ctrl-a c
(qemu) migrate -d "exec:cat>mig"

The file is not created and the command hangs:

#0  in __lll_lock_wait
#1  in pthread_mutex_lock
#2  in qemu_mutex_lock
#3  in rcu_init_lock
#4  in fork
#5  in qemu_fork
#6  in qio_channel_command_new_spawn
#7  in exec_start_outgoing_migration
#8  in qmp_migrate
Quoted 3 lines

...

It looks like a deadlock.

I think this patch is not the cause of the problem, the one it removes just unlocks the deadlock by playing with locks.

We have a rcu_init_lock() on fork() because of:

utils/rcu.c:

static void __attribute__((__constructor__)) rcu_init(void) {

#ifdef CONFIG_POSIX
    pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_unlock);
#endif
    rcu_init_complete();
}

The QMP thread hangs on:

(gdb) p rcu_sync_lock
$1 = {lock = {__data = {__lock = 2, __count = 0, __owner = 23865,

      __nusers = 1, __kind = 0, __spins = 0, __elision = 0, __list = {
        __prev = 0x0, __next = 0x0}},
    __size = "\002\000\000\000\000\000\000\000\071]\000\000\001", '\000'

<repeats 26 times>, __align = 2}, initialized = true}

The lock is already taken by thread 2:

(gdb) info thread
Id Target Id Frame
1 Thread 0x7f1cf02fdf00 (LWP 23864) "qemu-system-ppc"
0x00007f1cd914b37d in __lll_lock_wait () from /lib64/libpthread.so.0
* 2 Thread 0x7f1cc9762700 (LWP 23865) "qemu-system-ppc"
0x00007f1cd410daa9 in syscall () from /lib64/libc.so.6
3 Thread 0x7f1cbf8d5700 (LWP 23866) "qemu-system-ppc"
0x00007f1cd914b37d in __lll_lock_wait () from /lib64/libpthread.so.0

(gdb) bt

#0  0x00007f1cd410daa9 in syscall () at /lib64/libc.so.6
#1  0x000055ab028ddda2 in qemu_futex_wait
#2  0x000055ab028ddda2 in qemu_event_wait
#3  0x000055ab028eda2b in wait_for_readers
#4  0x000055ab028eda2b in synchronize_rcu
#5  0x000055ab028edc5b in call_rcu_thread
#6  0x00007f1cd914273a in start_thread ()
#7  0x00007f1cd4113e0f in clone ()

So it seems we cannot fork() from QMP?
[cc: Paolo]

Any comments?

Laurent

#7 lore raw

Re: [Qemu-devel] [PULL 5/6] console: remove do_safe_dpy_refresh

Quoted 82 lines · * Laurent Vivier ([email protected]) wrote:
Quoted 31 lines · Laurent Vivier
Quoted 3 lines · Gerd Hoffmann

Drop the temporary workaround for the broken display updates. All display adapters are updated, so this should be safe without causing regressions.

It seems it breaks QMP command 'migrate "exec:cat>mig"'.

The command hangs and doesn't create the file.

It happens with qemu-system-ppc64 on x86 (so TCG mode).

my command:

./ppc64-softmmu/qemu-system-ppc64 -serial mon:stdio

I wait SLOF fails to find an OS, and:

Ctrl-a c
(qemu) migrate -d "exec:cat>mig"

The file is not created and the command hangs:

#0  in __lll_lock_wait
#1  in pthread_mutex_lock
#2  in qemu_mutex_lock
#3  in rcu_init_lock
#4  in fork
#5  in qemu_fork
#6  in qio_channel_command_new_spawn
#7  in exec_start_outgoing_migration
#8  in qmp_migrate
Quoted 3 lines

...

It looks like a deadlock.

I think this patch is not the cause of the problem, the one it removes just unlocks the deadlock by playing with locks.

We have a rcu_init_lock() on fork() because of:

utils/rcu.c:

static void __attribute__((__constructor__)) rcu_init(void) {

#ifdef CONFIG_POSIX
    pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_unlock);
#endif
    rcu_init_complete();
}

The QMP thread hangs on:

(gdb) p rcu_sync_lock
$1 = {lock = {__data = {__lock = 2, __count = 0, __owner = 23865,

      __nusers = 1, __kind = 0, __spins = 0, __elision = 0, __list = {
        __prev = 0x0, __next = 0x0}},
    __size = "\002\000\000\000\000\000\000\000\071]\000\000\001", '\000'

<repeats 26 times>, __align = 2}, initialized = true}

The lock is already taken by thread 2:

(gdb) info thread
Id Target Id Frame
1 Thread 0x7f1cf02fdf00 (LWP 23864) "qemu-system-ppc"
0x00007f1cd914b37d in __lll_lock_wait () from /lib64/libpthread.so.0
* 2 Thread 0x7f1cc9762700 (LWP 23865) "qemu-system-ppc"
0x00007f1cd410daa9 in syscall () from /lib64/libc.so.6
3 Thread 0x7f1cbf8d5700 (LWP 23866) "qemu-system-ppc"
0x00007f1cd914b37d in __lll_lock_wait () from /lib64/libpthread.so.0

(gdb) bt

#0  0x00007f1cd410daa9 in syscall () at /lib64/libc.so.6
#1  0x000055ab028ddda2 in qemu_futex_wait
#2  0x000055ab028ddda2 in qemu_event_wait
#3  0x000055ab028eda2b in wait_for_readers
#4  0x000055ab028eda2b in synchronize_rcu
#5  0x000055ab028edc5b in call_rcu_thread
#6  0x00007f1cd914273a in start_thread ()
#7  0x00007f1cd4113e0f in clone ()
Quoted 4 lines

So it seems we cannot fork() from QMP?
[cc: Paolo]

Any comments?

I remembered hitting this in the past - but I can only trigger it rarely for me on x86; the following script triggers it after ~100 iterations on my laptop:

#!/bin/bash

while true
do
OURPIPE=/tmp/delaystop.$$
mknod $OURPIPE p

./try/x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,accel=kvm -smp 8 < $OURPIPE & QEMUPID=$!
exec 10> "$OURPIPE"

  # Flip the mon to hmp
  echo -e '\001c' >&10
  # just a test
  echo 'migrate  -d "exec: cat > /dev/null"' >&10
  sleep $(printf ".%05d" $RANDOM)
  echo "info status" >&10
  echo "q" >&10

rm $OURPIPE
wait $QEMUPID || break
done

(From my notes I mentioned that to Paolo about 18months ago after he nailed a different case)

Dave

Quoted 2 lines

Laurent

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#8 lore raw

Re: [Qemu-devel] [PULL 5/6] console: remove do_safe_dpy_refresh

In reply to Laurent Vivier
Quoted 82 lines · Laurent Vivier
Quoted 31 lines · Laurent Vivier
Quoted 3 lines · Gerd Hoffmann

Drop the temporary workaround for the broken display updates. All display adapters are updated, so this should be safe without causing regressions.

It seems it breaks QMP command 'migrate "exec:cat>mig"'.

The command hangs and doesn't create the file.

It happens with qemu-system-ppc64 on x86 (so TCG mode).

my command:

./ppc64-softmmu/qemu-system-ppc64 -serial mon:stdio

I wait SLOF fails to find an OS, and:

Ctrl-a c
(qemu) migrate -d "exec:cat>mig"

The file is not created and the command hangs:

#0  in __lll_lock_wait
#1  in pthread_mutex_lock
#2  in qemu_mutex_lock
#3  in rcu_init_lock
#4  in fork
#5  in qemu_fork
#6  in qio_channel_command_new_spawn
#7  in exec_start_outgoing_migration
#8  in qmp_migrate
Quoted 3 lines

...

It looks like a deadlock.

I think this patch is not the cause of the problem, the one it removes just unlocks the deadlock by playing with locks.

We have a rcu_init_lock() on fork() because of:

utils/rcu.c:

static void __attribute__((__constructor__)) rcu_init(void) {

#ifdef CONFIG_POSIX
    pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_unlock);
#endif
    rcu_init_complete();
}

The QMP thread hangs on:

(gdb) p rcu_sync_lock
$1 = {lock = {__data = {__lock = 2, __count = 0, __owner = 23865,

      __nusers = 1, __kind = 0, __spins = 0, __elision = 0, __list = {
        __prev = 0x0, __next = 0x0}},
    __size = "\002\000\000\000\000\000\000\000\071]\000\000\001", '\000'

<repeats 26 times>, __align = 2}, initialized = true}

The lock is already taken by thread 2:

(gdb) info thread
Id Target Id Frame
1 Thread 0x7f1cf02fdf00 (LWP 23864) "qemu-system-ppc"
0x00007f1cd914b37d in __lll_lock_wait () from /lib64/libpthread.so.0
* 2 Thread 0x7f1cc9762700 (LWP 23865) "qemu-system-ppc"
0x00007f1cd410daa9 in syscall () from /lib64/libc.so.6
3 Thread 0x7f1cbf8d5700 (LWP 23866) "qemu-system-ppc"
0x00007f1cd914b37d in __lll_lock_wait () from /lib64/libpthread.so.0

(gdb) bt

#0  0x00007f1cd410daa9 in syscall () at /lib64/libc.so.6
#1  0x000055ab028ddda2 in qemu_futex_wait
#2  0x000055ab028ddda2 in qemu_event_wait
#3  0x000055ab028eda2b in wait_for_readers
#4  0x000055ab028eda2b in synchronize_rcu
#5  0x000055ab028edc5b in call_rcu_thread
#6  0x00007f1cd914273a in start_thread ()
#7  0x00007f1cd4113e0f in clone ()
Quoted 2 lines

So it seems we cannot fork() from QMP?
[cc: Paolo]

There have been other similar bugs, as David reported. The plan was to disable pthread_atfork soon after daemonize (basically assuming that after daemonize fork is immediately followed by exec), but I've been lazy and never finished those patches. Looks like it's time.

Paolo