diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-20 17:53:24 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-20 17:53:24 +0000 |
| commit | f4a131fb07a48d67c14e60765bb4a15775aaaeb3 (patch) | |
| tree | c30fbfea6c2ea083aea4c397d7e907aaea97f1e9 /nova | |
| parent | fbdaa960d9abfada9cabd4764b11eaaed15b19df (diff) | |
| parent | 51441e369bb05e9cb9149ac9a7290fe541e3ed1a (diff) | |
| download | nova-f4a131fb07a48d67c14e60765bb4a15775aaaeb3.tar.gz nova-f4a131fb07a48d67c14e60765bb4a15775aaaeb3.tar.xz nova-f4a131fb07a48d67c14e60765bb4a15775aaaeb3.zip | |
Merge "Inherit the base images qcow2 properties"
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/tests/test_libvirt.py | 3 | ||||
| -rw-r--r-- | nova/virt/libvirt/utils.py | 24 |
2 files changed, 25 insertions, 2 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index bca9544fc..10db13e17 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -3402,6 +3402,9 @@ class LibvirtUtilsTestCase(test.TestCase): def test_create_cow_image(self): self.mox.StubOutWithMock(utils, 'execute') + rval = ('', '') + utils.execute('env', 'LC_ALL=C', 'LANG=C', + 'qemu-img', 'info', '/some/path').AndReturn(rval) utils.execute('qemu-img', 'create', '-f', 'qcow2', '-o', 'backing_file=/some/path', '/the/new/cow') diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py index 2dc0bfda1..740d4ea7b 100644 --- a/nova/virt/libvirt/utils.py +++ b/nova/virt/libvirt/utils.py @@ -86,8 +86,28 @@ def create_cow_image(backing_file, path): :param backing_file: Existing image on which to base the COW image :param path: Desired location of the COW image """ - execute('qemu-img', 'create', '-f', 'qcow2', '-o', - 'backing_file=%s' % backing_file, path) + base_cmd = ['qemu-img', 'create', '-f', 'qcow2'] + cow_opts = [] + if backing_file: + cow_opts += ['backing_file=%s' % backing_file] + base_details = images.qemu_img_info(backing_file) + else: + base_details = {} + # This doesn't seem to get inherited so force it to... + # http://paste.ubuntu.com/1213295/ + # TODO(harlowja) probably file a bug against qemu-img/qemu + if 'cluster_size' in base_details: + cow_opts += ['cluster_size=%s' % base_details['cluster_size']] + # For now don't inherit this due the following discussion... + # See: http://www.gossamer-threads.com/lists/openstack/dev/10592 + # if 'preallocation' in base_details: + # cow_opts += ['preallocation=%s' % base_details['preallocation']] + if 'encryption' in base_details: + cow_opts += ['encryption=%s' % base_details['encryption']] + if cow_opts: + cow_opts.insert(0, '-o') + cmd = base_cmd + cow_opts + [path] + execute(*cmd) def create_lvm_image(vg, lv, size, sparse=False): |
