diff options
| author | unicell <unicell@gmail.com> | 2013-01-18 18:48:10 +0800 |
|---|---|---|
| committer | unicell <unicell@gmail.com> | 2013-01-19 08:33:35 +0800 |
| commit | 485e4bdb921c5e2b53af2886c53f4c93b8bf3be8 (patch) | |
| tree | ea886ac234320aa2ed798c6f4c6ebd2bcc4e629c | |
| parent | ab04b00edfbb21131fd370325089e69d5fd8e1f0 (diff) | |
Run_as_root to ensure resize2fs succeed for all image backends
Unlike other file based image backend, operation over LVM
logical volumes requires root to functioning correctly. Resize2fs
on logical volumes also need run_as_root.
Otherwise, when running nova-compute as non-root user, instance
creation with flavor disk size larger than image size would fail.
Caused by resize2fs failure.
Fixes LP# 1101137
Change-Id: I16a2aa4382be58843270ff23e11bfb1e20c568d2
| -rw-r--r-- | etc/nova/rootwrap.d/compute.filters | 2 | ||||
| -rw-r--r-- | nova/tests/test_imagebackend.py | 2 | ||||
| -rw-r--r-- | nova/virt/disk/api.py | 10 | ||||
| -rw-r--r-- | nova/virt/libvirt/imagebackend.py | 2 |
4 files changed, 11 insertions, 5 deletions
diff --git a/etc/nova/rootwrap.d/compute.filters b/etc/nova/rootwrap.d/compute.filters index f344a1b1c..e1113a9e7 100644 --- a/etc/nova/rootwrap.d/compute.filters +++ b/etc/nova/rootwrap.d/compute.filters @@ -99,9 +99,11 @@ pygrub: CommandFilter, /usr/bin/pygrub, root fdisk: CommandFilter, /sbin/fdisk, root # nova/virt/xenapi/vm_utils.py: e2fsck, -f, -p, partition_path +# nova/virt/disk/api.py: e2fsck, -f, -p, image e2fsck: CommandFilter, /sbin/e2fsck, root # nova/virt/xenapi/vm_utils.py: resize2fs, partition_path +# nova/virt/disk/api.py: resize2fs, image resize2fs: CommandFilter, /sbin/resize2fs, root # nova/network/linux_net.py: 'ip[6]tables-save' % (cmd, '-t', ... diff --git a/nova/tests/test_imagebackend.py b/nova/tests/test_imagebackend.py index a9865cb44..495e7c947 100644 --- a/nova/tests/test_imagebackend.py +++ b/nova/tests/test_imagebackend.py @@ -273,7 +273,7 @@ class LvmTestCase(_ImageTestCase, test.TestCase): cmd = ('dd', 'if=%s' % self.TEMPLATE_PATH, 'of=%s' % self.PATH, 'bs=4M') self.utils.execute(*cmd, run_as_root=True) - self.disk.resize2fs(self.PATH) + self.disk.resize2fs(self.PATH, run_as_root=True) self.mox.ReplayAll() image = self.image_class(self.INSTANCE, self.NAME) diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py index 26fb86f1e..d080f6d36 100644 --- a/nova/virt/disk/api.py +++ b/nova/virt/disk/api.py @@ -96,9 +96,13 @@ def mkfs(os_type, fs_label, target): utils.execute(*mkfs_command.split()) -def resize2fs(image, check_exit_code=False): - utils.execute('e2fsck', '-fp', image, check_exit_code=check_exit_code) - utils.execute('resize2fs', image, check_exit_code=check_exit_code) +def resize2fs(image, check_exit_code=False, run_as_root=False): + utils.execute('e2fsck', '-fp', image, + check_exit_code=check_exit_code, + run_as_root=run_as_root) + utils.execute('resize2fs', image, + check_exit_code=check_exit_code, + run_as_root=run_as_root) def get_disk_size(path): diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py index d272e408c..0815c142f 100644 --- a/nova/virt/libvirt/imagebackend.py +++ b/nova/virt/libvirt/imagebackend.py @@ -228,7 +228,7 @@ class Lvm(Image): cmd = ('dd', 'if=%s' % base, 'of=%s' % self.path, 'bs=4M') utils.execute(*cmd, run_as_root=True) if resize: - disk.resize2fs(self.path) + disk.resize2fs(self.path, run_as_root=True) generated = 'ephemeral_size' in kwargs |
