Merge ~vorlon/launchpad-buildd:devtmpfs into launchpad-buildd:master

Proposed by Steve Langasek
Status: Merged
Approved by: Colin Watson
Approved revision: 393e2cc0d6c35c2d2bb47e036b45cd367e01cac4
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~vorlon/launchpad-buildd:devtmpfs
Merge into: launchpad-buildd:master
Diff against target: 89 lines (+4/-47)
2 files modified
lpbuildd/target/lxd.py (+2/-20)
lpbuildd/target/tests/test_lxd.py (+2/-27)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+442776@code.launchpad.net

Commit message

Mount devtmpfs in the lxd container, to make losetup -P work

Description of the change

To address race conditions when using kpartx to expose partitions on loop devices, we would like to move livecd-rootfs to use `losetup -P`, which synchronously creates all of the necessary devices in the kernel without races.

The problem is that the kernel creates these device nodes on devtmpfs - which is not mounted in the container.

Since the lxd target in launchpad-buildd is already a privileged container, I propose simply mounting devtmpfs in the container as well so that the kernel-created device nodes are exposed.

This also lets us remove some other code for manually creating devices as these will be populated by default by the kernel.

I am not confident that the changes here around nvidia device creation are correct. I am assuming these devices will be created automatically on module load but I am not in a position to verify this at the moment.

The dm-* devices are *not* something that would be precreated by the kernel so I think we still need the code to mknod these.

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

NVIDIA is still special, please keep all that.

~vorlon/launchpad-buildd:devtmpfs updated
393e2cc... by Steve Langasek

Revert change to not mknod nvidia devices.

Per Dimitri, these are not handled by the kernel due to licensing
constraints, so they must be created manually in the container.

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lpbuildd/target/lxd.py b/lpbuildd/target/lxd.py
2index fb0aad1..8800508 100644
3--- a/lpbuildd/target/lxd.py
4+++ b/lpbuildd/target/lxd.py
5@@ -430,6 +430,8 @@ class LXD(Backend):
6 ("lxc.cgroup.devices.allow", ""),
7 ("lxc.mount.auto", ""),
8 ("lxc.mount.auto", "proc:rw sys:rw"),
9+ ("lxc.mount.entry","udev /dev devtmpfs rw,nosuid,relatime,mode=755,inode64"),
10+ ("lxc.autodev", "0"),
11 ]
12
13 lxc_version = self._client.host_info["environment"]["driver_version"]
14@@ -586,26 +588,6 @@ class LXD(Backend):
15 "Container failed to start within %d seconds" % timeout
16 )
17
18- # Create loop devices. We do this by hand rather than via the LXD
19- # profile, as the latter approach creates lots of independent mounts
20- # under /dev/, and that can cause confusion when building live
21- # filesystems.
22- self.run(
23- ["mknod", "-m", "0660", "/dev/loop-control", "c", "10", "237"]
24- )
25- for minor in range(256):
26- self.run(
27- [
28- "mknod",
29- "-m",
30- "0660",
31- "/dev/loop%d" % minor,
32- "b",
33- "7",
34- str(minor),
35- ]
36- )
37-
38 # Create dm-# devices. On focal kpartx looks for dm devices and hangs
39 # in their absence.
40 major = get_device_mapper_major()
41diff --git a/lpbuildd/target/tests/test_lxd.py b/lpbuildd/target/tests/test_lxd.py
42index 04078fa..eb3a698 100644
43--- a/lpbuildd/target/tests/test_lxd.py
44+++ b/lpbuildd/target/tests/test_lxd.py
45@@ -309,6 +309,8 @@ class TestLXD(TestCase):
46 ("lxc.cgroup.devices.allow", ""),
47 ("lxc.mount.auto", ""),
48 ("lxc.mount.auto", "proc:rw sys:rw"),
49+ ("lxc.mount.entry","udev /dev devtmpfs rw,nosuid,relatime,mode=755,inode64"),
50+ ("lxc.autodev", "0"),
51 ]
52
53 major, minor = (int(v) for v in driver_version.split(".")[0:2])
54@@ -589,35 +591,8 @@ class TestLXD(TestCase):
55 ),
56 Equals(["hostname"]),
57 Equals(["hostname", "--fqdn"]),
58- Equals(
59- lxc
60- + [
61- "mknod",
62- "-m",
63- "0660",
64- "/dev/loop-control",
65- "c",
66- "10",
67- "237",
68- ]
69- ),
70 ]
71 )
72- for minor in range(256):
73- expected_args.append(
74- Equals(
75- lxc
76- + [
77- "mknod",
78- "-m",
79- "0660",
80- "/dev/loop%d" % minor,
81- "b",
82- "7",
83- str(minor),
84- ]
85- )
86- )
87 for minor in range(8):
88 expected_args.append(
89 Equals(

Subscribers

People subscribed via source and target branches