Blame SOURCES/0008-add-qxl_screendump-monitor-command.patch

1bdc94
From 24fd80b15ac39339607e43f9dca80f645b436557 Mon Sep 17 00:00:00 2001
4a2fec
From: Gerd Hoffmann <kraxel@redhat.com>
4a2fec
Date: Tue, 14 Mar 2017 13:21:06 +0100
4a2fec
Subject: add qxl_screendump monitor command
4a2fec
4a2fec
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
4a2fec
Message-id: <1375866764-17766-2-git-send-email-kraxel@redhat.com>
4a2fec
Patchwork-id: 53033
4a2fec
O-Subject: [RHEL-7 qemu-kvm PATCH 1/1] add qxl_screendump monitor command
4a2fec
Bugzilla: 903910
4a2fec
RH-Acked-by: Hans de Goede <hdegoede@redhat.com>
4a2fec
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
4a2fec
RH-Acked-by: Michal Novotny <minovotn@redhat.com>
4a2fec
4a2fec
This patch ports the rhel-6 specific qxl_screendump command to rhel-7.
4a2fec
qxl_screendump takes the device id as additional argument and thus can
4a2fec
be used to take screenshots from non-primary displays.
4a2fec
4a2fec
The plan to get that functionality upstream in time failed, so we go for
4a2fec
plan b and carry forward the rhel-6 specific qxl_screendump command.
4a2fec
Thanks to the major console subsystem cleanups which made it upstream
4a2fec
the implementation is (a) alot less hackier than the rhel-6 one and (b)
4a2fec
not qxl-specific any more.  Given that qxl is the only graphic device
4a2fec
which can work as secondary vga card the later is only a theoretical
4a2fec
benefit though ;)
4a2fec
4a2fec
RHEL-6 commit: 1c6074d107dff93c7c7b0edfb5da871504802946
4a2fec
4a2fec
bugzilla: #903910 - RHEL7 does not have equivalent functionality for
4a2fec
__com.redhat_qxl_screendump
4a2fec
4a2fec
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
4a2fec
(cherry picked from commit 211321c693f46d283205830c6c49b54d7250e98c)
4a2fec
1bdc94
Rebase notes (2.12.0):
1bdc94
- added prototype before definition
1bdc94
4a2fec
Rebase notes (2.9.0):
4a2fec
- documentation moved to qapi schema
4a2fec
4a2fec
Rebase notes (2.8.0):
4a2fec
- qmp-commands.hx replaced by docs/qmp-commands.txt (commit bd6092e)
4a2fec
- mhandler.cmd attribute renamed to cmd (commit 2b9e357)
4a2fec
4a2fec
Rebase notes (2.4.0):
4a2fec
- replace QERR_DEVICE_NOT_FOUND with ERROR_CLASS_DEVICE_NOT_FOUND
4a2fec
4a2fec
Merged patches (2.9.0):
4a2fec
- a3b59c0 HMP: Fix user manual typo of __com.redhat_qxl_screendump
4a2fec
4a2fec
Merged patches (2.6.0):
4a2fec
- f12846f __com.redhat_qxl_screendump: add docs
4a2fec
4a2fec
(cherry picked from commit 9ff701a5129653d6bd27c0b3cc249691cb6ce6a7)
1bdc94
(cherry picked from commit fd2ce5e462ee97f4538981f50e9bebc222fbe157)
1bdc94
(cherry picked from commit da2738aa88ba79de34abf9ce7de88920d0089fb3)
1bdc94
(cherry picked from commit 61fc62e6b6f217da00376b486c8927a5586c27b8)
1bdc94
(cherry picked from commit 4092812ff2d7a7dc7f2f62d49fa3a568ba78781f)
4a2fec
---
1bdc94
 hmp-commands.hx | 14 ++++++++++++++
1bdc94
 hmp.c           | 10 ++++++++++
1bdc94
 hmp.h           |  1 +
1bdc94
 qapi/misc.json  | 22 ++++++++++++++++++++++
1bdc94
 ui/console.c    | 25 +++++++++++++++++++++++++
1bdc94
 5 files changed, 72 insertions(+)
4a2fec
4a2fec
diff --git a/hmp-commands.hx b/hmp-commands.hx
1bdc94
index 3918831..01dcbb2 100644
4a2fec
--- a/hmp-commands.hx
4a2fec
+++ b/hmp-commands.hx
1bdc94
@@ -272,6 +272,20 @@ Save screen into PPM image @var{filename}.
4a2fec
 ETEXI
4a2fec
 
