Commit 1043fa32de for strongswan.org
commit 1043fa32de7040e573976c12ac74ad49c1abd552
Author: Tobias Brunner <tobias@strongswan.org>
Date: Mon Aug 18 18:05:01 2025 +0200
testing: Add delay after qemu-nbd -c
Seems that there is a delay before the disk can be used when using newer
QEMU versions (e.g. on Debian trixie). We get errors like these:
sfdisk: cannot open /dev/nbd0: Inappropriate ioctl for device
or
mount: /srv/strongswan-testing/build/loop: special device /dev/nbd0p1 does not exist.
A sleep before the next command seems to help.
Also see [1].
[1] https://gitlab.com/qemu-project/qemu/-/issues/1413
diff --git a/testing/scripts/build-baseimage b/testing/scripts/build-baseimage
index 37dfef2d43..8221fb86aa 100755
--- a/testing/scripts/build-baseimage
+++ b/testing/scripts/build-baseimage
@@ -78,6 +78,9 @@ log_action "Connecting image to NBD device $NBDEV"
execute "qemu-nbd -c $NBDEV $BASEIMG"
do_on_exit qemu-nbd -d $NBDEV
+# wait for disk to become ready with newer QEMU versions
+sleep 1
+
log_action "Partitioning disk"
sfdisk /dev/nbd0 >>$LOGFILE 2>&1 << EOF
;
diff --git a/testing/scripts/build-certs b/testing/scripts/build-certs
index a8648033ce..04f4fc703a 100755
--- a/testing/scripts/build-certs
+++ b/testing/scripts/build-certs
@@ -22,6 +22,8 @@ mkdir -p $IMGDIR
log_action "Connecting root image to NBD device $NBDEV"
execute "qemu-nbd -c $NBDEV $ROOTIMG"
do_on_exit qemu-nbd -d $NBDEV
+# wait for disk to become ready with newer QEMU versions
+sleep 1
blockdev --rereadpt $NBDEV
log_action "Mounting $NBDPARTITION to $LOOPDIR"
diff --git a/testing/scripts/build-guestimages b/testing/scripts/build-guestimages
index ce6a0aee17..c4d87c1874 100755
--- a/testing/scripts/build-guestimages
+++ b/testing/scripts/build-guestimages
@@ -44,6 +44,8 @@ do
log_action "Creating guest image for $host"
execute "qemu-img create -b $ROOTIMG -f $IMGEXT -F $IMGEXT $IMGDIR/$host.$IMGEXT" 0
execute "qemu-nbd -c $NBDEV $IMGDIR/$host.$IMGEXT" 0
+ # wait for disk to become ready with newer QEMU versions
+ sleep 1
blockdev --rereadpt $NBDEV
execute "mount $NBDPARTITION $LOOPDIR" 0
execute "mount -t proc none $LOOPDIR/proc" 0
diff --git a/testing/scripts/build-strongswan b/testing/scripts/build-strongswan
index 23cb2a0280..8e6126ad30 100755
--- a/testing/scripts/build-strongswan
+++ b/testing/scripts/build-strongswan
@@ -115,6 +115,8 @@ case "$GUEST" in
esac
do_on_exit qemu-nbd -d $NBDEV
+# wait for disk to become ready with newer QEMU versions
+sleep 1
blockdev --rereadpt $NBDEV
log_action "Mounting $NBDPARTITION to $LOOPDIR"
diff --git a/testing/scripts/chroot b/testing/scripts/chroot
index b686abd972..c9a9dec7c8 100755
--- a/testing/scripts/chroot
+++ b/testing/scripts/chroot
@@ -42,6 +42,8 @@ root)
esac
do_on_exit qemu-nbd -d $NBDEV
+# wait for disk to become ready with newer QEMU versions
+sleep 1
blockdev --rereadpt $NBDEV
log_action "Mounting $NBDPARTITION to $LOOPDIR"