diff --git a/include/VirtualMachineManager.h b/include/VirtualMachineManager.h index c404976196..5a2b24934a 100644 --- a/include/VirtualMachineManager.h +++ b/include/VirtualMachineManager.h @@ -133,6 +133,21 @@ public: */ int updatesg(VirtualMachine * vm, int sgid); + /** + * Get keep_snapshots capability from driver + */ + bool is_keep_snapshots(const string& name) + { + const VirtualMachineManagerDriver * vmd = get(name); + + if ( vmd == 0 ) + { + return false; + } + + return vmd->is_keep_snapshots(); + } + private: /** * Thread id for the Virtual Machine Manager diff --git a/include/VirtualMachineManagerDriver.h b/include/VirtualMachineManagerDriver.h index 5b0d4fd964..c32b57ca16 100644 --- a/include/VirtualMachineManagerDriver.h +++ b/include/VirtualMachineManagerDriver.h @@ -95,6 +95,14 @@ public: return imported_actions.is_set(action); } + /** + * @return true if system snapshots are preserved + */ + bool is_keep_snapshots() const + { + return keep_snapshots; + } + protected: /** * Gets a configuration attr from driver configuration file (single @@ -145,6 +153,12 @@ private: */ ActionSet imported_actions; + /** + * Set to true if the hypervisor can keep system snapshots across + * create/delete cycles and live migrations. + */ + bool keep_snapshots; + /** * Pointer to the Virtual Machine Pool, to access VMs */ diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 4574a208af..e856ea066b 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -415,12 +415,13 @@ IM_MAD = [ # CPU does not have virtualization extensions or use nested Qemu-KVM hosts #------------------------------------------------------------------------------- VM_MAD = [ - NAME = "kvm", - SUNSTONE_NAME = "KVM", - EXECUTABLE = "one_vmm_exec", - ARGUMENTS = "-t 15 -r 0 kvm", - DEFAULT = "vmm_exec/vmm_exec_kvm.conf", - TYPE = "kvm", + NAME = "kvm", + SUNSTONE_NAME = "KVM", + EXECUTABLE = "one_vmm_exec", + ARGUMENTS = "-t 15 -r 0 kvm", + DEFAULT = "vmm_exec/vmm_exec_kvm.conf", + TYPE = "kvm", + KEEP_SNAPSHOTS = "no", IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, resume, delete, reboot, reboot-hard, resched, unresched, disk-attach, disk-detach, nic-attach, nic-detach, snap-create, snap-delete" @@ -438,12 +439,13 @@ VM_MAD = [ # defaults to 'suspend'. #------------------------------------------------------------------------------- #VM_MAD = [ -# NAME = "vcenter", -# SUNSTONE_NAME = "VMWare vCenter", -# EXECUTABLE = "one_vmm_sh", -# ARGUMENTS = "-p -t 15 -r 0 vcenter -s sh", -# DEFAULT = "vmm_exec/vmm_exec_vcenter.conf", -# TYPE = "xml", +# NAME = "vcenter", +# SUNSTONE_NAME = "VMWare vCenter", +# EXECUTABLE = "one_vmm_sh", +# ARGUMENTS = "-p -t 15 -r 0 vcenter -s sh", +# DEFAULT = "vmm_exec/vmm_exec_vcenter.conf", +# TYPE = "xml", +# KEEP_SNAPSHOTS = "no", # IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, # resume, delete, reboot, reboot-hard, resched, unresched, poweroff, # poweroff-hard, disk-attach, disk-detach, nic-attach, nic-detach, @@ -457,11 +459,12 @@ VM_MAD = [ # -t number of threads, i.e. number of actions performed at the same time #------------------------------------------------------------------------------- #VM_MAD = [ -# NAME = "ec2", -# SUNSTONE_NAME = "Amazon EC2", -# EXECUTABLE = "one_vmm_sh", -# ARGUMENTS = "-t 15 -r 0 ec2", -# TYPE = "xml", +# NAME = "ec2", +# SUNSTONE_NAME = "Amazon EC2", +# EXECUTABLE = "one_vmm_sh", +# ARGUMENTS = "-t 15 -r 0 ec2", +# TYPE = "xml", +# KEEP_SNAPSHOTS = "no", # IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, # resume, delete, reboot, reboot-hard, resched, unresched, poweroff, # poweroff-hard, disk-attach, disk-detach, nic-attach, nic-detach, @@ -475,11 +478,12 @@ VM_MAD = [ # -t number of threads, i.e. number of actions performed at the same time #------------------------------------------------------------------------------- #VM_MAD = [ -# NAME = "az", -# SUNSTONE_NAME = "Microsoft Azure", -# EXECUTABLE = "one_vmm_sh", -# ARGUMENTS = "-t 15 -r 0 az", -# TYPE = "xml", +# NAME = "az", +# SUNSTONE_NAME = "Microsoft Azure", +# EXECUTABLE = "one_vmm_sh", +# ARGUMENTS = "-t 15 -r 0 az", +# TYPE = "xml", +# KEEP_SNAPSHOTS = "no", # IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, # resume, delete, reboot, reboot-hard, resched, unresched, poweroff, # poweroff-hard, disk-attach, disk-detach, nic-attach, nic-detach, diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 0e2deed2dc..9ae83d8725 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -275,7 +275,10 @@ void LifeCycleManager::migrate_action(int vid) vm->set_resched(false); - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vm->reset_info(); @@ -871,7 +874,10 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, vm->set_resched(false); - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vm->reset_info(); diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index 86bfb2a477..e05d2e715e 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -48,7 +48,10 @@ void LifeCycleManager::save_success_action(int vid) vm->set_state(VirtualMachine::PROLOG_MIGRATE); - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vm->reset_info(); @@ -84,7 +87,10 @@ void LifeCycleManager::save_success_action(int vid) // SUSPENDED STATE //---------------------------------------------------- - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vm->reset_info(); @@ -114,7 +120,10 @@ void LifeCycleManager::save_success_action(int vid) vm->set_state(VirtualMachine::EPILOG_STOP); - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vm->reset_info(); @@ -287,7 +296,10 @@ void LifeCycleManager::deploy_success_action(int vid) vm->set_state(VirtualMachine::RUNNING); - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vmpool->update(vm); } @@ -483,7 +495,10 @@ void LifeCycleManager::shutdown_success_action(int vid) vm->set_state(VirtualMachine::EPILOG); - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vm->reset_info(); @@ -507,7 +522,10 @@ void LifeCycleManager::shutdown_success_action(int vid) // POWEROFF STATE //---------------------------------------------------- - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vm->reset_info(); @@ -535,7 +553,10 @@ void LifeCycleManager::shutdown_success_action(int vid) vm->set_state(VirtualMachine::EPILOG_UNDEPLOY); - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vm->reset_info(); @@ -693,7 +714,10 @@ void LifeCycleManager::prolog_success_action(int vid) case VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE: //recover success case VirtualMachine::PROLOG_MIGRATE_SUSPEND: case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE: //recover success - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vm->reset_info(); @@ -1012,7 +1036,10 @@ void LifeCycleManager::monitor_suspend_action(int vid) vm->set_resched(false); - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vm->reset_info(); @@ -1097,7 +1124,10 @@ void LifeCycleManager::monitor_poweroff_action(int vid) time_t the_time = time(0); - vm->delete_snapshots(); + if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) ) + { + vm->delete_snapshots(); + } vm->reset_info(); diff --git a/src/vmm/VirtualMachineManagerDriver.cc b/src/vmm/VirtualMachineManagerDriver.cc index 217f497bcc..de51da7228 100644 --- a/src/vmm/VirtualMachineManagerDriver.cc +++ b/src/vmm/VirtualMachineManagerDriver.cc @@ -38,7 +38,8 @@ VirtualMachineManagerDriver::VirtualMachineManagerDriver( const map& attrs, bool sudo, VirtualMachinePool * pool): - Mad(userid,attrs,sudo), driver_conf(true), vmpool(pool) + Mad(userid,attrs,sudo), driver_conf(true), keep_snapshots(false), + vmpool(pool) { map::const_iterator it; char * error_msg = 0; @@ -85,6 +86,22 @@ VirtualMachineManagerDriver::VirtualMachineManagerDriver( } } + // ------------------------------------------------------------------------- + // Copy the configuration attributes to driver conf + // ------------------------------------------------------------------------- + for (it=attrs.begin(); it != attrs.end(); ++it) + { + driver_conf.replace(it->first, it->second); + } + + // ------------------------------------------------------------------------- + // Parse KEEP_SNAPSHOTS + // ------------------------------------------------------------------------- + driver_conf.get("KEEP_SNAPSHOTS", keep_snapshots); + + // ------------------------------------------------------------------------- + // Parse IMPORTED_VMS_ACTIONS string and init the action set + // ------------------------------------------------------------------------- it = attrs.find("IMPORTED_VMS_ACTIONS"); if (it != attrs.end()) @@ -131,6 +148,7 @@ VirtualMachineManagerDriver::VirtualMachineManagerDriver( imported_actions.set(id); } + } /* ************************************************************************** */