parallels-with-bitmap.sh (1504B)
1 #!/bin/bash 2 # 3 # Test parallels load bitmap 4 # 5 # Copyright (c) 2021 Virtuozzo International GmbH. 6 # 7 # This program is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # This program is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 19 # 20 21 CT=parallels-with-bitmap-ct 22 DIR=$PWD/parallels-with-bitmap-dir 23 IMG=$DIR/root.hds 24 XML=$DIR/DiskDescriptor.xml 25 TARGET=parallels-with-bitmap.bz2 26 27 rm -rf $DIR 28 29 prlctl create $CT --vmtype ct 30 prlctl set $CT --device-add hdd --image $DIR --recreate --size 2G 31 32 # cleanup the image 33 qemu-img create -f parallels $IMG 64G 34 35 # create bitmap 36 prlctl backup $CT 37 38 prlctl set $CT --device-del hdd1 39 prlctl destroy $CT 40 41 dev=$(ploop mount $XML | sed -n 's/^Adding delta dev=\(\/dev\/ploop[0-9]\+\).*/\1/p') 42 dd if=/dev/zero of=$dev bs=64K seek=5 count=2 oflag=direct 43 dd if=/dev/zero of=$dev bs=64K seek=30 count=1 oflag=direct 44 dd if=/dev/zero of=$dev bs=64K seek=10 count=3 oflag=direct 45 ploop umount $XML # bitmap name will be in the output 46 47 bzip2 -z $IMG 48 49 mv $IMG.bz2 $TARGET 50 51 rm -rf $DIR