From nobody Sun May 5 20:16:21 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=fail(p=none dis=none) header.from=codethink.co.uk Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525202589564986.2142093233158; Tue, 1 May 2018 12:23:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8268430023F0; Tue, 1 May 2018 19:23:06 +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 962AC5D756; Tue, 1 May 2018 19:23:04 +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 5EA504CAA8; Tue, 1 May 2018 19:23:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w41JMxYS025220 for ; Tue, 1 May 2018 15:22:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id D0DDD341E4; Tue, 1 May 2018 19:22:59 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7AB12E174 for ; Tue, 1 May 2018 19:22:57 +0000 (UTC) Received: from imap1.codethink.co.uk (imap1.codethink.co.uk [176.9.8.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C3723003A45 for ; Tue, 1 May 2018 19:22:55 +0000 (UTC) Received: from 167-98-27-229.cust-167.exponential-e.net ([167.98.27.229] helo=ct-lt-931.codethink.co.uk) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1fDarV-0004LB-QK; Tue, 01 May 2018 20:22:53 +0100 From: Maciej Wolny To: libvir-list@redhat.com Date: Tue, 1 May 2018 20:22:45 +0100 Message-Id: <20180501192245.19952-1-maciej.wolny@codethink.co.uk> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 01 May 2018 19:22:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 01 May 2018 19:22:56 +0000 (UTC) for IP:'176.9.8.82' DOMAIN:'imap1.codethink.co.uk' HELO:'imap1.codethink.co.uk' FROM:'maciej.wolny@codethink.co.uk' RCPT:'' X-RedHat-Spam-Score: -0.011 (RCVD_IN_DNSWL_NONE, SPF_PASS) 176.9.8.82 imap1.codethink.co.uk 176.9.8.82 imap1.codethink.co.uk X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Maciej Wolny Subject: [libvirt] [PATCH] qemu: add sdl opengl support 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.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 01 May 2018 19:23:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add SDL graphics gl attribute, modify the domain XML schema, add a test, modify the documentation to include the new option. Signed-off-by: Maciej Wolny --- docs/schemas/domaincommon.rng | 8 +++++ src/conf/domain_conf.c | 41 ++++++++++++++++++= ++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 19 ++++++++++ .../qemuxml2argvdata/video-virtio-gpu-sdl-gl.args | 28 +++++++++++++++ tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml | 38 ++++++++++++++++++= ++ tests/qemuxml2argvtest.c | 5 +++ 9 files changed, 143 insertions(+) create mode 100644 tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args create mode 100644 tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 3569b9212..a2ef93c09 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3031,6 +3031,14 @@ + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b0257068d..7d65ca9df 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13448,6 +13448,7 @@ static int virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def, xmlNodePtr node) { + xmlNodePtr cur; char *fullscreen =3D virXMLPropString(node, "fullscreen"); int ret =3D -1; =20 @@ -13468,6 +13469,34 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsD= efPtr def, def->data.sdl.xauth =3D virXMLPropString(node, "xauth"); def->data.sdl.display =3D virXMLPropString(node, "display"); =20 + cur =3D node->children; + while (cur !=3D NULL) { + if (cur->type =3D=3D XML_ELEMENT_NODE) { + if (virXMLNodeNameEqual(cur, "gl")) { + char *enable =3D virXMLPropString(cur, "enable"); + int enableVal; + + if (!enable) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("sdl gl element missing enable")); + goto cleanup; + } + + enableVal =3D virTristateBoolTypeFromString(enable); + if (enableVal < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown enable value '%s'"), enable); + VIR_FREE(enable); + goto cleanup; + } + VIR_FREE(enable); + + def->data.sdl.gl =3D enableVal; + } + } + cur =3D cur->next; + } + ret =3D 0; cleanup: VIR_FREE(fullscreen); @@ -25652,6 +25681,18 @@ virDomainGraphicsDefFormat(virBufferPtr buf, if (def->data.sdl.fullscreen) virBufferAddLit(buf, " fullscreen=3D'yes'"); =20 + if (!children && def->data.sdl.gl) { + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + children =3D true; + } + + if (def->data.sdl.gl) { + virBufferAsprintf(buf, "data.sdl.gl= )); + virBufferAddLit(buf, "/>\n"); + } + break; =20 case VIR_DOMAIN_GRAPHICS_TYPE_RDP: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3c7eccb8c..90071d9c0 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1601,6 +1601,7 @@ struct _virDomainGraphicsDef { char *display; char *xauth; bool fullscreen; + virTristateBool gl; } sdl; struct { int port; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index aa8d350f5..02680502e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -474,6 +474,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "query-cpus-fast", "disk-write-cache", "nbd-tls", + "sdl-gl", ); =20 =20 @@ -2451,6 +2452,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCaps= CommandLine[] =3D { { "vnc", "vnc", QEMU_CAPS_VNC_MULTI_SERVERS }, { "chardev", "reconnect", QEMU_CAPS_CHARDEV_RECONNECT }, { "sandbox", "elevateprivileges", QEMU_CAPS_SECCOMP_BLACKLIST }, + { "sdl", "gl", QEMU_CAPS_SDL_GL }, }; =20 static int diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 2afe7ef58..e36611e2a 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -458,6 +458,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_QUERY_CPUS_FAST, /* query-cpus-fast command */ QEMU_CAPS_DISK_WRITE_CACHE, /* qemu block frontends support write-cach= e param */ QEMU_CAPS_NBD_TLS, /* NBD server supports TLS transport */ + QEMU_CAPS_SDL_GL, /* -sdl gl */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 418729b98..29214e806 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7988,6 +7988,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr c= fg, virQEMUCapsPtr qemuCaps, virDomainGraphicsDefPtr graphics) { + virBuffer opt =3D VIR_BUFFER_INITIALIZER; switch (graphics->type) { case VIR_DOMAIN_GRAPHICS_TYPE_SDL: if (graphics->data.sdl.xauth) @@ -8009,6 +8010,24 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr = cfg, * default, since the default changes :-( */ virCommandAddArg(cmd, "-sdl"); =20 + if (graphics->data.sdl.gl =3D=3D VIR_TRISTATE_BOOL_YES) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL_GL)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support SDL OpenGL")); + return -1; + + } + + virBufferAsprintf(&opt, "gl=3D%s", + virTristateSwitchTypeToString(graphics->data= .sdl.gl)); + } + + { + const char *optContent =3D virBufferCurrentContent(&opt); + if (optContent && STRNEQ(optContent, "")) + virCommandAddArgBuffer(cmd, &opt); + } + break; =20 case VIR_DOMAIN_GRAPHICS_TYPE_VNC: diff --git a/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args b/tests/qe= muxml2argvdata/video-virtio-gpu-sdl-gl.args new file mode 100644 index 000000000..4172320ed --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args @@ -0,0 +1,28 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +/usr/bin/qemu-system-i686 \ +-name QEMUGuest1 \ +-S \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 1024 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=3D/var/lib/libvirt/images/QEMUGuest1,format=3Dqcow2,if=3Dnone,\ +id=3Ddrive-ide0-0-0,cache=3Dnone \ +-device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ +-sdl gl=3Don \ +-device virtio-gpu-pci,id=3Dvideo0,virgl=3Don,bus=3Dpci.0,addr=3D0x2 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml b/tests/qem= uxml2argvdata/video-virtio-gpu-sdl-gl.xml new file mode 100644 index 000000000..9dea73fbe --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml @@ -0,0 +1,38 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5b3bd4a99..0b06699f0 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1924,6 +1924,11 @@ mymain(void) QEMU_CAPS_SPICE_GL, QEMU_CAPS_SPICE_RENDERNODE, QEMU_CAPS_DEVICE_VIDEO_PRIMARY); + DO_TEST("video-virtio-gpu-sdl-gl", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_VIRGL, + QEMU_CAPS_SDL_GL, + QEMU_CAPS_DEVICE_VIDEO_PRIMARY); DO_TEST("video-virtio-gpu-secondary", QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_VIDEO_PRIMARY); --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list