From a2cf04f5572bccdb4dba10540ef93860bbd690de Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 4 Jul 2014 11:55:46 +0200 Subject: [PATCH 065/212] add qxl_screendump monitor command RH-Author: Gerd Hoffmann Message-id: <1375866764-17766-2-git-send-email-kraxel@redhat.com> Patchwork-id: 53033 O-Subject: [RHEL-7 qemu-kvm PATCH 1/1] add qxl_screendump monitor command Bugzilla: 903910 RH-Acked-by: Hans de Goede RH-Acked-by: Laszlo Ersek RH-Acked-by: Michal Novotny This patch ports the rhel-6 specific qxl_screendump command to rhel-7. qxl_screendump takes the device id as additional argument and thus can be used to take screenshots from non-primary displays. The plan to get that functionality upstream in time failed, so we go for plan b and carry forward the rhel-6 specific qxl_screendump command. Thanks to the major console subsystem cleanups which made it upstream the implementation is (a) alot less hackier than the rhel-6 one and (b) not qxl-specific any more. Given that qxl is the only graphic device which can work as secondary vga card the later is only a theoretical benefit though ;) RHEL-6 commit: 1c6074d107dff93c7c7b0edfb5da871504802946 bugzilla: #903910 - RHEL7 does not have equivalent functionality for __com.redhat_qxl_screendump Signed-off-by: Gerd Hoffmann --- hmp-commands.hx |7 +++++++ hmp.c| 10 ++++++++++ hmp.h|1 + qapi-schema.json | 15 +++++++++++++++ qmp-commands.hx |5 +++++ ui/console.c | 23 +++++++++++++++++++++++ 6 files changed, 61 insertions(+) Signed-off-by: Miroslav Rezanina --- hmp-commands.hx | 7 +++++++ hmp.c | 10 ++++++++++ hmp.h | 1 + qapi-schema.json | 15 +++++++++++++++ qmp-commands.hx | 5 +++++ ui/console.c | 23 +++++++++++++++++++++++ 6 files changed, 61 insertions(+), 0 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index d0943b1..f24a72a 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -247,6 +247,13 @@ ETEXI .help = "save screen into PPM image 'filename'", .mhandler.cmd = hmp_screen_dump, }, + { + .name = "__com.redhat_qxl_screendump", + .args_type = "id:s,filename:F", + .params = "id filename", + .help = "save screen from qxl device 'id' into PPM image 'filename'", + .mhandler.cmd = hmp___com_redhat_qxl_screen_dump, + }, STEXI @item screendump @var{filename} diff --git a/hmp.c b/hmp.c index 4d1838e..ad8f52d 100644 --- a/hmp.c +++ b/hmp.c @@ -1547,6 +1547,16 @@ void hmp_screen_dump(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } +void hmp___com_redhat_qxl_screen_dump(Monitor *mon, const QDict *qdict) +{ + const char *id = qdict_get_str(qdict, "id"); + const char *filename = qdict_get_str(qdict, "filename"); + Error *err = NULL; + + qmp___com_redhat_qxl_screendump(id, filename, &err); + hmp_handle_error(mon, &err); +} + void hmp_nbd_server_start(Monitor *mon, const QDict *qdict) { const char *uri = qdict_get_str(qdict, "uri"); diff --git a/hmp.h b/hmp.h index 4fd3c4a..856e026 100644 --- a/hmp.h +++ b/hmp.h @@ -84,6 +84,7 @@ void hmp_getfd(Monitor *mon, const QDict *qdict); void hmp_closefd(Monitor *mon, const QDict *qdict); void hmp_send_key(Monitor *mon, const QDict *qdict); void hmp_screen_dump(Monitor *mon, const QDict *qdict); +void hmp___com_redhat_qxl_screen_dump(Monitor *mon, const QDict *qdict); void hmp_nbd_server_start(Monitor *mon, const QDict *qdict); void hmp_nbd_server_add(Monitor *mon, const QDict *qdict); void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict); diff --git a/qapi-schema.json b/qapi-schema.json index b11aad2..8cd7d19 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2610,6 +2610,21 @@ { 'command': 'screendump', 'data': {'filename': 'str'} } ## +# @__com.redhat_qxl_screendump: +# +# Write a PPM of secondary qxl devices to a file. +# +# @id: qxl device id +# @filename: the path of a new PPM file to store the image +# +# Returns: Nothing on success +# +# Since: never (rhel-only, not upstream) +## +{ 'command': '__com.redhat_qxl_screendump', 'data': { 'id' : 'str', + 'filename': 'str' } } + +## # @ChardevFile: # # Configuration info for file chardevs. diff --git a/qmp-commands.hx b/qmp-commands.hx index 4be4765..4a02a51 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -148,6 +148,11 @@ EQMP .args_type = "filename:F", .mhandler.cmd_new = qmp_marshal_input_screendump, }, + { + .name = "__com.redhat_qxl_screendump", + .args_type = "id:s,filename:F", + .mhandler.cmd_new = qmp_marshal_input___com_redhat_qxl_screendump, + }, SQMP screendump diff --git a/ui/console.c b/ui/console.c index ab84549..776b3d8 100644 --- a/ui/console.c +++ b/ui/console.c @@ -331,6 +331,29 @@ void qmp_screendump(const char *filename, Error **errp) ppm_save(filename, surface, errp); } +void qmp___com_redhat_qxl_screendump(const char *id, const char *filename, Error **errp) +{ + DeviceState *dev; + QemuConsole *con; + DisplaySurface *surface; + + dev = qdev_find_recursive(sysbus_get_default(), id); + if (NULL == dev) { + error_set(errp, QERR_DEVICE_NOT_FOUND, id); + return; + } + + con = qemu_console_lookup_by_device(dev, 0); + if (con == NULL) { + error_setg(errp, "Device %s has no QemuConsole attached to it.", id); + return; + } + + graphic_hw_update(con); + surface = qemu_console_surface(con); + ppm_save(filename, surface, errp); +} + void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata) { if (!con) { -- 1.7.1