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

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