fix VM autostart race condition

https://github.com/QubesOS/qubes-issues/issues/1075
This commit is contained in:
Patrick Schleizer 2015-07-30 17:46:24 +02:00
parent 39379364c7
commit 472ed54e4c

View File

@ -27,8 +27,11 @@ sfdisk --no-reread -u M "$FILENAME" > /dev/null 2> /dev/null <<EOF
,${ROOT_SIZE},L ,${ROOT_SIZE},L
EOF EOF
(
flock 200
loopdev=`losetup -f --show --partscan "$FILENAME"` loopdev=`losetup -f --show --partscan "$FILENAME"`
udevadm settle udevadm settle
mkswap -f ${loopdev}p1 > /dev/null mkswap -f ${loopdev}p1 > /dev/null
losetup -d ${loopdev} || : losetup -d ${loopdev} || :
chown --reference `dirname "$FILENAME"` "$FILENAME" chown --reference `dirname "$FILENAME"` "$FILENAME"
) 200>"/var/run/qubes/prepare-volatile-img.lock"