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
diff --git a/lpbuildd/target/lxd.py b/lpbuildd/target/lxd.py
index fb0aad1..8800508 100644
--- a/lpbuildd/target/lxd.py
+++ b/lpbuildd/target/lxd.py
@@ -430,6 +430,8 @@ class LXD(Backend):
430 ("lxc.cgroup.devices.allow", ""),430 ("lxc.cgroup.devices.allow", ""),
431 ("lxc.mount.auto", ""),431 ("lxc.mount.auto", ""),
432 ("lxc.mount.auto", "proc:rw sys:rw"),432 ("lxc.mount.auto", "proc:rw sys:rw"),
433 ("lxc.mount.entry","udev /dev devtmpfs rw,nosuid,relatime,mode=755,inode64"),
434 ("lxc.autodev", "0"),
433 ]435 ]
434436
435 lxc_version = self._client.host_info["environment"]["driver_version"]437 lxc_version = self._client.host_info["environment"]["driver_version"]
@@ -586,26 +588,6 @@ class LXD(Backend):
586 "Container failed to start within %d seconds" % timeout588 "Container failed to start within %d seconds" % timeout
587 )589 )
588590
589 # Create loop devices. We do this by hand rather than via the LXD
590 # profile, as the latter approach creates lots of independent mounts
591 # under /dev/, and that can cause confusion when building live
592 # filesystems.
593 self.run(
594 ["mknod", "-m", "0660", "/dev/loop-control", "c", "10", "237"]
595 )
596 for minor in range(256):
597 self.run(
598 [
599 "mknod",
600 "-m",
601 "0660",
602 "/dev/loop%d" % minor,
603 "b",
604 "7",
605 str(minor),
606 ]
607 )
608
609 # Create dm-# devices. On focal kpartx looks for dm devices and hangs591 # Create dm-# devices. On focal kpartx looks for dm devices and hangs
610 # in their absence.592 # in their absence.
611 major = get_device_mapper_major()593 major = get_device_mapper_major()
diff --git a/lpbuildd/target/tests/test_lxd.py b/lpbuildd/target/tests/test_lxd.py
index 04078fa..eb3a698 100644
--- a/lpbuildd/target/tests/test_lxd.py
+++ b/lpbuildd/target/tests/test_lxd.py
@@ -309,6 +309,8 @@ class TestLXD(TestCase):
309 ("lxc.cgroup.devices.allow", ""),309 ("lxc.cgroup.devices.allow", ""),
310 ("lxc.mount.auto", ""),310 ("lxc.mount.auto", ""),
311 ("lxc.mount.auto", "proc:rw sys:rw"),311 ("lxc.mount.auto", "proc:rw sys:rw"),
312 ("lxc.mount.entry","udev /dev devtmpfs rw,nosuid,relatime,mode=755,inode64"),
313 ("lxc.autodev", "0"),
312 ]314 ]
313315
314 major, minor = (int(v) for v in driver_version.split(".")[0:2])316 major, minor = (int(v) for v in driver_version.split(".")[0:2])
@@ -589,35 +591,8 @@ class TestLXD(TestCase):
589 ),591 ),
590 Equals(["hostname"]),592 Equals(["hostname"]),
591 Equals(["hostname", "--fqdn"]),593 Equals(["hostname", "--fqdn"]),
592 Equals(
593 lxc
594 + [
595 "mknod",
596 "-m",
597 "0660",
598 "/dev/loop-control",
599 "c",
600 "10",
601 "237",
602 ]
603 ),
604 ]594 ]
605 )595 )
606 for minor in range(256):
607 expected_args.append(
608 Equals(
609 lxc
610 + [
611 "mknod",
612 "-m",
613 "0660",
614 "/dev/loop%d" % minor,
615 "b",
616 "7",
617 str(minor),
618 ]
619 )
620 )
621 for minor in range(8):596 for minor in range(8):
622 expected_args.append(597 expected_args.append(
623 Equals(598 Equals(

Subscribers

People subscribed via source and target branches