From nobody Sun Apr 28 22:43:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526570344782536.6858549498281; Thu, 17 May 2018 08:19:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2D67EEF10; Thu, 17 May 2018 15:19:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C34A1001F4C; Thu, 17 May 2018 15:19:01 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 32A874BB79; Thu, 17 May 2018 15:19:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4HFIb8M025706 for ; Thu, 17 May 2018 11:18:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id EF3E91102E17; Thu, 17 May 2018 15:18:36 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94D001102E1C for ; Thu, 17 May 2018 15:18:36 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 17 May 2018 17:18:28 +0200 Message-Id: <04dcc6e0e0e7dd243f199221a991c70f867e64e9.1526570187.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: Introduce QEMU_CAPS_SCREENDUMP_DEVICE X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 17 May 2018 15:19:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" As of v2.12.0-rc0~32^2 QEMU is capable specifying which display device and head should the screendump be taken from. Track this capability so that we can use it later in our virDomainScreenshot API. Signed-off-by: Michal Privoznik Reviewed-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 + 6 files changed, 7 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a5cb24fec6..bface72de2 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -486,6 +486,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, =20 /* 300 */ "sdl-gl", + "screendump_device", ); =20 =20 @@ -1269,6 +1270,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSc= hemaQueries[] =3D { { "blockdev-add/arg-type/+iscsi/password-secret", QEMU_CAPS_ISCSI_PASS= WORD_SECRET }, { "blockdev-add/arg-type/+qcow2/encrypt/+luks/key-secret", QEMU_CAPS_Q= COW2_LUKS }, { "nbd-server-start/arg-type/tls-creds", QEMU_CAPS_NBD_TLS }, + { "screendump/arg-type/device", QEMU_CAPS_SCREENDUMP_DEVICE }, }; =20 typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index d23c34c24d..6f9953478a 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -470,6 +470,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ =20 /* 300 */ QEMU_CAPS_SDL_GL, /* -sdl gl */ + QEMU_CAPS_SCREENDUMP_DEVICE, /* screendump command accepts device & he= ad */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml b/tests/qem= ucapabilitiesdata/caps_2.12.0.aarch64.xml index cabe4f2f07..de41d96cd0 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml @@ -162,6 +162,7 @@ + 2011090 0 343099 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemuc= apabilitiesdata/caps_2.12.0.ppc64.xml index bffe3b3b97..fc26f934ee 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml @@ -159,6 +159,7 @@ + 2011090 0 419968 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.12.0.s390x.xml index 2622d54ecd..bdfb81c998 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml @@ -127,6 +127,7 @@ + 2012000 0 371055 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.12.0.x86_64.xml index 4247afeb31..820b3ef759 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml @@ -200,6 +200,7 @@ + 2011090 0 390813 --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 22:43:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526570325102796.0822075565304; Thu, 17 May 2018 08:18:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92D5630C01F3; Thu, 17 May 2018 15:18:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51BB630012A8; Thu, 17 May 2018 15:18:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 032D3180B536; Thu, 17 May 2018 15:18:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4HFIbs6025721 for ; Thu, 17 May 2018 11:18:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8F6251102E17; Thu, 17 May 2018 15:18:37 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 353DB1102E1C for ; Thu, 17 May 2018 15:18:37 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 17 May 2018 17:18:29 +0200 Message-Id: <9a337767155b077b81bed66098672eb94e71ff06.1526570187.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] qemu: Implement multiple screen support for virDomainScreenshot X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 17 May 2018 15:18:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" According to virDomainScreenshot() documentation, screens are numbered sequentially. e.g. having two graphics cards, both with four heads, screen ID 5 addresses the second head on the second card. But apart from that, there's nothing special happening here. Signed-off-by: Michal Privoznik Reviewed-by: Jiri Denemark --- src/qemu/qemu_driver.c | 38 +++++++++++++++++++++++++++++++------- src/qemu/qemu_monitor.c | 4 +++- src/qemu/qemu_monitor.h | 2 ++ src/qemu/qemu_monitor_json.c | 4 ++++ src/qemu/qemu_monitor_json.h | 2 ++ tests/qemumonitorjsontest.c | 2 +- 6 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b697838070..e61af23870 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3999,6 +3999,8 @@ qemuDomainScreenshot(virDomainPtr dom, qemuDomainObjPrivatePtr priv; char *tmp =3D NULL; int tmp_fd =3D -1; + size_t i; + const char *videoAlias =3D NULL; char *ret =3D NULL; bool unlink_tmp =3D false; virQEMUDriverConfigPtr cfg =3D NULL; @@ -4020,13 +4022,35 @@ qemuDomainScreenshot(virDomainPtr dom, if (virDomainObjCheckActive(vm) < 0) goto endjob; =20 - /* Well, even if qemu allows multiple graphic cards, heads, whatever, - * screenshot command does not */ + if (!vm->def->nvideos) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("no screens to take screenshot from")); + goto endjob; + } + if (screen) { - virReportError(VIR_ERR_INVALID_ARG, - "%s", _("currently is supported only taking " - "screenshots of screen ID 0")); - goto endjob; + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SCREENDUMP_DEVICE)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("qemu does not allow specifying screen ID")); + goto endjob; + } + + for (i =3D 0; i < vm->def->nvideos; i++) { + const virDomainVideoDef *video =3D vm->def->videos[i]; + + if (screen < video->heads) { + videoAlias =3D video->info.alias; + break; + } + + screen -=3D video->heads; + } + + if (i =3D=3D vm->def->nvideos) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("no such screen ID")); + goto endjob; + } } =20 if (virAsprintf(&tmp, "%s/qemu.screendump.XXXXXX", cfg->cacheDir) < 0) @@ -4041,7 +4065,7 @@ qemuDomainScreenshot(virDomainPtr dom, qemuSecuritySetSavedStateLabel(driver->securityManager, vm->def, tmp); =20 qemuDomainObjEnterMonitor(driver, vm); - if (qemuMonitorScreendump(priv->mon, tmp) < 0) { + if (qemuMonitorScreendump(priv->mon, videoAlias, screen, tmp) < 0) { ignore_value(qemuDomainObjExitMonitor(driver, vm)); goto endjob; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 3d7ca3ccfc..f21bf7000d 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3477,6 +3477,8 @@ qemuMonitorSendKey(qemuMonitorPtr mon, =20 int qemuMonitorScreendump(qemuMonitorPtr mon, + const char *device, + unsigned int head, const char *file) { VIR_DEBUG("file=3D%s", file); @@ -3484,7 +3486,7 @@ qemuMonitorScreendump(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); =20 if (mon->json) - return qemuMonitorJSONScreendump(mon, file); + return qemuMonitorJSONScreendump(mon, device, head, file); else return qemuMonitorTextScreendump(mon, file); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 33dc521e83..6cba37c281 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -886,6 +886,8 @@ int qemuMonitorArbitraryCommand(qemuMonitorPtr mon, int qemuMonitorInjectNMI(qemuMonitorPtr mon); =20 int qemuMonitorScreendump(qemuMonitorPtr mon, + const char *device, + unsigned int head, const char *file); =20 int qemuMonitorSendKey(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e2e0004e4d..6dcded9369 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4483,6 +4483,8 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon, } =20 int qemuMonitorJSONScreendump(qemuMonitorPtr mon, + const char *device, + unsigned int head, const char *file) { int ret =3D -1; @@ -4490,6 +4492,8 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon, =20 cmd =3D qemuMonitorJSONMakeCommand("screendump", "s:filename", file, + "S:device", device, + "p:head", head, NULL); =20 if (!cmd) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index e86b58f7ea..8461932cac 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -296,6 +296,8 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon, unsigned int nkeycodes); =20 int qemuMonitorJSONScreendump(qemuMonitorPtr mon, + const char *device, + unsigned int head, const char *file); =20 int qemuMonitorJSONBlockStream(qemuMonitorPtr mon, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index edd57067bd..add5ff0f19 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1348,7 +1348,7 @@ GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/fo= o/bar", NULL, 1024, 0, 0, VIR_DOMAIN_BLOCK_REBASE_SHALLOW | VIR_DOMAIN_BLOCK_REBASE_RE= USE_EXT) GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "/foo/bar1", "/foo/bar2",= NULL, 1024) GEN_TEST_FUNC(qemuMonitorJSONDrivePivot, "vdb") -GEN_TEST_FUNC(qemuMonitorJSONScreendump, "/foo/bar") +GEN_TEST_FUNC(qemuMonitorJSONScreendump, NULL, 0, "/foo/bar") GEN_TEST_FUNC(qemuMonitorJSONOpenGraphics, "spice", "spicefd", false) GEN_TEST_FUNC(qemuMonitorJSONNBDServerStart, "localhost", 12345, "test-ali= as") GEN_TEST_FUNC(qemuMonitorJSONNBDServerAdd, "vda", true) --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list