qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alon Levy <alevy@redhat.com>
To: lcapitulino@redhat.com, armbru@redhat.com, kraxel@redhat.com
Cc: mlureau@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/5] monitor: screen_dump async
Date: Mon, 24 Oct 2011 14:02:15 +0200	[thread overview]
Message-ID: <1319457739-14562-2-git-send-email-alevy@redhat.com> (raw)
In-Reply-To: <1319457739-14562-1-git-send-email-alevy@redhat.com>

Make screen_dump monitor command an async command to allow next for qxl
to implement it as a initiating call to red_worker and completion on
callback, to fix a deadlock when issueing a screendump command via
libvirt while connected with a libvirt controlled spice-gtk client.

This patch introduces no functional changes.
---
 console.c       |    5 +++--
 console.h       |    7 +++++--
 hmp-commands.hx |    3 ++-
 hw/g364fb.c     |   12 ++++++++----
 hw/qxl.c        |    6 ++++--
 hw/vga.c        |    7 +++++--
 hw/vmware_vga.c |    5 +++--
 monitor.c       |    5 +++--
 qmp-commands.hx |    3 ++-
 9 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/console.c b/console.c
index e43de92..30c667a 100644
--- a/console.c
+++ b/console.c
@@ -173,7 +173,8 @@ void vga_hw_invalidate(void)
         active_console->hw_invalidate(active_console->hw);
 }
 
-void vga_hw_screen_dump(const char *filename)
+void vga_hw_screen_dump(const char *filename, MonitorCompletion cb,
+                        void *opaque)
 {
     TextConsole *previous_active_console;
 
@@ -183,7 +184,7 @@ void vga_hw_screen_dump(const char *filename)
        so always dump the first one.  */
     console_select(0);
     if (consoles[0] && consoles[0]->hw_screen_dump) {
-        consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
+        consoles[0]->hw_screen_dump(consoles[0]->hw, filename, cb, opaque);
     }
 
     console_select(previous_active_console->index);
diff --git a/console.h b/console.h
index 9c1487e..dde4088 100644
--- a/console.h
+++ b/console.h
@@ -343,7 +343,9 @@ static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
 
 typedef void (*vga_hw_update_ptr)(void *);
 typedef void (*vga_hw_invalidate_ptr)(void *);
-typedef void (*vga_hw_screen_dump_ptr)(void *, const char *);
+typedef void (*vga_hw_screen_dump_ptr)(void *, const char *,
+                                       MonitorCompletion *,
+                                       void *);
 typedef void (*vga_hw_text_update_ptr)(void *, console_ch_t *);
 
 DisplayState *graphic_console_init(vga_hw_update_ptr update,
@@ -354,7 +356,8 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update,
 
 void vga_hw_update(void);
 void vga_hw_invalidate(void);
-void vga_hw_screen_dump(const char *filename);
+void vga_hw_screen_dump(const char *filename, MonitorCompletion cb,
+                        void *opaque);
 void vga_hw_text_update(console_ch_t *chardata);
 
 int is_graphic_console(void);
diff --git a/hmp-commands.hx b/hmp-commands.hx
index ab08d58..a7b3494 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -157,7 +157,8 @@ ETEXI
         .params     = "filename",
         .help       = "save screen into PPM image 'filename'",
         .user_print = monitor_user_noop,
-        .mhandler.cmd_new = do_screen_dump,
+        .mhandler.cmd_async = do_screen_dump,
+        .flags      = MONITOR_CMD_ASYNC,
     },
 
 STEXI
diff --git a/hw/g364fb.c b/hw/g364fb.c
index f00ee27..5884e20 100644
--- a/hw/g364fb.c
+++ b/hw/g364fb.c
@@ -291,7 +291,8 @@ static void g364fb_reset(G364State *s)
     g364fb_invalidate_display(s);
 }
 
-static void g364fb_screen_dump(void *opaque, const char *filename)
+static void g364fb_screen_dump(void *opaque, const char *filename,
+                               MonitorCompletion *cb, void *cb_opaque)
 {
     G364State *s = opaque;
     int y, x;
@@ -303,12 +304,13 @@ static void g364fb_screen_dump(void *opaque, const char *filename)
 
     if (s->depth != 8) {
         error_report("g364: unknown guest depth %d", s->depth);
-        return;
+        goto end;
     }
 
     f = fopen(filename, "wb");
-    if (!f)
-        return;
+    if (!f) {
+        goto end;
+    }
 
     if (s->ctla & CTLA_FORCE_BLANK) {
         /* blank screen */
@@ -331,6 +333,8 @@ static void g364fb_screen_dump(void *opaque, const char *filename)
     }
 
     fclose(f);
+end:
+    cb(cb_opaque, NULL);
 }
 
 /* called for accesses to io ports */
diff --git a/hw/qxl.c b/hw/qxl.c
index 03848ed..4003e53 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1423,7 +1423,8 @@ static void qxl_hw_invalidate(void *opaque)
     vga->invalidate(vga);
 }
 
