python-vm-builder --raw doesn't set size correctly

Bug #303882 reported by Tom Moyer

This bug report was converted into a question: question #115631: python-vm-builder --raw doesn't set size correctly.

24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
vm-builder (Ubuntu)
Invalid
Medium
Soren Hansen

Bug Description

Binary package hint: python-vm-builder

When using the --raw option with an LVM volume as the target to create a VM, the default size is 5G. This isn't a problem if rootsize + swapsize + optsize falls within 5GB, but if you exceed the 5GB default size, vmbuilder throws an exception (shown below). To make this concrete here is what I am trying to do. I create a logical volume with size 10GB, and on this I would like to have an 8GB root and 2GB swap partition. There should be enough space, but I'm being told otherwise. There should be a way to specify the size of the raw device, or simply ignore the size when raw is being used. I can work up a patch to add a size option to the command line if it would help.

vmbuilder kvm ubuntu --debug --verbose -c vmbuilder.cfg --raw /dev/tungsten/tungsten-client0 --hostname tungsten-client0 --rootsize 7168 --swapsize 2048 --mem 3072 --overwrite
Traceback (most recent call last):
  File "/usr/bin/vmbuilder", line 29, in <module>
    VMBuilder.run()
  File "/usr/lib/python2.5/site-packages/VMBuilder/__init__.py", line 66, in run
    frontend.run()
  File "/usr/lib/python2.5/site-packages/VMBuilder/plugins/cli/__init__.py", line 65, in run
    self.set_disk_layout(vm)
  File "/usr/lib/python2.5/site-packages/VMBuilder/plugins/cli/__init__.py", line 97, in set_disk_layout
    disk.add_part(offset, vm.swapsize, 'swap', 'swap')
  File "/usr/lib/python2.5/site-packages/VMBuilder/disk.py", line 163, in add_part
    raise Exception('Partition is out of bounds. start=%d, end=%d, disksize=%d' % (begin,end,self.size))
Exception: Partition is out of bounds. start=7168, end=9215, disksize=5120
root@tungsten:~# vmbuilder kvm ubuntu --debug --verbose -c vmbuilder.cfg --raw /dev/tungsten/tungsten-client0 --hostname tungsten-client0 --rootsize 8192 --swapsize 2048 --mem 3072 --overwrite
Traceback (most recent call last):
  File "/usr/bin/vmbuilder", line 29, in <module>
    VMBuilder.run()
  File "/usr/lib/python2.5/site-packages/VMBuilder/__init__.py", line 66, in run
    frontend.run()
  File "/usr/lib/python2.5/site-packages/VMBuilder/plugins/cli/__init__.py", line 65, in run
    self.set_disk_layout(vm)
  File "/usr/lib/python2.5/site-packages/VMBuilder/plugins/cli/__init__.py", line 97, in set_disk_layout
    disk.add_part(offset, vm.swapsize, 'swap', 'swap')
  File "/usr/lib/python2.5/site-packages/VMBuilder/disk.py", line 163, in add_part
    raise Exception('Partition is out of bounds. start=%d, end=%d, disksize=%d' % (begin,end,self.size))
Exception: Partition is out of bounds. start=8192, end=10239, disksize=5120

Output of lsb_release -rd:
Description: Ubuntu 8.10
Release: 8.10

Output of apt-cache policy python-vm-builder:
apt-cache policy python-vm-builder
python-vm-builder:
  Installed: 0.9-0ubuntu3.1
  Candidate: 0.9-0ubuntu3.1
  Version table:
 *** 0.9-0ubuntu3.1 0
        500 http://us.archive.ubuntu.com intrepid-updates/universe Packages
        500 http://security.ubuntu.com intrepid-security/universe Packages
        100 /var/lib/dpkg/status
     0.9-0ubuntu3 0
        500 http://us.archive.ubuntu.com intrepid/universe Packages

Expected outcome: VM successfully created on the LVM partition that was previously allocated.
Actual outcome: Exception thrown due to an incorrect assumption about the size of the raw device.

Revision history for this message
Nick Barcet (nijaba) wrote :

We were indeed mistakenly setting a maximum size of 5G for raw devices for which we should not assume the size. This should now be fixed. Of course there is no telling of what happens if the device is smaller than what you try to fit into it, but I do not see any obvious way to determine reliably the size of the raw device passed considering the various type that can be used. Ideas welcome...

While at it I also realized that it was not possible to use --raw multiple times as is was possible to do with the bash implementation. It is quite useful when used together with --part when you specify multiple disk. I fixed that as well.

