From dadcfc334d57727efac87dbf8c1719cede56f2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 15 May 2015 02:41:18 +0200 Subject: [PATCH] dispvm: set 'memory' to the size reported on savefile generation That parameter will be used later to request memory from qmemman just before loading savefile to memory, so it should match the real need. Do not allow values smaller than 400, to prevent storing some erroneous values. Fixes qubesos/qubes-issues#973 --- dispvm/qubes-prepare-saved-domain.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dispvm/qubes-prepare-saved-domain.sh b/dispvm/qubes-prepare-saved-domain.sh index a50da278..802621f9 100755 --- a/dispvm/qubes-prepare-saved-domain.sh +++ b/dispvm/qubes-prepare-saved-domain.sh @@ -58,6 +58,15 @@ if ! virsh -c xen:/// save $1 $2; then exit 1 fi rm -f $QMEMMAN_STOP +# Do not allow smaller allocation than 400MB. If that small number comes from +# an error, it would prevent further savefile regeneration (because VM would +# not start with too little memory). Also 'maxmem' depends on 'memory', so +# 400MB is sane compromise. +if [ "$MEM" -lt 409600 ]; then + qvm-prefs -s $1 memory 400 +else + qvm-prefs -s $1 memory $[ $MEM / 1024 ] +fi ln -snf $VMDIR /var/lib/qubes/dvmdata/vmdir cd $VMDIR bsdtar -cSf saved-cows.tar volatile.img