-static void qxl_hw_screen_dump(void *opaque, const char *filename)
+static void qxl_hw_screen_dump(void *opaque, const char *filename,
+                               MonitorCompletion *cb, void *cb_opaque)
 {
     PCIQXLDevice *qxl = opaque;
     VGACommonState *vga = &qxl->vga;
@@ -1433,9 +1434,10 @@ static void qxl_hw_screen_dump(void *opaque, const char *filename)
     case QXL_MODE_NATIVE:
         qxl_render_update(qxl);
         ppm_save(filename, qxl->ssd.ds->surface);
+        cb(cb_opaque, NULL);
         break;
     case QXL_MODE_VGA:
-        vga->screen_dump(vga, filename);
+        vga->screen_dump(vga, filename, cb, cb_opaque);
         break;
     default:
         break;
diff --git a/hw/vga.c b/hw/vga.c
index ca79aa1..b257f74 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -148,7 +148,8 @@ static uint32_t expand4[256];
 static uint16_t expand2[256];
 static uint8_t expand4to8[16];
 
-static void vga_screen_dump(void *opaque, const char *filename);
+static void vga_screen_dump(void *opaque, const char *filename,
+                            MonitorCompletion *cb, void *cb_opaque);
 static const char *screen_dump_filename;
 static DisplayChangeListener *screen_dump_dcl;
 
@@ -2404,7 +2405,8 @@ static DisplayChangeListener* vga_screen_dump_init(DisplayState *ds)
 
 /* save the vga display in a PPM image even if no display is
    available */
-static void vga_screen_dump(void *opaque, const char *filename)
+static void vga_screen_dump(void *opaque, const char *filename,
+                            MonitorCompletion *cb, void *cb_opaque)
 {
     VGACommonState *s = opaque;
 
@@ -2415,4 +2417,5 @@ static void vga_screen_dump(void *opaque, const char *filename)
     vga_invalidate_display(s);
     vga_hw_update();
     screen_dump_filename = NULL;
+    cb(cb_opaque, NULL);
 }
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index af70bde..a238fef 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1003,11 +1003,12 @@ static void vmsvga_invalidate_display(void *opaque)
 
 /* save the vga display in a PPM image even if no display is
    available */
-static void vmsvga_screen_dump(void *opaque, const char *filename)
+static void vmsvga_screen_dump(void *opaque, const char *filename,
+                               MonitorCompletion *cb, void *cb_opaque)
 {
     struct vmsvga_state_s *s = opaque;
     if (!s->enable) {
-        s->vga.screen_dump(&s->vga, filename);
+        s->vga.screen_dump(&s->vga, filename, cb, cb_opaque);
         return;
     }
 
diff --git a/monitor.c b/monitor.c
index ffda0fe..daf5e2f 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1180,9 +1180,10 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict, QObject **ret_d
     return -1;
 }
 
-static int do_screen_dump(Monitor *mon, const QDict *qdict, QObject **ret_data)
+static int do_screen_dump(Monitor *mon, const QDict *params,
+                          MonitorCompletion cb, void *opaque)
 {
-    vga_hw_screen_dump(qdict_get_str(qdict, "filename"));
+    vga_hw_screen_dump(qdict_get_str(params, "filename"), cb, opaque);
     return 0;
 }
 
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 9c11e87..15b04d6 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -155,7 +155,8 @@ EQMP
         .params     = "filename",
         .help       = "save screen into PPM image 'filename'",
         .user_print = monitor_user_noop,
-        .mhandler.cmd_new = do_screen_dump,
+        .mhandler.cmd_async = do_screen_dump,
+        .flags      = MONITOR_CMD_ASYNC,
     },
 
 SQMP
-- 
1.7.7

  reply	other threads:[~2011-10-24 12:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-24 12:02 [Qemu-devel] [PATCH 0/5] monitor+qxl: async monitor support Alon Levy
2011-10-24 12:02 ` Alon Levy [this message]
2011-10-24 15:13   ` [Qemu-devel] [PATCH 1/5] monitor: screen_dump async Gerd Hoffmann
2011-10-24 15:45     ` Luiz Capitulino
2011-10-24 17:29       ` Alon Levy
2011-10-25  0:31         ` Luiz Capitulino
2011-10-25 10:13           ` Alon Levy
2011-10-25 12:51             ` Luiz Capitulino
2011-10-25 13:21               ` Alon Levy
2011-10-25 18:41                 ` Luiz Capitulino
2011-10-26 11:48                   ` Alon Levy
2011-10-25  7:16       ` Gerd Hoffmann
2011-10-24 12:02 ` [Qemu-devel] [PATCH 2/5] qxl: s/__FUNCTION__/__func__/, change logging levels Alon Levy
2011-10-24 12:02 ` [Qemu-devel] [PATCH 3/5] qxl: support concurrent async commands Alon Levy
2011-10-24 15:26   ` Gerd Hoffmann
2011-10-25 12:19     ` Alon Levy
2011-10-24 12:02 ` [Qemu-devel] [PATCH 4/5] qxl: split qxl_render_display_resized Alon Levy
2011-10-24 12:02 ` [Qemu-devel] [PATCH 5/5] qxl: support async monitor screen dump Alon Levy
2011-10-24 15:29   ` Gerd Hoffmann
2011-10-24 17:30     ` Alon Levy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1319457739-14562-2-git-send-email-alevy@redhat.com \
    --to=alevy@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mlureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).