qmrestore alloc_size calculation bug

ib.pl

New Member
Apr 14, 2011
18
0
1
Hi,

After restoring VM from PVE2.1 backup with one 3GB virtual disk (exactly 3221225472 bytes = 3GB) we ended with VM having bigger LV than should be (3GB + 1 physical extend = 4GB in our case because in this scenario there was PE size = 1GB).

Tested in the following environment:

# pveversion --verbose
pve-manager: 2.1-14 (pve-manager/2.1/f32f3f46)
running kernel: 2.6.32-14-pve
proxmox-ve-2.6.32: 2.1-74
pve-kernel-2.6.32-11-pve: 2.6.32-66
pve-kernel-2.6.32-14-pve: 2.6.32-74
lvm2: 2.02.95-1pve2
clvm: 2.02.95-1pve2
corosync-pve: 1.4.3-1
openais-pve: 1.1.4-2
libqb: 0.10.1-2
redhat-cluster-pve: 3.1.92-3
resource-agents-pve: 3.9.2-3
fence-agents-pve: 3.1.8-1
pve-cluster: 1.0-27
qemu-server: 2.0-49
pve-firmware: 1.0-18
libpve-common-perl: 1.0-30
libpve-access-control: 1.0-24
libpve-storage-perl: 2.0-31
vncterm: 1.0-3
vzctl: 3.0.30-2pve5
vzprocps: 2.0.11-2
vzquota: 3.0.12-3
pve-qemu-kvm: 1.1-8
ksm-control-daemon: 1.1-1

This problem exists in other PVE versions too problably:
http://forum.proxmox.com/threads/4516-qmrestore-Rounding-up-size-to-full-physical-extent

Debugging /usr/share/perl5/PVE/Storage/LVMPlugin.pm allowed us to discover exact cmd that was executed to create this LV:

# qmrestore --storage vg0 vzdump-qemu-912-2012_11_02-02_52_12.tar.gz 912
extracting archive '/somedir/vzdump-qemu-912-2012_11_02-02_52_12.tar.gz'
extracting 'qemu-server.conf' from archive
extracting 'vm-disk-virtio0.raw' from archive
CMD: /sbin/lvcreate -aly --addtag pve-vm-912 --size 3145728.99902344k --name vm-912-disk-1 vg0
Rounding up size to full physical extent 4.00 GiB
Logical volume "vm-912-disk-1" created
new volume ID is 'vg0:vm-912-disk-1'
restore data to '/dev/vg0/vm-912-disk-1' (3221225472 bytes)

The problem is in byte to kB calculation in /usr/lib/qemu-server/qmextract where we can see

my $alloc_size = ($filesize + 1024 - 1)/1024;

but probably should be

my $alloc_size = int( ($filesize + 1024 - 1) / 1024 );

After patching qmextract as above, restored VM has LV with exact the same size like in tar.gz backup file and there is no lvcreate "Rounding up size to full physical extent..." warning.

Please verify and consider fixing in mainstream.

Thank you for great tool!

Regards,
Pawel

IB Development Team
http://dev.ib.pl/
 
Thanks for reporting that bug. The fix is already in the git repository, and we will upload the new package asap.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!