1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

bug #4405: Optional KEEP_SNAPSHOTS parameter for VMM drivers. It

preserves system snapshots across power on/off cycles and life migrations
if the hypervisor supports that.
This commit is contained in:
Ruben S. Montero 2016-05-18 19:48:43 +02:00
parent a6985e6b5b
commit 7a55686fa6
6 changed files with 122 additions and 35 deletions

View File

@ -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

View File

@ -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<History::VMAction> 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
*/

View File

@ -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,

View File

@ -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();

View File

@ -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();

View File

@ -38,7 +38,8 @@ VirtualMachineManagerDriver::VirtualMachineManagerDriver(
const map<string,string>& 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<string,string>::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);
}
}
/* ************************************************************************** */