dracut: initialize volatile.img partitions

Do not rely on dom0 initializing that device. Actually volatile.img
content should be none of dom0 business.

QubesOS/qubes-issues#1308
This commit is contained in:
Marek Marczykowski-Górecki 2015-10-15 02:38:04 +02:00
parent 0f954034a1
commit a30d583249
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
5 changed files with 39 additions and 2 deletions

View File

@ -11,5 +11,7 @@ check() {
install() { install() {
inst_hook pre-udev 90 $moddir/qubes_cow_setup.sh inst_hook pre-udev 90 $moddir/qubes_cow_setup.sh
inst_hook pre-pivot 50 $moddir/mount_modules.sh inst_hook pre-pivot 50 $moddir/mount_modules.sh
inst_multiple \
sfdisk \
mkswap
} }

View File

@ -18,6 +18,22 @@ if [ `cat /sys/block/xvda/ro` = 1 ] ; then
echo "Qubes: Doing COW setup for AppVM..." echo "Qubes: Doing COW setup for AppVM..."
while ! [ -e /dev/xvdc ]; do sleep 0.1; done while ! [ -e /dev/xvdc ]; do sleep 0.1; done
VOLATILE_SIZE=$(sfdisk -s /dev/xvdc)
ROOT_SIZE=$(sfdisk -s /dev/xvda) # kbytes
SWAP_SIZE=1024 # kbytes
if [ $VOLATILE_SIZE -lt $(($ROOT_SIZE + $SWAP_SIZE)) ]; then
ROOT_SIZE=$(($VOLATILE_SIZE - $SWAP_SIZE))
fi
sfdisk -q --unit B /dev/xvdc >/dev/null <<EOF
0,$SWAP_SIZE,S
,$ROOT_SIZE,L
EOF
if [ $? -ne 0 ]; then
echo "Qubes: failed to setup partitions on volatile device"
exit 1
fi
while ! [ -e /dev/xvdc1 ]; do sleep 0.1; done
mkswap /dev/xvdc1
while ! [ -e /dev/xvdc2 ]; do sleep 0.1; done while ! [ -e /dev/xvdc2 ]; do sleep 0.1; done
echo "0 `cat /sys/block/xvda/size` snapshot /dev/xvda /dev/xvdc2 N 16" | \ echo "0 `cat /sys/block/xvda/size` snapshot /dev/xvda /dev/xvdc2 N 16" | \

View File

@ -19,6 +19,22 @@ if [ `cat /sys/block/xvda/ro` = 1 ] ; then
echo "Qubes: Doing COW setup for AppVM..." echo "Qubes: Doing COW setup for AppVM..."
while ! [ -e /dev/xvdc ]; do sleep 0.1; done while ! [ -e /dev/xvdc ]; do sleep 0.1; done
VOLATILE_SIZE=$(sfdisk -s /dev/xvdc)
ROOT_SIZE=$(sfdisk -s /dev/xvda) # kbytes
SWAP_SIZE=1024 # kbytes
if [ $VOLATILE_SIZE -lt $(($ROOT_SIZE + $SWAP_SIZE)) ]; then
ROOT_SIZE=$(($VOLATILE_SIZE - $SWAP_SIZE))
fi
sfdisk -q --unit B /dev/xvdc >/dev/null <<EOF
0,$SWAP_SIZE,S
,$ROOT_SIZE,L
EOF
if [ $? -ne 0 ]; then
echo "Qubes: failed to setup partitions on volatile device"
exit 1
fi
while ! [ -e /dev/xvdc1 ]; do sleep 0.1; done
mkswap /dev/xvdc1
while ! [ -e /dev/xvdc2 ]; do sleep 0.1; done while ! [ -e /dev/xvdc2 ]; do sleep 0.1; done
echo "0 `cat /sys/block/xvda/size` snapshot /dev/xvda /dev/xvdc2 N 16" | \ echo "0 `cat /sys/block/xvda/size` snapshot /dev/xvda /dev/xvdc2 N 16" | \

View File

@ -11,4 +11,7 @@ depends() {
install() { install() {
inst $moddir/init.sh /init inst $moddir/init.sh /init
inst_multiple \
sfdisk \
mkswap
} }

View File

@ -80,7 +80,7 @@ static long u2mfn_ioctl(struct file *f, unsigned int cmd,
(current, current->mm, data, 1, 1, 0, &user_page, 0); (current, current->mm, data, 1, 1, 0, &user_page, 0);
up_read(&current->mm->mmap_sem); up_read(&current->mm->mmap_sem);
if (ret != 1) { if (ret != 1) {
printk("U2MFN_GET_MFN_FOR_PAGE: get_user_pages failed, ret=0x%x\n", ret); printk("U2MFN_GET_MFN_FOR_PAGE: get_user_pages failed, ret=0x%lx\n", ret);
return -1; return -1;
} }
kaddr = kmap(user_page); kaddr = kmap(user_page);