The fix that I've applied is to add the '2.5' to the list below.
1.) qemu-nbd --format=raw --connect $DEV $FILE
2.) wait until a 'pid' file appears in /sys/block/$BNAME/pid)
2.5) run 'blockdev --rereadpt' and 'udevadm settle'
3.) wait until $PART_PATH exists
4.) mount $PART_PATH to MOUNTPOINT
5.) execute user code that operates on on MOUNTPOINT
6.) umount MOUNTPOINT (and anything under it)
7.) qemu-disconnect --disconnect $DEV
note that 'udevadm settle' is not entirely unlike 'sleep 1', but if you call blockdev --rereadpt, then you do need to settle afterward.
The fix that I've applied is to add the '2.5' to the list below.
1.) qemu-nbd --format=raw --connect $DEV $FILE $BNAME/ pid)
2.) wait until a 'pid' file appears in /sys/block/
2.5) run 'blockdev --rereadpt' and 'udevadm settle'
3.) wait until $PART_PATH exists
4.) mount $PART_PATH to MOUNTPOINT
5.) execute user code that operates on on MOUNTPOINT
6.) umount MOUNTPOINT (and anything under it)
7.) qemu-disconnect --disconnect $DEV
note that 'udevadm settle' is not entirely unlike 'sleep 1', but if you call blockdev --rereadpt, then you do need to settle afterward.