From: Anton Mikanovich <amikan@ilbers.de>
To: isar-users@googlegroups.com
Cc: Florian Bezdeka <florian.bezdeka@siemens.com>,
Anton Mikanovich <amikan@ilbers.de>
Subject: [PATCH v3 7/8] rootfs: Add missing umounts in rootfs_postprocess() and rootfs_install()
Date: Fri, 11 Oct 2024 13:00:49 +0300 [thread overview]
Message-ID: <20241011100050.322686-8-amikan@ilbers.de> (raw)
In-Reply-To: <20241011100050.322686-1-amikan@ilbers.de>
From: Florian Bezdeka <florian.bezdeka@siemens.com>
Calls to rootfs_do_mounts should always be paired with calls to
rootfs_do_umounts. With this change, it is done in do_rootfs_install
and do_rootfs_postprocess.
In case there was an exception thrown within the try blocks they will be
re-raised after the finally block has been processed. This way we try to
avoid leaking mounts but unmounting might still fail. In any case we
tried our best to clean up.
To reproduce:
. ./isar-init-build-env newbuild
mount >01.txt
cat >conf/local.conf <<EOF
MACHINE = "qemuamd64"
DISTRO = "debian-bookworm"
DISTRO_ARCH = "amd64"
EOF
bitbake sbuild-chroot-target
mount >02.txt
diff -Naurp 01.txt 02.txt
+tmpfs on newbuild/tmp/work/debian-bookworm-amd64/sbuild-chroot-target/1.0-r0/rootfs/dev type tmpfs (rw,nosuid,size=4096k,nr_inodes=65536,mode=755,inode64)
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
meta/classes/rootfs.bbclass | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index ef40cbdf..c7011508 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -248,18 +248,21 @@ python do_rootfs_install() {
progress_reporter = bb.progress.MultiStageProgressReporter(d, stage_weights)
d.rootfs_progress = progress_reporter
- for cmd in cmds:
- progress_reporter.next_stage()
+ try:
+ for cmd in cmds:
+ progress_reporter.next_stage()
- if (d.getVarFlag(cmd, 'isar-apt-lock') or "") == "acquire-before":
- lock = bb.utils.lockfile(d.getVar("REPO_ISAR_DIR") + "/isar.lock",
- shared=True)
+ if (d.getVarFlag(cmd, 'isar-apt-lock') or "") == "acquire-before":
+ lock = bb.utils.lockfile(d.getVar("REPO_ISAR_DIR") + "/isar.lock",
+ shared=True)
- bb.build.exec_func(cmd, d)
+ bb.build.exec_func(cmd, d)
- if (d.getVarFlag(cmd, 'isar-apt-lock') or "") == "release-after":
- bb.utils.unlockfile(lock)
- progress_reporter.finish()
+ if (d.getVarFlag(cmd, 'isar-apt-lock') or "") == "release-after":
+ bb.utils.unlockfile(lock)
+ progress_reporter.finish()
+ finally:
+ bb.build.exec_func('rootfs_do_umounts', d)
}
addtask rootfs_install before do_rootfs_postprocess after do_unpack
@@ -379,9 +382,13 @@ python do_rootfs_postprocess() {
if cmds is None or not cmds.strip():
return
cmds = cmds.split()
- for i, cmd in enumerate(cmds):
- bb.build.exec_func(cmd, d)
- progress_reporter.update(int(i / len(cmds) * 100))
+
+ try:
+ for i, cmd in enumerate(cmds):
+ bb.build.exec_func(cmd, d)
+ progress_reporter.update(int(i / len(cmds) * 100))
+ finally:
+ bb.build.exec_func('rootfs_do_umounts', d)
}
addtask rootfs_postprocess before do_rootfs after do_unpack
--
2.34.1
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isar-users/20241011100050.322686-8-amikan%40ilbers.de.
next prev parent reply other threads:[~2024-10-11 10:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 10:00 [PATCH v3 0/8] Hanging mount fixes Anton Mikanovich
2024-10-11 10:00 ` [PATCH v3 1/8] CI: Do not lose output on bitbake / qemu exit Anton Mikanovich
2024-10-11 10:00 ` [PATCH v3 2/8] isar-events: Unhide mounts left behind Anton Mikanovich
2024-10-11 10:00 ` [PATCH v3 3/8] CI: Pass ISAR_FAIL_ON_CLEANUP from environment to bitbake Anton Mikanovich
2024-10-11 10:00 ` [PATCH v3 4/8] image: Avoid breaking the build when mounts are no longer present on umount Anton Mikanovich
2024-10-11 10:00 ` [PATCH v3 5/8] rootfs: Provide rootfs_do_umounts Anton Mikanovich
2024-10-11 10:00 ` [PATCH v3 6/8] initramfs: Add missing umounts after generation Anton Mikanovich
2024-10-11 10:00 ` Anton Mikanovich [this message]
2024-10-11 10:00 ` [PATCH v3 8/8] image: Do not call rootfs_do_umounts twice Anton Mikanovich
2024-10-15 9:23 ` [PATCH v3 0/8] Hanging mount fixes Baurzhan Ismagulov
2024-10-16 16:06 ` Uladzimir Bely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241011100050.322686-8-amikan@ilbers.de \
--to=amikan@ilbers.de \
--cc=florian.bezdeka@siemens.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox