Add qcow2 as a disk backend for KVM

This allows to build an image with qcow2 as a disk backend.

The update implements a new class that inherits from QEMUVolume and just
needs the extention and file format.
This commit is contained in:
Brendan Harley 2017-06-14 18:09:27 +02:00
parent 3e5c94f0d4
commit cc69173e52
6 changed files with 38 additions and 4 deletions

View file

@ -26,6 +26,7 @@ def load_volume(data, bootloader):
from bootstrapvz.common.fs.virtualmachinedisk import VirtualMachineDisk from bootstrapvz.common.fs.virtualmachinedisk import VirtualMachineDisk
from bootstrapvz.common.fs.folder import Folder from bootstrapvz.common.fs.folder import Folder
from bootstrapvz.common.fs.logicalvolume import LogicalVolume from bootstrapvz.common.fs.logicalvolume import LogicalVolume
from bootstrapvz.common.fs.qcow2volume import Qcow2Volume
volume_backing = {'raw': LoopbackVolume, volume_backing = {'raw': LoopbackVolume,
's3': LoopbackVolume, 's3': LoopbackVolume,
'vdi': VirtualDiskImage, 'vdi': VirtualDiskImage,
@ -33,7 +34,8 @@ def load_volume(data, bootloader):
'vmdk': VirtualMachineDisk, 'vmdk': VirtualMachineDisk,
'ebs': EBSVolume, 'ebs': EBSVolume,
'folder': Folder, 'folder': Folder,
'lvm': LogicalVolume 'lvm': LogicalVolume,
'qcow2': Qcow2Volume
}.get(data['backing']) }.get(data['backing'])
# Instantiate the partition map # Instantiate the partition map

View file

@ -0,0 +1,7 @@
from qemuvolume import QEMUVolume
class Qcow2Volume(QEMUVolume):
extension = 'qcow2'
qemu_format = 'qcow2'

View file

@ -6,7 +6,7 @@ virtual images for Linux Kernel-based Virtual Machines. It supports the
installation of `virtio kernel installation of `virtio kernel
modules <http://www.linux-kvm.org/page/Virtio>`__ (paravirtualized modules <http://www.linux-kvm.org/page/Virtio>`__ (paravirtualized
drivers for IO operations). drivers for IO operations).
It also supports creating an image with LVM as a disk backend. It also supports creating an image with LVM and qcow2 as a disk backend.
Manifest settings Manifest settings
----------------- -----------------

View file

@ -32,7 +32,8 @@ properties:
properties: properties:
backing: backing:
type: string type: string
enum: enum:
- qcow2
- raw - raw
- lvm - lvm
logicalvolume: {type: string} logicalvolume: {type: string}

View file

@ -276,7 +276,7 @@ boot, root and swap.
- ``backing``: Specifies the volume backing. This setting is very - ``backing``: Specifies the volume backing. This setting is very
provider specific. provider specific.
Valid values: ``ebs``, ``s3``, ``vmdk``, ``vdi``, ``raw`` Valid values: ``ebs``, ``s3``, ``vmdk``, ``vdi``, ``raw``, ``qcow2``, ``lvm``
``required`` ``required``
- ``partitions``: A map of the partitions that should be created on - ``partitions``: A map of the partitions that should be created on
the volume. the volume.

View file

@ -0,0 +1,24 @@
---
name: debian-qcow2-example
provider:
name: kvm
bootstrapper:
workspace: /target
system:
release: jessie
architecture: amd64
bootloader: grub
charmap: UTF-8
locale: en_US
timezone: UTC
volume:
backing: qcow2
partitions:
type: gpt
root:
filesystem: ext4
size: 1GB
packages: {}
plugins:
root_password:
password: test