From nobody Thu May 2 23:54:50 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=canonical.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1547570097029649.6449487906409; Tue, 15 Jan 2019 08:34:57 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6F4B83F44; Tue, 15 Jan 2019 16:34:54 +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 6049360C44; Tue, 15 Jan 2019 16:34:54 +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 E4B193F60F; Tue, 15 Jan 2019 16:34:53 +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 x0FGYrEw009179 for ; Tue, 15 Jan 2019 11:34:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1581919748; Tue, 15 Jan 2019 16:34:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF3DE194A8; Tue, 15 Jan 2019 16:34:50 +0000 (UTC) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 42750C049589; Tue, 15 Jan 2019 16:34:49 +0000 (UTC) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gjRfr-0005zs-8g; Tue, 15 Jan 2019 16:34:47 +0000 From: Christian Ehrhardt To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 18:34:41 +0200 Message-Id: <20190115163441.31572-1-christian.ehrhardt@canonical.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 15 Jan 2019 16:34:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 15 Jan 2019 16:34:49 +0000 (UTC) for IP:'91.189.89.112' DOMAIN:'youngberry.canonical.com' HELO:'youngberry.canonical.com' FROM:'christian.ehrhardt@canonical.com' RCPT:'' X-RedHat-Spam-Score: -5 (RCVD_IN_DNSWL_HI) 91.189.89.112 youngberry.canonical.com 91.189.89.112 youngberry.canonical.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Jamie Strandboge , =?UTF-8?q?Guido=20G=C3=BCnther?= , christian.ehrhardt@canonical.com, Erik Skultety Subject: [libvirt] [PATCH] virt-aa-helper: generate rules for gl enabled graphics devices 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 15 Jan 2019 16:34:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This adds the virt-aa-helper support for gl enabled graphics devices to generate rules for the needed rendernode paths. Example in domain xml: results in: "/dev/dri" r, "/dev/dri/bar" rw, Special cases are: - multiple devices with rendernodes -> all are added - non explicit rendernodes -> follow recently added virHostGetDRMRenderNode - rendernode without opengl (in egl-headless for example) -> still add the node Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1757085 Signed-off-by: Christian Ehrhardt --- src/security/virt-aa-helper.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 64a425671d..327a8a0202 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -938,7 +938,7 @@ get_files(vahControl * ctl) size_t i; char *uuid; char uuidstr[VIR_UUID_STRING_BUFLEN]; - bool needsVfio =3D false, needsvhost =3D false; + bool needsVfio =3D false, needsvhost =3D false, needDefaultRenderNode = =3D false; =20 /* verify uuid is same as what we were given on the command line */ virUUIDFormat(ctl->def->uuid, uuidstr); @@ -1062,6 +1062,10 @@ get_files(vahControl * ctl) for (i =3D 0; i < ctl->def->ngraphics; i++) { virDomainGraphicsDefPtr graphics =3D ctl->def->graphics[i]; size_t n; + const char *rendernode =3D virDomainGraphicsGetRenderNode(graphics= ); + + if (rendernode) + vah_add_file(&buf, rendernode, "rw"); =20 for (n =3D 0; n < graphics->nListens; n++) { virDomainGraphicsListenDef listenObj =3D graphics->listens[n]; @@ -1071,6 +1075,20 @@ get_files(vahControl * ctl) vah_add_file(&buf, listenObj.socket, "rw")) goto cleanup; } + + if (graphics->data.spice.gl =3D=3D VIR_TRISTATE_BOOL_YES) { + if (!rendernode) + needDefaultRenderNode =3D true; + } + } + + if (virDomainGraphicsDefHasOpenGL(ctl->def)) + vah_add_file(&buf, "/dev/dri", "r"); + + if (needDefaultRenderNode) { + const char *rendernode =3D virHostGetDRMRenderNode(); + if (rendernode) + vah_add_file(&buf, virHostGetDRMRenderNode(), "rw"); } =20 if (ctl->def->ngraphics =3D=3D 1 && --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list