From a30d5832495c0b9367e99bd976a2b95c790ab78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 15 Oct 2015 02:38:04 +0200 Subject: [PATCH] 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 --- dracut/full/module-setup.sh | 4 +++- dracut/full/qubes_cow_setup.sh | 16 ++++++++++++++++ dracut/simple/init.sh | 16 ++++++++++++++++ dracut/simple/module-setup.sh | 3 +++ kernel-modules/u2mfn/u2mfn.c | 2 +- 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/dracut/full/module-setup.sh b/dracut/full/module-setup.sh index 6ce44bf..652fe8a 100644 --- a/dracut/full/module-setup.sh +++ b/dracut/full/module-setup.sh @@ -11,5 +11,7 @@ check() { install() { inst_hook pre-udev 90 $moddir/qubes_cow_setup.sh inst_hook pre-pivot 50 $moddir/mount_modules.sh - + inst_multiple \ + sfdisk \ + mkswap } diff --git a/dracut/full/qubes_cow_setup.sh b/dracut/full/qubes_cow_setup.sh index a86002e..2e7e8d5 100644 --- a/dracut/full/qubes_cow_setup.sh +++ b/dracut/full/qubes_cow_setup.sh @@ -18,6 +18,22 @@ if [ `cat /sys/block/xvda/ro` = 1 ] ; then echo "Qubes: Doing COW setup for AppVM..." 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 </dev/null <mm, data, 1, 1, 0, &user_page, 0); up_read(¤t->mm->mmap_sem); 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; } kaddr = kmap(user_page);