/
nvidia_drivers_support.go
82 lines (71 loc) · 2.54 KB
/
nvidia_drivers_support.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2023 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package builtin
const nvidiaDriversSupportSummary = `NVIDIA drivers userspace system setup support`
const nvidiaDriversSupportBaseDeclarationPlugs = `
nvidia-drivers-support:
allow-installation: false
deny-auto-connection: true
`
const nvidiaDriversSupportBaseDeclarationSlots = `
nvidia-drivers-support:
allow-installation:
slot-snap-type:
- core
deny-auto-connection: true
`
const nvidiaDriversSupportConnectedPlugAppArmor = `
# This is inverse of
# https://forum.snapcraft.io/t/call-for-testing-chromium-62-0-3202-62/2569/46
# As nvidia-assemble snap needs to create the static & dynamic MAJOR
# chrdevs for all other snaps to have access to. Specifically
# /dev/nvidiactl /dev/nvidia-uvm
/{,usr/}bin/mknod ixr,
allow capability mknod,
/dev/nvidia[0-9]* rw,
/dev/nvidiactl rw,
/dev/nvidia-uvm rw,
/dev/nvidia-uvm-tools rw,
/dev/nvidia-modeset rw,
# To read dynamically allocated MAJOR for nvidia-uvm
@{PROC}/devices r,
`
const nvidiaDriversSupportConnectedPlugSecComp = `
# This is inverse of
# https://forum.snapcraft.io/t/call-for-testing-chromium-62-0-3202-62/2569/46
# As nvidia-assemble snap needs to create the static & dynamic MAJOR
# chrdevs for all other snaps to have access to. Specifically
# /dev/nvidiactl /dev/nvidia-uvm
mknod - |S_IFCHR -
mknodat - - |S_IFCHR -
`
type nvidiaDriversSupportInterface struct {
commonInterface
}
func init() {
registerIface(&nvidiaDriversSupportInterface{commonInterface: commonInterface{
name: "nvidia-drivers-support",
summary: nvidiaDriversSupportSummary,
implicitOnCore: true,
implicitOnClassic: true,
baseDeclarationPlugs: nvidiaDriversSupportBaseDeclarationPlugs,
baseDeclarationSlots: nvidiaDriversSupportBaseDeclarationSlots,
connectedPlugAppArmor: nvidiaDriversSupportConnectedPlugAppArmor,
connectedPlugSecComp: nvidiaDriversSupportConnectedPlugSecComp,
}})
}