From 8bd8da476c9e7718cea6552e767ea51727d28418 Mon Sep 17 00:00:00 2001 From: Rafi Khardalian Date: Fri, 1 Mar 2013 08:53:52 +0000 Subject: 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 --- etc/nova/rootwrap.d/compute.filters | 4 ++++ nova/virt/disk/api.py | 2 +- nova/virt/libvirt/driver.py | 5 +++-- nova/virt/libvirt/imagebackend.py | 3 +++ 4 files changed, 11 insertions(+), 3 deletions(-) mode change 100644 => 100755 nova/virt/disk/api.py 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 old mode 100644 new mode 100755 index 0880af1cb..e8ecbbd8a --- 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): -- cgit