Changed in vm-builder:
assignee: nobody → nijaba
status: New → Fix Committed
importance: Undecided → Medium
Revision history for this message
Tom Moyer (tom-tom) wrote : Re: [Bug 303882] Re: python-vm-builder --raw doesn't set size correctly

Only suggestion I have is to move away from --raw as an option (except
as a last resort) and instead diversify the options such that you
could have something like --partition --drive and --lvm (and any
others that I am leaving out as valid block devices) and then there
should be ways of getting sizes for some of these types of devices
given the extra information provided on the command line.

~tom

On Dec 1, 2008, at 5:02 PM, Nick Barcet wrote:

> We were indeed mistakenly setting a maximum size of 5G for raw devices
> for which we should not assume the size. This should now be fixed.
> Of
> course there is no telling of what happens if the device is smaller
> than
> what you try to fit into it, but I do not see any obvious way to
> determine reliably the size of the raw device passed considering the
> various type that can be used. Ideas welcome...
>
> While at it I also realized that it was not possible to use --raw
> multiple times as is was possible to do with the bash implementation.
> It is quite useful when used together with --part when you specify
> multiple disk. I fixed that as well.
>
>
> ** Changed in: vm-builder (Ubuntu)
> Assignee: (unassigned) => Nick Barcet (nijaba)
> Status: New => Fix Committed
>
> ** Changed in: vm-builder (Ubuntu)
> Importance: Undecided => Medium
>
> --
> python-vm-builder --raw doesn't set size correctly
> https://bugs.launchpad.net/bugs/303882
> You received this bug notification because you are a direct subscriber
> of the bug.

Revision history for this message
Tim Miller Dyck (timmillerdyck) wrote :

I see the fix is committed above, but the

size='5G'

hardcoding on line 37 of /usr/share/pyshared/VMBuilder/disk.py is still present in the current karmic version (python-vm-builder 0.11-0ubuntu2). Can this patch be merged into the karmic version? Thanks!

-Tim

Nick Barcet (nijaba)
Changed in vm-builder (Ubuntu):
assignee: Nick Barcet (nijaba) → Soren Hansen (soren)
Revision history for this message
Andreas Ntaflos (daff) wrote :

Would also like to see this fixed for karmic. Using python-vmbuilder 0.11.3-0ubuntu1 and the same error occurs when trying to use a 10G LVM volume as a --raw device. I assume this is the same bug.

sudo vmbuilder kvm ubuntu --debug --verbose -m 2048 --raw=/dev/mapper/vg--storage-lv--chat_root --rootsize=8G --swapsize=2G --suite=karmic ...

Traceback (most recent call last):
  File "/usr/bin/vmbuilder", line 29, in <module>
    VMBuilder.run()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/__init__.py", line 65, in run
    frontend.run()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/plugins/cli/__init__.py", line 66, in run
    self.set_disk_layout(vm)
  File "/usr/lib/python2.6/dist-packages/VMBuilder/plugins/cli/__init__.py", line 105, in set_disk_layout
    disk.add_part(offset, vm.swapsize, 'swap', 'swap')
  File "/usr/lib/python2.6/dist-packages/VMBuilder/disk.py", line 189, in add_part
    raise Exception('Partition is out of bounds. start=%d, end=%d, disksize=%d' % (begin,end,self.size))
Exception: Partition is out of bounds. start=8192, end=10239, disksize=5120

Revision history for this message
Soren Hansen (soren) wrote :

In Lucid we now detect the size of the device or file given to --raw.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package vm-builder - 0.12.1-0ubuntu1

---------------
vm-builder (0.12.1-0ubuntu1) lucid; urgency=low

  * New upstream, bugfix-only release. (LP: #303882, #523589, #261702,
    #284620, #527240, #527253)
 -- Soren Hansen <email address hidden> Wed, 24 Feb 2010 23:52:03 +0100

Changed in vm-builder (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
sony (vijays4) wrote :

when i am trying to creating vm with the help of vmbuilder i am getting error..
pls suggest where i need to work/modify/update.

File "/usr/lib/python2.6/dist-packages/VMBuilder/plugins/ubuntu/distro.py", line 166, in xen_kernel_version
    raise VMBuilderException('Something is wrong, no valid xen kernel for the suite %s found by rmadison' % self.vm.suite)
NameError: global name 'VMBuilderException' is not defined

Changed in vm-builder (Ubuntu):
status: Fix Released → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.