[PATCH 2/2] test/py: Wait for guestmount worker to exit after running guestunmount
Tom Rini
trini at konsulko.com
Tue Jul 6 02:58:46 CEST 2021
On Fri, Jun 04, 2021 at 10:04:46PM +0300, Alper Nebi Yasak wrote:
> Some filesystem tests are failing when their image is prepared with
> guestmount, but succeeding if loop mounts are used instead. The reason
> seems to be a race condition the guestmount(1) manual page explains:
>
> When guestunmount(1)/fusermount(1) exits, guestmount may still be
> running and cleaning up the mountpoint. The disk image will not be
> fully finalized.
>
> This means that scripts like the following have a nasty race condition:
>
> guestmount -a disk.img -i /mnt
> # copy things into /mnt
> guestunmount /mnt
> # immediately try to use 'disk.img' ** UNSAFE **
>
> The solution is to use the --pid-file option to write the guestmount
> PID to a file, then after guestunmount spin waiting for this PID to
> exit.
>
> The Python standard library has an os.waitpid() function for waiting a
> child to terminate, but it cannot wait on non-child processes. Implement
> a utility function that can do this by polling the process repeatedly
> for a given duration, optionally killing the process if it won't
> terminate on its own. Apply the suggested solution with this utility
> function, which makes the failing tests succeed again.
>
> Signed-off-by: Alper Nebi Yasak <alpernebiyasak at gmail.com>
> Reviewed-by: Simon Glass <sjg at chromium.org>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210705/10e82bed/attachment.sig>
More information about the U-Boot
mailing list