diff options
author | Rafi Khardalian <rafi@metacloud.com> | 2013-03-01 08:53:52 +0000 |
---|---|---|
committer | Rafi Khardalian <rafi@metacloud.com> | 2013-03-01 09:22:12 +0000 |
commit | 8bd8da476c9e7718cea6552e767ea51727d28418 (patch) | |
tree | 726a4b861579ed249884e7930a5e622970ea7154 | |
parent | 957a2a6909fb6b5d9773ef74160543f4d984cc96 (diff) | |
download | nova-8bd8da476c9e7718cea6552e767ea51727d28418.tar.gz nova-8bd8da476c9e7718cea6552e767ea51727d28418.tar.xz nova-8bd8da476c9e7718cea6552e767ea51727d28418.zip |
Fix ephemeral devices on LVM don't get mkfs'd
Fixes bug 1083424
Updated imagebackend to run the necessary callback conditionally
based on whether LVM is configured for use and ephemeral_size is
defined. The callback function was updated not to invoke qemu-img
for LVM, since the ephemeral disk is already present/created via
LVM. Lastly, the mkfs call had to be changed to be run as root,
since we are dealing with raw devices.
Change-Id: Ieb1febb0ea086f8e5063d92ca376d349fcd43a43
-rw-r--r-- | etc/nova/rootwrap.d/compute.filters | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | nova/virt/disk/api.py | 2 | ||||
-rwxr-xr-x | nova/virt/libvirt/driver.py | 5 | ||||
-rwxr-xr-x | nova/virt/libvirt/imagebackend.py | 3 |
4 files changed, 11 insertions, 3 deletions
diff --git a/etc/nova/rootwrap.d/compute.filters b/etc/nova/rootwrap.d/compute.filters index f0d9c6fee..bf08a6638 100644 --- a/etc/nova/rootwrap.d/compute.filters +++ b/etc/nova/rootwrap.d/compute.filters @@ -163,6 +163,10 @@ readlink: CommandFilter, readlink, root # nova/virt/disk/api.py: 'touch', target touch: CommandFilter, /usr/bin/touch, root +# nova/virt/disk/api.py: +mkfs.ext3: CommandFilter, /sbin/mkfs.ext3, root +mkfs.ntfs: CommandFilter, /sbin/mkfs.ntfs, root + # nova/virt/libvirt/connection.py: read_initiator: ReadFileFilter, /etc/iscsi/initiatorname.iscsi diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py index 0880af1cb..e8ecbbd8a 100644..100755 --- a/nova/virt/disk/api.py +++ b/nova/virt/disk/api.py @@ -94,7 +94,7 @@ def mkfs(os_type, fs_label, target): mkfs_command = (_MKFS_COMMAND.get(os_type, _DEFAULT_MKFS_COMMAND) or '') % locals() if mkfs_command: - utils.execute(*mkfs_command.split()) + utils.execute(*mkfs_command.split(), run_as_root=True) def resize2fs(image, check_exit_code=False, run_as_root=False): diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 5ba97a8a4..682ee9ca2 100755 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -1690,8 +1690,9 @@ class LibvirtDriver(driver.ComputeDriver): if not fs_format: fs_format = CONF.default_ephemeral_format - libvirt_utils.create_image('raw', target, - '%d%c' % (local_size, unit)) + if not CONF.libvirt_images_type == "lvm": + libvirt_utils.create_image('raw', target, + '%d%c' % (local_size, unit)) if fs_format: utils.mkfs(fs_format, target, label) diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py index 082dd403e..25c6be1f3 100755 --- a/nova/virt/libvirt/imagebackend.py +++ b/nova/virt/libvirt/imagebackend.py @@ -141,6 +141,9 @@ class Image(object): def call_if_not_exists(target, *args, **kwargs): if not os.path.exists(target): fetch_func(target=target, *args, **kwargs) + elif CONF.libvirt_images_type == "lvm" and \ + 'ephemeral_size' in kwargs: + fetch_func(target=target, *args, **kwargs) base_dir = os.path.join(CONF.instances_path, CONF.base_dir_name) if not os.path.exists(base_dir): |