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