4a2fec
     {
4a2fec
+        .name       = "__com.redhat_qxl_screendump",
4a2fec
+        .args_type  = "id:s,filename:F",
4a2fec
+        .params     = "id filename",
4a2fec
+        .help       = "save screen from qxl device 'id' into PPM image 'filename'",
4a2fec
+        .cmd = hmp___com_redhat_qxl_screen_dump,
4a2fec
+    },
4a2fec
+
4a2fec
+STEXI
4a2fec
+@item __com.redhat_qxl_screendump @var{id} @var{filename}
4a2fec
+@findex __com.redhat_qxl_screendump
4a2fec
+Save screen from qxl device @var{id} into PPM image @var{filename}.
4a2fec
+ETEXI
4a2fec
+
4a2fec
+    {
4a2fec
         .name       = "logfile",
4a2fec
         .args_type  = "filename:F",
4a2fec
         .params     = "filename",
4a2fec
diff --git a/hmp.c b/hmp.c
1bdc94
index 6c92198..7a53e63 100644
4a2fec
--- a/hmp.c
4a2fec
+++ b/hmp.c
1bdc94
@@ -2160,6 +2160,16 @@ void hmp_screendump(Monitor *mon, const QDict *qdict)
4a2fec
     hmp_handle_error(mon, &err;;
4a2fec
 }
4a2fec
 
4a2fec
+void hmp___com_redhat_qxl_screen_dump(Monitor *mon, const QDict *qdict)
4a2fec
+{
4a2fec
+    const char *id = qdict_get_str(qdict, "id");
4a2fec
+    const char *filename = qdict_get_str(qdict, "filename");
4a2fec
+    Error *err = NULL;
4a2fec
+
4a2fec
+    qmp___com_redhat_qxl_screendump(id, filename, &err;;
4a2fec
+    hmp_handle_error(mon, &err;;
4a2fec
+}
4a2fec
+
4a2fec
 void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
4a2fec
 {
4a2fec
     const char *uri = qdict_get_str(qdict, "uri");
4a2fec
diff --git a/hmp.h b/hmp.h
1bdc94
index 4e2ec37..f85318c 100644
4a2fec
--- a/hmp.h
4a2fec
+++ b/hmp.h
1bdc94
@@ -97,6 +97,7 @@ void hmp_getfd(Monitor *mon, const QDict *qdict);
4a2fec
 void hmp_closefd(Monitor *mon, const QDict *qdict);
4a2fec
 void hmp_sendkey(Monitor *mon, const QDict *qdict);
4a2fec
 void hmp_screendump(Monitor *mon, const QDict *qdict);
4a2fec
+void hmp___com_redhat_qxl_screen_dump(Monitor *mon, const QDict *qdict);
4a2fec
 void hmp_nbd_server_start(Monitor *mon, const QDict *qdict);
4a2fec
 void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
1bdc94
 void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict);
1bdc94
diff --git a/qapi/misc.json b/qapi/misc.json
1bdc94
index 5636f4a..045eb7c 100644
1bdc94
--- a/qapi/misc.json
1bdc94
+++ b/qapi/misc.json
1bdc94
@@ -2445,6 +2445,28 @@
1bdc94
 { 'command': 'query-fdsets', 'returns': ['FdsetInfo'] }
4a2fec
 
4a2fec
 ##
4a2fec
+# @__com.redhat_qxl_screendump:
4a2fec
+#
4a2fec
+# Write a PPM of secondary qxl devices to a file.
4a2fec
+#
4a2fec
+# @id: qxl device id
4a2fec
+# @filename: the path of a new PPM file to store the image
4a2fec
+#
4a2fec
+# Returns: Nothing on success
4a2fec
+#
4a2fec
+# Since: never (rhel-only, not upstream)
4a2fec
+#
4a2fec
+# Example:
4a2fec
+#
4a2fec
+# -> { "execute": "__com.redhat_qxl_screendump",
4a2fec
+#      "arguments": { "id": video1", "filename": "v1.ppm" } }
4a2fec
+# <- { "return": {} }
4a2fec
+#
4a2fec
+##
4a2fec
+{ 'command': '__com.redhat_qxl_screendump', 'data': { 'id' : 'str',
4a2fec
+                                                      'filename': 'str' } }
4a2fec
+
4a2fec
+##
1bdc94
 # @TargetInfo:
4a2fec
 #
1bdc94
 # Information describing the QEMU target.
4a2fec
diff --git a/ui/console.c b/ui/console.c
1bdc94
index 3fb2f4e..73b2d3c 100644
4a2fec
--- a/ui/console.c
4a2fec
+++ b/ui/console.c
1bdc94
@@ -373,6 +373,31 @@ void qmp_screendump(const char *filename, bool has_device, const char *device,
4a2fec
     ppm_save(filename, surface, errp);
4a2fec
 }
4a2fec
 
1bdc94
+void qmp___com_redhat_qxl_screendump(const char *id, const char *filename, Error **errp);
4a2fec
+void qmp___com_redhat_qxl_screendump(const char *id, const char *filename, Error **errp)
4a2fec
+{
4a2fec
+    DeviceState *dev;
4a2fec
+    QemuConsole *con;
4a2fec
+    DisplaySurface *surface;
4a2fec
+
4a2fec
+    dev = qdev_find_recursive(sysbus_get_default(), id);
4a2fec
+    if (NULL == dev) {
4a2fec
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
4a2fec
+                  "Device '%s' not found", id);
4a2fec
+        return;
4a2fec
+    }
4a2fec
+
4a2fec
+    con = qemu_console_lookup_by_device(dev, 0);
4a2fec
+    if (con == NULL) {
4a2fec
+        error_setg(errp, "Device %s has no QemuConsole attached to it.", id);
4a2fec
+        return;
4a2fec
+    }
4a2fec
+
4a2fec
+    graphic_hw_update(con);
4a2fec
+    surface = qemu_console_surface(con);
4a2fec
+    ppm_save(filename, surface, errp);
4a2fec
+}
4a2fec
+
4a2fec
 void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata)
4a2fec
 {
4a2fec
     if (!con) {
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec