diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-09-09 10:27:00 -0700 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-09-09 10:27:00 -0700 |
| commit | 3a0df2ca9b145d0ef5808def1f2f990a74e607e0 (patch) | |
| tree | 3069b34546eb21b8540ea61e09882d3e21eb34dd | |
| parent | f9665344b4197c48c5388314e7ecf4fb5eef4406 (diff) | |
| download | nova-3a0df2ca9b145d0ef5808def1f2f990a74e607e0.tar.gz nova-3a0df2ca9b145d0ef5808def1f2f990a74e607e0.tar.xz nova-3a0df2ca9b145d0ef5808def1f2f990a74e607e0.zip | |
remove unnecessary qemu-img flag, use base image type by default
| -rw-r--r-- | nova/virt/libvirt/connection.py | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 5f53b9d5d..5a5802fb4 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -124,13 +124,10 @@ flags.DEFINE_string('block_migration_flag', 'Define block migration behavior.') flags.DEFINE_integer('live_migration_bandwidth', 0, 'Define live migration behavior') -flags.DEFINE_string('qemu_img', 'qemu-img', - 'binary to use for qemu-img commands') -flags.DEFINE_string('snapshot_image_format', 'raw', - 'Snapshot image format (valide option are : ' - 'raw, qcow2, vmdk, vdi.' - 'If the binary qemu_img supports it)') - FLAGS.snapshot_disk_format, +flags.DEFINE_string('snapshot_image_format', None, + 'Snapshot image format (valid options are : ' + 'raw, qcow2, vmdk, vdi).' + 'Defaults to same as source image') flags.DEFINE_string('libvirt_vif_type', 'bridge', 'Type of VIF to create.') flags.DEFINE_string('libvirt_vif_driver', @@ -395,10 +392,7 @@ class LibvirtConnection(driver.ComputeDriver): def snapshot(self, context, instance, image_href): """Create snapshot from a running VM instance. - This command only works with qemu 0.14+, the qemu_img flag is - provided so that a locally compiled binary of qemu-img can be used - to support this command. - + This command only works with qemu 0.14+ """ virt_dom = self._lookup_by_name(instance['name']) @@ -424,8 +418,11 @@ class LibvirtConnection(driver.ComputeDriver): arch = base['properties']['architecture'] metadata['properties']['architecture'] = arch - if 'disk_format' in base: - metadata['disk_format'] = FLAGS.snapshot_image_format + source_format = base.get('disk_format') or 'raw' + if FLAGS.use_cow_images: + source_format = 'qcow2' + image_format = FLAGS.snapshot_image_format or source_format + metadata['disk_format'] = image_format if 'container_format' in base: metadata['container_format'] = base['container_format'] @@ -448,12 +445,12 @@ class LibvirtConnection(driver.ComputeDriver): # Export the snapshot to a raw image temp_dir = tempfile.mkdtemp() out_path = os.path.join(temp_dir, snapshot_name) - qemu_img_cmd = (FLAGS.qemu_img, + qemu_img_cmd = ('qemu-img', 'convert', '-f', - 'qcow2', + source_format, '-O', - FLAGS.snapshot_image_format, + image_format, '-s', snapshot_name, disk_path, |
