vmbuilder should allow for no swapfile

Bug #403149 reported by Daniel Silva
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
vm-builder (Ubuntu)
Confirmed
Wishlist
Unassigned

Bug Description

The option "--swapsize 0" currently throws an exception -- I guess vmbuilder tries to add a 0-sized partition to the virtual disk.

In the cli module, in its CLI class, in its set_disk_layout method, the code says:

            if vm.hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:
                vm.add_filesystem(size='%dM' % vm.rootsize, type='ext3', mntpnt='/')
                vm.add_filesystem(size='%dM' % vm.swapsize, type='swap', mntpnt=None)
                if vm.optsize > 0:
                    vm.add_filesystem(size='%dM' % optsize, type='ext3', mntpnt='/opt')
            else:
                if vm.raw:
                    disk = vm.add_disk(filename=vm.raw, preallocated=True)
                else:
                    size = vm.rootsize + vm.swapsize + vm.optsize
                    disk = vm.add_disk(size='%dM' % size)
                offset = 0
                disk.add_part(offset, vm.rootsize, 'ext3', '/')
                offset += vm.rootsize
                disk.add_part(offset, vm.swapsize, 'swap', 'swap')
                offset += vm.swapsize
                if vm.optsize > 0:
                    disk.add_part(offset, vm.optsize, 'ext3', '/opt')

and it could allow for skipping swapfiles with:

            if vm.hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:
                vm.add_filesystem(size='%dM' % vm.rootsize, type='ext3', mntpnt='/')
                if vm.swapsize > 0:
                    vm.add_filesystem(size='%dM' % vm.swapsize, type='swap', mntpnt=None)
                if vm.optsize > 0:
                    vm.add_filesystem(size='%dM' % optsize, type='ext3', mntpnt='/opt')
            else:
                if vm.raw:
                    disk = vm.add_disk(filename=vm.raw, preallocated=True)
                else:
                    size = vm.rootsize + vm.swapsize + vm.optsize
                    disk = vm.add_disk(size='%dM' % size)
                offset = 0
                disk.add_part(offset, vm.rootsize, 'ext3', '/')
                offset += vm.rootsize
                if vm.swapsize > 0:
                    disk.add_part(offset, vm.swapsize, 'swap', 'swap')
                    offset += vm.swapsize
                if vm.optsize > 0:
                    disk.add_part(offset, vm.optsize, 'ext3', '/opt')

Related branches

Revision history for this message
Chuck Short (zulcss) wrote :

Thanks for the bug report. I will create a patch for this and try to push it Soren.

Regards
chuck

Changed in vm-builder (Ubuntu):
assignee: nobody → Chuck Short (zulcss)
importance: Undecided → Wishlist
status: New → Confirmed
Chuck Short (zulcss)
Changed in vm-builder (Ubuntu):
assignee: Chuck Short (zulcss) → nobody
Revision history for this message
Simon Huerlimann (huerlisi) wrote :

In current Lucid (vmbuilder 0.12.3.r435) this still throws an error, though a different one:

2010-04-22 20:38:55,242 INFO : Calling hook: post_install
2010-04-22 20:38:55,243 ERROR : Partitions are overlapping
Traceback (most recent call last):
  File "/usr/bin/vmbuilder", line 24, in <module>
    cli.main()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/contrib/cli.py", line 115, in main
    self.set_disk_layout(hypervisor)
  File "/usr/lib/python2.6/dist-packages/VMBuilder/contrib/cli.py", line 208, in set_disk_layout
    disk.add_part(offset, swapsize, 'swap', 'swap')
  File "/usr/lib/python2.6/dist-packages/VMBuilder/disk.py", line 211, in add_part
    raise VMBuilderUserError('Partitions are overlapping')
VMBuilder.exception.VMBuilderUserError: Partitions are overlapping

Revision history for this message
Fabián Rodríguez (magicfab) wrote :

Same with Maverick.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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