From patchwork Mon Oct 24 12:02:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 121334 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 94EF5B6F82 for ; Mon, 24 Oct 2011 23:13:50 +1100 (EST) Received: from localhost ([::1]:57351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIJHe-0000fp-1g for incoming@patchwork.ozlabs.org; Mon, 24 Oct 2011 08:05:38 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIJHJ-0000Pz-4H for qemu-devel@nongnu.org; Mon, 24 Oct 2011 08:05:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RIJHB-00027U-Cn for qemu-devel@nongnu.org; Mon, 24 Oct 2011 08:05:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIJHA-000277-T0 for qemu-devel@nongnu.org; Mon, 24 Oct 2011 08:05:09 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9OC58NZ027927 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 24 Oct 2011 08:05:08 -0400 Received: from bow.tlv.redhat.com (dhcp-3-73.tlv.redhat.com [10.35.3.73]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9OC52ve027291; Mon, 24 Oct 2011 08:05:06 -0400 From: Alon Levy To: lcapitulino@redhat.com, armbru@redhat.com, kraxel@redhat.com Date: Mon, 24 Oct 2011 14:02:15 +0200 Message-Id: <1319457739-14562-2-git-send-email-alevy@redhat.com> In-Reply-To: <1319457739-14562-1-git-send-email-alevy@redhat.com> References: <1319457739-14562-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: mlureau@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 1/5] monitor: screen_dump async X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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