From nobody Fri May 3 06:59:47 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 1548153081061536.0594528665508; Tue, 22 Jan 2019 02:31:21 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 132E7E3E06; Tue, 22 Jan 2019 10:31:18 +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 5C0911C95B; Tue, 22 Jan 2019 10:31:15 +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 B61E21803394; Tue, 22 Jan 2019 10:31:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0MAV9KC001972 for ; Tue, 22 Jan 2019 05:31:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9EFC762526; Tue, 22 Jan 2019 10:31:09 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7231662C8; Tue, 22 Jan 2019 10:31:05 +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 10A5BA42A1; Tue, 22 Jan 2019 10:30:55 +0000 (UTC) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gltKX-000181-2m; Tue, 22 Jan 2019 10:30:53 +0000 From: Christian Ehrhardt To: libvir-list@redhat.com Date: Tue, 22 Jan 2019 11:30:50 +0100 Message-Id: <20190122103050.13526-1-christian.ehrhardt@canonical.com> In-Reply-To: <= References: <= 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.28]); Tue, 22 Jan 2019 10:30:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 22 Jan 2019 10:30:55 +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.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Guido=20G=C3=BCnther?= , Christian Ehrhardt , Erik Skultety Subject: [libvirt] [PATCH v2] 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 22 Jan 2019 10:31:19 +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/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 Updates in V2: - avoid leaking rendernode - logically group patch hunks - drop base /dev/dri access - simplify detection of the need for a default rendernode - add tests in tests/virt-aa-helper-test - rebased to recent master Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1757085 Signed-off-by: Christian Ehrhardt Reviewed-by: Erik Skultety --- src/security/virt-aa-helper.c | 12 ++++++++++++ tests/virt-aa-helper-test | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 64a425671d..a84dd5a8c9 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1062,6 +1062,18 @@ 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"); + else + if (virDomainGraphicsNeedsAutoRenderNode(graphics)) { + char * defaultRenderNode =3D virHostGetDRMRenderNode(); + if (defaultRenderNode) { + vah_add_file(&buf, defaultRenderNode, "rw"); + VIR_FREE(defaultRenderNode); + } + } =20 for (n =3D 0; n < graphics->nListens; n++) { virDomainGraphicsListenDef listenObj =3D graphics->listens[n]; diff --git a/tests/virt-aa-helper-test b/tests/virt-aa-helper-test index fb400574dc..6e674bfe5c 100755 --- a/tests/virt-aa-helper-test +++ b/tests/virt-aa-helper-test @@ -378,6 +378,12 @@ testme "0" "input dev passthrough" "-r -u $valid_uuid"= "$test_xml" "$disk2.*rw,$ sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,524= 288,1048576,g" -e "s,,$disk25242= 880,g" "$template_xml" > "$= test_xml" testme "0" "nvdimm" "-r -u $valid_uuid" "$test_xml" "$disk2.*rw,$" =20 +sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,= ,g" "$template_xml" > "$test_xml" +testme "0" "dri egl" "-r -u $valid_uuid" "$test_xml" "/dev/dri/testegl1.*r= w,$" + +sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,= ,g" "$template_xml" > "$test_xml" +testme "0" "dri spice" "-r -u $valid_uuid" "$test_xml" "/dev/dri/testegl2.= *rw,$" + testme "0" "help" "-h" =20 echo "" >$output --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list