From c538024fddc5994afe13f41817b9fe0b8e8f3fdd Mon Sep 17 00:00:00 2001 From: Rafi Khardalian Date: Fri, 18 Jan 2013 06:23:02 +0000 Subject: Allow snapshots of paused and suspended instances Fixes bug 1100556 Remove the restriction in the API of snapshotting instances which are in paused or suspended states and update the libvirt driver to deal with this accordingly. Other drivers may need to be updated accordingly. Change-Id: Iabeb44f843c3c04f767c4103038fcf6c52966ff3 --- nova/compute/api.py | 3 ++- nova/virt/libvirt/driver.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index 4b15a3e27..1ff0365d4 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1370,7 +1370,8 @@ class API(base.Base): return image_meta @wrap_check_policy - @check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.STOPPED]) + @check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.STOPPED, + vm_states.PAUSED, vm_states.SUSPENDED]) def snapshot(self, context, instance, name, extra_properties=None, image_id=None): """Snapshot the given instance. diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 115c6cd02..e51883843 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -808,7 +808,7 @@ class LibvirtDriver(driver.ComputeDriver): # NOTE(dkang): managedSave does not work for LXC if CONF.libvirt_type != 'lxc': - if state == power_state.RUNNING: + if state == power_state.RUNNING or state == power_state.PAUSED: virt_dom.managedSave(0) # Make the snapshot @@ -832,6 +832,9 @@ class LibvirtDriver(driver.ComputeDriver): if CONF.libvirt_type != 'lxc': if state == power_state.RUNNING: self._create_domain(domain=virt_dom) + elif state == power_state.PAUSED: + self._create_domain(domain=virt_dom, + launch_flags=libvirt.VIR_DOMAIN_START_PAUSED) # Upload that image to the image service -- cgit