Created
July 27, 2012 15:21
-
-
Save vishvananda/3188626 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py | |
| index e55b54f..c733045 100644 | |
| --- a/nova/virt/disk/api.py | |
| +++ b/nova/virt/disk/api.py | |
| @@ -294,7 +294,7 @@ def setup_container(image, container_dir=None, use_cow=False): | |
| raise exception.NovaException(img.errors) | |
| -def destroy_container(img): | |
| +def destroy_container(image, container_dir=None, use_cow=False): | |
| """Destroy the container once it terminates. | |
| It will umount the container that is mounted, | |
| @@ -302,6 +302,7 @@ def destroy_container(img): | |
| LXC does not support qcow2 images yet. | |
| """ | |
| + img = _DiskImage(image=image, use_cow=use_cow, mount_dir=container_dir) | |
| try: | |
| if img: | |
| img.umount() | |
| diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py | |
| index 9ae5d1d..e9aeee1 100644 | |
| --- a/nova/virt/libvirt/driver.py | |
| +++ b/nova/virt/libvirt/driver.py | |
| @@ -551,7 +551,15 @@ class LibvirtDriver(driver.ComputeDriver): | |
| LOG.info(_('Deleting instance files %(target)s') % locals(), | |
| instance=instance) | |
| if FLAGS.libvirt_type == 'lxc': | |
| - disk.destroy_container(self.container) | |
| + disk_path = os.path.join(FLAGS.instances_path, | |
| + instance['name'], | |
| + 'disk') | |
| + container_dir = os.path.join(FLAGS.instances_path, | |
| + instance['name'], | |
| + 'rootfs') | |
| + disk.destroy_container(disk_path, | |
| + container_dir=container_dir, | |
| + use_cow=FLAGS.use_cow_images) | |
| if os.path.exists(target): | |
| # If we fail to get rid of the directory | |
| # tree, this shouldn't block deletion of | |
| @@ -1242,7 +1250,9 @@ class LibvirtDriver(driver.ComputeDriver): | |
| libvirt_utils.write_to_file(basepath('libvirt.xml'), libvirt_xml) | |
| if FLAGS.libvirt_type == 'lxc': | |
| - container_dir = '%s/rootfs' % basepath(suffix='') | |
| + container_dir = os.path.join(FLAGS.instances_path, | |
| + instance['name'], | |
| + 'rootfs') | |
| libvirt_utils.ensure_tree(container_dir) | |
| # NOTE(dprince): for rescue console.log may already exist... chown it. | |
| @@ -1438,9 +1448,12 @@ class LibvirtDriver(driver.ComputeDriver): | |
| instance=instance) | |
| if FLAGS.libvirt_type == 'lxc': | |
| - self.container = disk.setup_container(basepath('disk'), | |
| - container_dir=container_dir, | |
| - use_cow=FLAGS.use_cow_images) | |
| + disk_path = os.path.join(FLAGS.instances_path, | |
| + instance['name'], | |
| + 'disk') | |
| + disk.setup_container(disk_path, | |
| + container_dir=container_dir, | |
| + use_cow=FLAGS.use_cow_images) | |
| if FLAGS.libvirt_type == 'uml': | |
| libvirt_utils.chown(basepath('disk'), 'root') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment