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

4a2fec
From fd2ce5e462ee97f4538981f50e9bebc222fbe157 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
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)
4a2fec
---
4a2fec
 hmp-commands.hx  | 14 ++++++++++++++
4a2fec
 hmp.c            | 10 ++++++++++
4a2fec
 hmp.h            |  1 +
4a2fec
 qapi-schema.json | 22 ++++++++++++++++++++++
4a2fec
 ui/console.c     | 24 ++++++++++++++++++++++++
4a2fec
 5 files changed, 71 insertions(+)
4a2fec
4a2fec
diff --git a/hmp-commands.hx b/hmp-commands.hx
4a2fec
index 2d137a1..cb00a3e 100644
4a2fec
--- a/hmp-commands.hx
4a2fec
+++ b/hmp-commands.hx
4a2fec
@@ -270,6 +270,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
4a2fec
index ab985c6..5b6eeba 100644
4a2fec
--- a/hmp.c
4a2fec
+++ b/hmp.c
4a2fec
@@ -2145,6 +2145,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
4a2fec
index 1ff4552..8d9cb29 100644
4a2fec
--- a/hmp.h
4a2fec
+++ b/hmp.h
4a2fec
@@ -98,6 +98,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);
4a2fec
 void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
4a2fec
diff --git a/qapi-schema.json b/qapi-schema.json
4a2fec
index 802ea53..0591d9d 100644
4a2fec
--- a/qapi-schema.json
4a2fec
+++ b/qapi-schema.json
4a2fec
@@ -4968,6 +4968,28 @@
4a2fec
                                        '*logappend': 'bool' } }
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
+##
4a2fec
 # @ChardevFile:
4a2fec
 #
4a2fec
 # Configuration info for file chardevs.
4a2fec
diff --git a/ui/console.c b/ui/console.c
4a2fec
index d2d3534..2616f9c 100644
4a2fec
--- a/ui/console.c
4a2fec
+++ b/ui/console.c
4a2fec
@@ -357,6 +357,30 @@ void qmp_screendump(const char *filename, Error **errp)
4a2fec
     ppm_save(filename, surface, errp);
4a2fec
 }
4a2fec
 
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