|
|
c1c534 |
From e326d80a0b1ff2606e16e6fabea8a1914a5cd1d2 Mon Sep 17 00:00:00 2001
|
|
|
c1c534 |
Message-Id: <e326d80a0b1ff2606e16e6fabea8a1914a5cd1d2@dist-git>
|
|
|
6d3351 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
6d3351 |
Date: Fri, 26 Aug 2011 16:41:17 +0800
|
|
|
6d3351 |
Subject: [PATCH] RHEL: screenshot: Implement multiple screen support
|
|
|
6d3351 |
|
|
|
6d3351 |
For https://bugzilla.redhat.com/show_bug.cgi?id=1026966
|
|
|
6d3351 |
https://bugzilla.redhat.com/show_bug.cgi?id=710489
|
|
|
6d3351 |
RHEL only, requires __com.redhat_qxl_screendump
|
|
|
6d3351 |
|
|
|
6d3351 |
As RHEL qemu supports taking screenshot of other monitors than the
|
|
|
6d3351 |
first one, we can allow libvirt to support this feature too.
|
|
|
6d3351 |
|
|
|
6d3351 |
Although this command allows screen specification via ID, there is
|
|
|
6d3351 |
not a way to assign one to the primary monitor. Therefore, we must
|
|
|
6d3351 |
stick to upstream command in case of primary monitor, and use this
|
|
|
6d3351 |
new command in other cases.
|
|
|
6d3351 |
|
|
|
6d3351 |
(cherry picked from commit 800c9b2c1e0347585213ba6895db7cf064cda21c in
|
|
|
6d3351 |
rhel-6.5 branch)
|
|
|
6d3351 |
|
|
|
6d3351 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
6d3351 |
|
|
|
6d3351 |
Conflicts:
|
|
|
6d3351 |
src/qemu/qemu_driver.c - context
|
|
|
6d3351 |
src/qemu/qemu_monitor.c - don't return -1 without reporting an
|
|
|
6d3351 |
error
|
|
|
6d3351 |
---
|
|
|
6d3351 |
src/qemu/qemu_driver.c | 22 +++++++++++++++-------
|
|
|
6d3351 |
src/qemu/qemu_monitor.c | 14 ++++++++++++--
|
|
|
6d3351 |
src/qemu/qemu_monitor.h | 3 ++-
|
|
|
6d3351 |
src/qemu/qemu_monitor_json.c | 24 ++++++++++++++++++++++++
|
|
|
6d3351 |
src/qemu/qemu_monitor_json.h | 4 ++++
|
|
|
6d3351 |
5 files changed, 57 insertions(+), 10 deletions(-)
|
|
|
6d3351 |
|
|
|
6d3351 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
c1c534 |
index 1dff53441b..82c60e6ef1 100644
|
|
|
6d3351 |
--- a/src/qemu/qemu_driver.c
|
|
|
6d3351 |
+++ b/src/qemu/qemu_driver.c
|
|
|
c1c534 |
@@ -3999,6 +3999,8 @@ qemuDomainScreenshot(virDomainPtr dom,
|
|
|
6d3351 |
char *ret = NULL;
|
|
|
6d3351 |
bool unlink_tmp = false;
|
|
|
6d3351 |
virQEMUDriverConfigPtr cfg = NULL;
|
|
|
6d3351 |
+ int video_index = 0;
|
|
|
6d3351 |
+ const char *video_id = NULL;
|
|
|
6d3351 |
|
|
|
6d3351 |
virCheckFlags(0, NULL);
|
|
|
6d3351 |
|
|
|
c1c534 |
@@ -4020,12 +4022,15 @@ qemuDomainScreenshot(virDomainPtr dom,
|
|
|
6d3351 |
goto endjob;
|
|
|
6d3351 |
}
|
|
|
6d3351 |
|
|
|
6d3351 |
- /* Well, even if qemu allows multiple graphic cards, heads, whatever,
|
|
|
6d3351 |
- * screenshot command does not */
|
|
|
6d3351 |
- if (screen) {
|
|
|
6d3351 |
- virReportError(VIR_ERR_INVALID_ARG,
|
|
|
6d3351 |
- "%s", _("currently is supported only taking "
|
|
|
6d3351 |
- "screenshots of screen ID 0"));
|
|
|
6d3351 |
+ while (video_index < vm->def->nvideos) {
|
|
|
6d3351 |
+ if (screen < vm->def->videos[video_index]->heads)
|
|
|
6d3351 |
+ break;
|
|
|
6d3351 |
+ screen -= vm->def->videos[video_index]->heads;
|
|
|
6d3351 |
+ video_index++;
|
|
|
6d3351 |
+ }
|
|
|
6d3351 |
+
|
|
|
6d3351 |
+ if (video_index == vm->def->nvideos) {
|
|
|
6d3351 |
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("no such screen"));
|
|
|
6d3351 |
goto endjob;
|
|
|
6d3351 |
}
|
|
|
6d3351 |
|
|
|
c1c534 |
@@ -4040,8 +4045,11 @@ qemuDomainScreenshot(virDomainPtr dom,
|
|
|
6d3351 |
|
|
|
6d3351 |
qemuSecuritySetSavedStateLabel(driver->securityManager, vm->def, tmp);
|
|
|
6d3351 |
|
|
|
6d3351 |
+ if (video_index)
|
|
|
6d3351 |
+ video_id = vm->def->videos[video_index]->info.alias;
|
|
|
6d3351 |
+
|
|
|
6d3351 |
qemuDomainObjEnterMonitor(driver, vm);
|
|
|
6d3351 |
- if (qemuMonitorScreendump(priv->mon, tmp) < 0) {
|
|
|
6d3351 |
+ if (qemuMonitorScreendump(priv->mon, tmp, video_id) < 0) {
|
|
|
6d3351 |
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
|
|
6d3351 |
goto endjob;
|
|
|
6d3351 |
}
|
|
|
6d3351 |
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
|
|
|
c1c534 |
index dd9d64a207..3cf23db874 100644
|
|
|
6d3351 |
--- a/src/qemu/qemu_monitor.c
|
|
|
6d3351 |
+++ b/src/qemu/qemu_monitor.c
|
|
|
c1c534 |
@@ -3461,12 +3461,22 @@ qemuMonitorSendKey(qemuMonitorPtr mon,
|
|
|
6d3351 |
|
|
|
6d3351 |
int
|
|
|
6d3351 |
qemuMonitorScreendump(qemuMonitorPtr mon,
|
|
|
6d3351 |
- const char *file)
|
|
|
6d3351 |
+ const char *file,
|
|
|
6d3351 |
+ const char *id)
|
|
|
6d3351 |
{
|
|
|
6d3351 |
- VIR_DEBUG("file=%s", file);
|
|
|
6d3351 |
+ VIR_DEBUG("file=%s, id=%s", file, id);
|
|
|
6d3351 |
|
|
|
6d3351 |
QEMU_CHECK_MONITOR(mon);
|
|
|
6d3351 |
|
|
|
6d3351 |
+ if (id) {
|
|
|
6d3351 |
+ if (!mon->json) {
|
|
|
6d3351 |
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
|
6d3351 |
+ _("non-zero screen ID requires JSON monitor"));
|
|
|
6d3351 |
+ return -1;
|
|
|
6d3351 |
+ }
|
|
|
6d3351 |
+ return qemuMonitorJSONScreendumpRH(mon, file, id);
|
|
|
6d3351 |
+ }
|
|
|
6d3351 |
+
|
|
|
6d3351 |
if (mon->json)
|
|
|
6d3351 |
return qemuMonitorJSONScreendump(mon, file);
|
|
|
6d3351 |
else
|
|
|
6d3351 |
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
|
|
|
c1c534 |
index bc8494faee..7e20e96116 100644
|
|
|
6d3351 |
--- a/src/qemu/qemu_monitor.h
|
|
|
6d3351 |
+++ b/src/qemu/qemu_monitor.h
|
|
|
c1c534 |
@@ -888,7 +888,8 @@ int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
|
|
|
6d3351 |
int qemuMonitorInjectNMI(qemuMonitorPtr mon);
|
|
|
6d3351 |
|
|
|
6d3351 |
int qemuMonitorScreendump(qemuMonitorPtr mon,
|
|
|
6d3351 |
- const char *file);
|
|
|
6d3351 |
+ const char *file,
|
|
|
6d3351 |
+ const char *id);
|
|
|
6d3351 |
|
|
|
6d3351 |
int qemuMonitorSendKey(qemuMonitorPtr mon,
|
|
|
6d3351 |
unsigned int holdtime,
|
|
|
6d3351 |
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
|
|
|
c1c534 |
index 05cc634d20..8a75e0ef7e 100644
|
|
|
6d3351 |
--- a/src/qemu/qemu_monitor_json.c
|
|
|
6d3351 |
+++ b/src/qemu/qemu_monitor_json.c
|
|
|
c1c534 |
@@ -4294,6 +4294,30 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
|
|
|
6d3351 |
return ret;
|
|
|
6d3351 |
}
|
|
|
6d3351 |
|
|
|
6d3351 |
+int qemuMonitorJSONScreendumpRH(qemuMonitorPtr mon,
|
|
|
6d3351 |
+ const char *file,
|
|
|
6d3351 |
+ const char *id)
|
|
|
6d3351 |
+{
|
|
|
6d3351 |
+ int ret = -1;
|
|
|
6d3351 |
+ virJSONValuePtr cmd, reply = NULL;
|
|
|
6d3351 |
+
|
|
|
6d3351 |
+ cmd = qemuMonitorJSONMakeCommand("__com.redhat_qxl_screendump",
|
|
|
6d3351 |
+ "s:filename", file,
|
|
|
6d3351 |
+ "s:id", id,
|
|
|
6d3351 |
+ NULL);
|
|
|
6d3351 |
+ if (!cmd)
|
|
|
6d3351 |
+ return -1;
|
|
|
6d3351 |
+
|
|
|
6d3351 |
+ ret = qemuMonitorJSONCommand(mon, cmd, &reply);
|
|
|
6d3351 |
+
|
|
|
6d3351 |
+ if (ret == 0)
|
|
|
6d3351 |
+ ret = qemuMonitorJSONCheckError(cmd, reply);
|
|
|
6d3351 |
+
|
|
|
6d3351 |
+ virJSONValueFree(cmd);
|
|
|
6d3351 |
+ virJSONValueFree(reply);
|
|
|
6d3351 |
+ return ret;
|
|
|
6d3351 |
+}
|
|
|
6d3351 |
+
|
|
|
6d3351 |
int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
|
|
|
6d3351 |
const char *file)
|
|
|
6d3351 |
{
|
|
|
6d3351 |
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
|
|
|
c1c534 |
index 739a99293c..02a504ab85 100644
|
|
|
6d3351 |
--- a/src/qemu/qemu_monitor_json.h
|
|
|
6d3351 |
+++ b/src/qemu/qemu_monitor_json.h
|
|
|
c1c534 |
@@ -292,6 +292,10 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
|
|
|
6d3351 |
unsigned int *keycodes,
|
|
|
6d3351 |
unsigned int nkeycodes);
|
|
|
6d3351 |
|
|
|
6d3351 |
+int qemuMonitorJSONScreendumpRH(qemuMonitorPtr mon,
|
|
|
6d3351 |
+ const char *file,
|
|
|
6d3351 |
+ const char *id);
|
|
|
6d3351 |
+
|
|
|
6d3351 |
int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
|
|
|
6d3351 |
const char *file);
|
|
|
6d3351 |
|
|
|
6d3351 |
--
|
|
|
c1c534 |
2.14.3
|
|
|
6d3351 |
|