Merge lp:~mvo/snap-confine/auto-bind-mount-nvidia into lp:~snappy-dev/snap-confine/trunk

Proposed by Michael Vogt
Status: Needs review
Proposed branch: lp:~mvo/snap-confine/auto-bind-mount-nvidia
Merge into: lp:~snappy-dev/snap-confine/trunk
Diff against target: 67 lines (+34/-1)
2 files modified
debian/usr.bin.ubuntu-core-launcher (+5/-0)
src/main.c (+29/-1)
To merge this branch: bzr merge lp:~mvo/snap-confine/auto-bind-mount-nvidia
Reviewer Review Type Date Requested Status
Jamie Strandboge (community) Disapprove
Review via email: mp+291983@code.launchpad.net

Description of the change

This branch adds more magic to the ubuntu-core-launcher, this time to make automatic mounting of the nvidia libgl dir work.

However we do not have to do it this way, we could modify all of the nvidia-* drivers to ship a systemd mount unit file that does this mounting. In terms of getting stuff into the release this looks more risky though.

To post a comment you must log in.
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

I didn't do a code review, but I think I prefer the systemd mount approach for a few reasons:

1. added more code to a setuid launcher is not ideal. This thing is already quite large
2. the launcher would need to be updated for other non-nvidia drivers
3. the launcher needs to be updated if the nvidia packaging changes. This issue is aggravated when considering LTS backports where the launcher may need to be part of the backports stack if something changes in later releases

The nice thing about the systemd approach is this systemd unit can be shipped by the packages that are in control of where the files are (ie, the nvidia drivers packages). In this way, all the paths are maintained within one package.

review: Disapprove

Unmerged revisions

129. By Michael Vogt

add auto bind mount of the nvidia libgl dir

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/usr.bin.ubuntu-core-launcher'
2--- debian/usr.bin.ubuntu-core-launcher 2016-04-14 22:21:13 +0000
3+++ debian/usr.bin.ubuntu-core-launcher 2016-04-15 09:20:59 +0000
4@@ -87,6 +87,11 @@
5 mount options=(rw bind) /snap/ubuntu-core*/*/lib64/ -> /lib64/,
6 mount options=(rw bind) /snap/ubuntu-core*/*/usr/ -> /usr/,
7
8+ # nvidia handling, glob needs /usr/** and the launcher must be
9+ # able to bind mount the nvidia dir
10+ /usr/** r,
11+ mount options=(rw bind) /usr/lib/nvidia-*/ -> /var/lib/snapd/lib/gl/,
12+
13 # for creating the user data directories: ~/snap, ~/snap/<name> and
14 # ~/snap/<name>/<version>
15 / r,
16
17=== modified file 'src/main.c'
18--- src/main.c 2016-04-15 06:46:03 +0000
19+++ src/main.c 2016-04-15 09:20:59 +0000
20@@ -339,11 +339,37 @@
21 }
22 }
23
24+void setup_snappy_nvidia_mounts()
25+{
26+ debug("%s", __func__);
27+
28+ // FIXME: this assume we only have nvidia the driver has a version
29+ // range from [100,999]
30+ glob_t glob_res;
31+ int res = glob("/usr/lib/nvidia-[0-9][0-9][0-9]/", 0, NULL, &glob_res);
32+ // not an nvidia system
33+ if (res != 0)
34+ return;
35+ if (glob_res.gl_pathc != 1) {
36+ globfree(&glob_res);
37+ return;
38+ }
39+ char *src = glob_res.gl_pathv[0];
40+ const char *dst = "/var/lib/snapd/lib/gl";
41+
42+ debug("nvidia mounting %s -> %s\n", src, dst);
43+ if (mount(src, dst, NULL, MS_BIND, NULL) != 0) {
44+ die("unable to bind %s to %s", src, dst);
45+ }
46+
47+ globfree(&glob_res);
48+}
49+
50 void setup_snappy_os_mounts()
51 {
52 debug("%s", __func__);
53
54- // FIXME: hardcoded "ubuntu-core.*"
55+ // FIXME: hardcoded "ubuntu-core*"
56 glob_t glob_res;
57 if (glob("/snap/ubuntu-core*/current/", 0, NULL, &glob_res) != 0) {
58 die("can not find a snappy os");
59@@ -522,6 +548,8 @@
60
61 // do the mounting if run on a non-native snappy system
62 if (is_running_on_classic_ubuntu()) {
63+ // nvidia must run before the OS mount
64+ setup_snappy_nvidia_mounts();
65 setup_snappy_os_mounts();
66 }
67 // set up private mounts

Subscribers

People subscribed via source and target branches