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

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