From 3d9686e354d7cfc802a39a46ee64c39ca3ff34dd Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 27 May 2017 11:55:58 +0200 Subject: [PATCH] F #4809: Fix history update for non-cache vm objects --- src/dm/DispatchManagerActions.cc | 28 ++++---- src/lcm/LifeCycleActions.cc | 113 +++++++++++++------------------ src/lcm/LifeCycleStates.cc | 80 +++++++++++----------- 3 files changed, 99 insertions(+), 122 deletions(-) diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc index 87169639d8..8442126fb8 100644 --- a/src/dm/DispatchManagerActions.cc +++ b/src/dm/DispatchManagerActions.cc @@ -108,8 +108,6 @@ int DispatchManager::import(VirtualMachine * vm, const RequestAttributes& ra) vm->set_state(VirtualMachine::RUNNING); } - vmpool->update(vm); - vm->set_stime(the_time); vm->set_prolog_stime(the_time); @@ -121,6 +119,8 @@ int DispatchManager::import(VirtualMachine * vm, const RequestAttributes& ra) vmpool->update_history(vm); + vmpool->update(vm); + return 0; } @@ -1790,10 +1790,6 @@ int DispatchManager::disk_snapshot_create(int vid, int did, const string& name, default: break; } - vmpool->update(vm); - - vm->unlock(); - switch(state) { case VirtualMachine::POWEROFF: @@ -1831,6 +1827,10 @@ int DispatchManager::disk_snapshot_create(int vid, int did, const string& name, default: break; } + vmpool->update(vm); + + vm->unlock(); + return 0; } @@ -1991,10 +1991,6 @@ int DispatchManager::disk_snapshot_delete(int vid, int did, int snap_id, default: break; } - vmpool->update(vm); - - vm->unlock(); - switch(state) { case VirtualMachine::ACTIVE: @@ -2029,6 +2025,10 @@ int DispatchManager::disk_snapshot_delete(int vid, int did, int snap_id, default: break; } + vmpool->update(vm); + + vm->unlock(); + return 0; } @@ -2101,10 +2101,6 @@ int DispatchManager::disk_resize(int vid, int did, long long new_size, default: break; } - vmpool->update(vm); - - vm->unlock(); - switch(state) { case VirtualMachine::POWEROFF: @@ -2142,6 +2138,10 @@ int DispatchManager::disk_resize(int vid, int did, long long new_size, default: break; } + vmpool->update(vm); + + vm->unlock(); + return 0; } diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 5f8408ef96..e32fe53fc0 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -71,14 +71,14 @@ void LifeCycleManager::deploy_action(const LCMAction& la) rc = hpool->add_capacity(vm->get_hid(),vm->get_oid(),cpu,mem,disk,pci); - vmpool->update(vm); - vm->set_stime(thetime); vm->set_prolog_stime(thetime); vmpool->update_history(vm); + vmpool->update(vm); + if ( rc == -1) { //The host has been deleted, move VM to FAILURE @@ -124,12 +124,12 @@ void LifeCycleManager::suspend_action(const LCMAction& la) vm->set_resched(false); - vmpool->update(vm); - vm->set_action(History::SUSPEND_ACTION, la.uid(), la.gid(), la.req_id()); vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- vmm->trigger(VMMAction::SAVE,vid); @@ -169,12 +169,12 @@ void LifeCycleManager::stop_action(const LCMAction& la) vm->set_resched(false); - vmpool->update(vm); - vm->set_action(History::STOP_ACTION, la.uid(), la.gid(), la.req_id()); vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- vmm->trigger(VMMAction::SAVE,vid); @@ -187,14 +187,14 @@ void LifeCycleManager::stop_action(const LCMAction& la) vm->set_state(VirtualMachine::ACTIVE); vm->set_state(VirtualMachine::EPILOG_STOP); - vmpool->update(vm); - vm->set_action(History::STOP_ACTION, la.uid(), la.gid(), la.req_id()); vm->set_epilog_stime(time(0)); vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- tm->trigger(TMAction::EPILOG_STOP,vid); @@ -243,17 +243,19 @@ void LifeCycleManager::migrate_action(const LCMAction& la) hpool->add_capacity(vm->get_hid(), vm->get_oid(), cpu, mem, disk, pci); - vmpool->update(vm); - vm->set_stime(the_time); - vm->set_previous_action(History::MIGRATE_ACTION, la.uid(), la.gid(), - la.req_id()); - vm->set_action(History::MIGRATE_ACTION, la.uid(), la.gid(), la.req_id()); vmpool->update_history(vm); + vm->set_previous_action(History::MIGRATE_ACTION, la.uid(), la.gid(), + la.req_id()); + + vmpool->update_previous_history(vm); + + vmpool->update(vm); + //---------------------------------------------------- vmm->trigger(VMMAction::SAVE,vid); @@ -313,14 +315,14 @@ void LifeCycleManager::migrate_action(const LCMAction& la) hpool->del_capacity(vm->get_previous_hid(), vm->get_oid(), cpu, mem, disk, pci); - vmpool->update(vm); - vm->set_stime(the_time); vm->set_prolog_stime(the_time); vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- tm->trigger(TMAction::PROLOG_MIGR,vid); @@ -369,20 +371,20 @@ void LifeCycleManager::live_migrate_action(const LCMAction& la) hpool->add_capacity(vm->get_hid(), vm->get_oid(), cpu, mem, disk, pci); - vmpool->update(vm); - vm->set_stime(time(0)); + vm->set_action(History::LIVE_MIGRATE_ACTION, la.uid(), la.gid(), + la.req_id()); + vmpool->update_history(vm); vm->set_previous_action(History::LIVE_MIGRATE_ACTION, la.uid(),la.gid(), la.req_id()); - vm->set_action(History::LIVE_MIGRATE_ACTION, la.uid(), la.gid(), - la.req_id()); - vmpool->update_previous_history(vm); + vmpool->update(vm); + //---------------------------------------------------- vmm->trigger(VMMAction::MIGRATE,vid); @@ -437,8 +439,9 @@ void LifeCycleManager::shutdown_action(const LCMAction& la, bool hard) vm->set_resched(false); - vmpool->update(vm); vmpool->update_history(vm); + + vmpool->update(vm); } else if (vm->get_state() == VirtualMachine::SUSPENDED || vm->get_state() == VirtualMachine::POWEROFF) @@ -446,8 +449,6 @@ void LifeCycleManager::shutdown_action(const LCMAction& la, bool hard) vm->set_state(VirtualMachine::ACTIVE); vm->set_state(VirtualMachine::EPILOG); - vmpool->update(vm); - vm->set_action(History::TERMINATE_ACTION, la.uid(), la.gid(), la.req_id()); @@ -455,6 +456,8 @@ void LifeCycleManager::shutdown_action(const LCMAction& la, bool hard) vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- tm->trigger(TMAction::EPILOG, vid); @@ -465,8 +468,6 @@ void LifeCycleManager::shutdown_action(const LCMAction& la, bool hard) vm->set_state(VirtualMachine::ACTIVE); vm->set_state(VirtualMachine::EPILOG); - vmpool->update(vm); - vm->set_action(History::TERMINATE_ACTION, la.uid(), la.gid(), la.req_id()); @@ -474,6 +475,8 @@ void LifeCycleManager::shutdown_action(const LCMAction& la, bool hard) vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- tm->trigger(TMAction::EPILOG_LOCAL, vid); @@ -513,10 +516,6 @@ void LifeCycleManager::undeploy_action(const LCMAction& la, bool hard) vm->set_resched(false); - vmpool->update(vm); - - //---------------------------------------------------- - if (hard) { vm->set_action(History::UNDEPLOY_HARD_ACTION, la.uid(), la.gid(), @@ -533,6 +532,8 @@ void LifeCycleManager::undeploy_action(const LCMAction& la, bool hard) } vmpool->update_history(vm); + + vmpool->update(vm); } else if (vm->get_state() == VirtualMachine::POWEROFF) { @@ -543,8 +544,6 @@ void LifeCycleManager::undeploy_action(const LCMAction& la, bool hard) vm->set_state(VirtualMachine::ACTIVE); vm->set_state(VirtualMachine::EPILOG_UNDEPLOY); - vmpool->update(vm); - vm->set_action(History::UNDEPLOY_ACTION, la.uid(), la.gid(), la.req_id()); @@ -552,6 +551,8 @@ void LifeCycleManager::undeploy_action(const LCMAction& la, bool hard) vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- tm->trigger(TMAction::EPILOG_STOP,vid); @@ -611,10 +612,6 @@ void LifeCycleManager::poweroff_action(int vid, bool hard, const LCMAction& la) vm->set_resched(false); - vmpool->update(vm); - - //---------------------------------------------------- - if (hard) { vm->set_action(History::POWEROFF_HARD_ACTION, la.uid(), la.gid(), @@ -631,6 +628,8 @@ void LifeCycleManager::poweroff_action(int vid, bool hard, const LCMAction& la) } vmpool->update_history(vm); + + vmpool->update(vm); } else { @@ -673,8 +672,6 @@ void LifeCycleManager::restore_action(const LCMAction& la) vm->cp_history(); - vmpool->update(vm); //update last_seq & state - vm->set_stime(the_time); vm->set_last_poll(0); @@ -685,6 +682,8 @@ void LifeCycleManager::restore_action(const LCMAction& la) vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- vmm->trigger(VMMAction::RESTORE,vid); @@ -732,8 +731,6 @@ void LifeCycleManager::restart_action(const LCMAction& la) vm->cp_history(); - vmpool->update(vm); - vm->set_stime(the_time); vm->set_last_poll(0); @@ -744,6 +741,8 @@ void LifeCycleManager::restart_action(const LCMAction& la) vmpool->update_history(vm); + vmpool->update(vm); + vmm->trigger(VMMAction::DEPLOY, vid); } else @@ -949,8 +948,6 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, vm->reset_info(); - vmpool->update(vm); - vm->set_etime(the_time); vm->set_vm_info(); @@ -974,7 +971,6 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::PROLOG_UNDEPLOY_FAILURE: case VirtualMachine::PROLOG_FAILURE: vm->set_prolog_etime(the_time); - vmpool->update_history(vm); tm->trigger(TMAction::DRIVER_CANCEL,vid); tm->trigger(TMAction::EPILOG_DELETE,vid); @@ -998,7 +994,6 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::SHUTDOWN_UNDEPLOY: case VirtualMachine::HOTPLUG_SNAPSHOT: vm->set_running_etime(the_time); - vmpool->update_history(vm); vmm->trigger(VMMAction::DRIVER_CANCEL,vid); vmm->trigger(VMMAction::CLEANUP,vid); @@ -1006,10 +1001,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::HOTPLUG: vm->clear_attach_disk(); - vmpool->update(vm); vm->set_running_etime(the_time); - vmpool->update_history(vm); vmm->trigger(VMMAction::DRIVER_CANCEL,vid); vmm->trigger(VMMAction::CLEANUP,vid); @@ -1017,10 +1010,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::HOTPLUG_NIC: vm->clear_attach_nic(); - vmpool->update(vm); vm->set_running_etime(the_time); - vmpool->update_history(vm); vmm->trigger(VMMAction::DRIVER_CANCEL,vid); vmm->trigger(VMMAction::CLEANUP,vid); @@ -1028,10 +1019,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::HOTPLUG_SAVEAS: image_id = vm->clear_saveas_disk(); - vmpool->update(vm); vm->set_running_etime(the_time); - vmpool->update_history(vm); vmm->trigger(VMMAction::DRIVER_CANCEL,vid); vmm->trigger(VMMAction::CLEANUP,vid); @@ -1040,10 +1029,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::HOTPLUG_SAVEAS_POWEROFF: case VirtualMachine::HOTPLUG_SAVEAS_SUSPENDED: image_id = vm->clear_saveas_disk(); - vmpool->update(vm); vm->set_running_etime(the_time); - vmpool->update_history(vm); tm->trigger(TMAction::DRIVER_CANCEL, vid); tm->trigger(TMAction::EPILOG_DELETE, vid); @@ -1052,7 +1039,6 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::HOTPLUG_PROLOG_POWEROFF: case VirtualMachine::HOTPLUG_EPILOG_POWEROFF: vm->clear_attach_disk(); - vmpool->update(vm); tm->trigger(TMAction::DRIVER_CANCEL,vid); tm->trigger(TMAction::EPILOG_DELETE,vid); @@ -1066,7 +1052,6 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::DISK_SNAPSHOT_DELETE_SUSPENDED: case VirtualMachine::DISK_SNAPSHOT_DELETE: vm->clear_snapshot_disk(); - vmpool->update(vm); tm->trigger(TMAction::DRIVER_CANCEL, vid); tm->trigger(TMAction::EPILOG_DELETE,vid); @@ -1074,10 +1059,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::DISK_SNAPSHOT: vm->clear_snapshot_disk(); - vmpool->update(vm); vm->set_running_etime(the_time); - vmpool->update_history(vm); vmm->trigger(VMMAction::DRIVER_CANCEL,vid); vmm->trigger(VMMAction::CLEANUP,vid); @@ -1085,10 +1068,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::DISK_RESIZE: vm->clear_resize_disk(true); - vmpool->update(vm); vm->set_running_etime(the_time); - vmpool->update_history(vm); vmm->trigger(VMMAction::DRIVER_CANCEL,vid); vmm->trigger(VMMAction::CLEANUP,vid); @@ -1097,7 +1078,6 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::DISK_RESIZE_POWEROFF: case VirtualMachine::DISK_RESIZE_UNDEPLOYED: vm->clear_resize_disk(true); - vmpool->update(vm); tm->trigger(TMAction::DRIVER_CANCEL, vid); tm->trigger(TMAction::EPILOG_DELETE,vid); @@ -1105,17 +1085,16 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::MIGRATE: vm->set_running_etime(the_time); - vmpool->update_history(vm); vm->set_previous_etime(the_time); vm->set_previous_vm_info(); vm->set_previous_running_etime(the_time); - vmpool->update_previous_history(vm); - hpool->del_capacity(vm->get_previous_hid(), vm->get_oid(), cpu, mem, disk, pci); + vmpool->update_previous_history(vm); + vmm->trigger(VMMAction::DRIVER_CANCEL,vid); vmm->trigger(VMMAction::CLEANUP_BOTH,vid); break; @@ -1123,7 +1102,6 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::SAVE_STOP: case VirtualMachine::SAVE_SUSPEND: vm->set_running_etime(the_time); - vmpool->update_history(vm); vmm->trigger(VMMAction::DRIVER_CANCEL,vid); vmm->trigger(VMMAction::CLEANUP,vid); @@ -1131,17 +1109,16 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::SAVE_MIGRATE: vm->set_running_etime(the_time); - vmpool->update_history(vm); vm->set_previous_etime(the_time); vm->set_previous_vm_info(); vm->set_previous_running_etime(the_time); - vmpool->update_previous_history(vm); - hpool->del_capacity(vm->get_previous_hid(), vm->get_oid(), cpu, mem, disk, pci); + vmpool->update_previous_history(vm); + vmm->trigger(VMMAction::DRIVER_CANCEL,vid); vmm->trigger(VMMAction::CLEANUP_PREVIOUS,vid); break; @@ -1155,7 +1132,6 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::PROLOG_MIGRATE_UNKNOWN: case VirtualMachine::PROLOG_MIGRATE_UNKNOWN_FAILURE: vm->set_prolog_etime(the_time); - vmpool->update_history(vm); tm->trigger(TMAction::DRIVER_CANCEL,vid); tm->trigger(TMAction::EPILOG_DELETE_BOTH,vid); @@ -1168,7 +1144,6 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::EPILOG_STOP_FAILURE: case VirtualMachine::EPILOG_UNDEPLOY_FAILURE: vm->set_epilog_etime(the_time); - vmpool->update_history(vm); tm->trigger(TMAction::DRIVER_CANCEL,vid); tm->trigger(TMAction::EPILOG_DELETE,vid); @@ -1179,6 +1154,10 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, case VirtualMachine::CLEANUP_DELETE: break; } + + vmpool->update_history(vm); + + vmpool->update(vm); } /* -------------------------------------------------------------------------- */ diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index fc520d319e..e53fa1e5f7 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -55,8 +55,6 @@ void LifeCycleManager::save_success_action(int vid) vm->reset_info(); - vmpool->update(vm); - vm->set_previous_etime(the_time); vm->set_previous_vm_info(); @@ -69,6 +67,8 @@ void LifeCycleManager::save_success_action(int vid) vmpool->update_history(vm); + vmpool->update(vm); + vm->get_requirements(cpu, mem, disk, pci); hpool->del_capacity(vm->get_previous_hid(),vm->get_oid(),cpu,mem,disk,pci); @@ -92,8 +92,6 @@ void LifeCycleManager::save_success_action(int vid) vm->reset_info(); - vmpool->update(vm); - vm->set_running_etime(the_time); vm->set_etime(the_time); @@ -102,6 +100,8 @@ void LifeCycleManager::save_success_action(int vid) vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- dm->trigger(DMAction::SUSPEND_SUCCESS,vid); @@ -123,14 +123,14 @@ void LifeCycleManager::save_success_action(int vid) vm->reset_info(); - vmpool->update(vm); - vm->set_epilog_stime(the_time); vm->set_running_etime(the_time); vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- tm->trigger(TMAction::EPILOG_STOP,vid); @@ -192,8 +192,6 @@ void LifeCycleManager::save_failure_action(int vid) vm->cp_previous_history(); - vmpool->update(vm); //update last_seq & state - vm->set_stime(the_time); vm->set_running_stime(the_time); @@ -202,6 +200,8 @@ void LifeCycleManager::save_failure_action(int vid) vmpool->update_history(vm); + vmpool->update(vm); + vm->log("LCM", Log::INFO, "Fail to save VM state while migrating." " Assuming that the VM is still RUNNING (will poll VM)."); @@ -218,12 +218,12 @@ void LifeCycleManager::save_failure_action(int vid) vm->set_state(VirtualMachine::RUNNING); - vmpool->update(vm); - vm->clear_action(); vmpool->update_history(vm); + vmpool->update(vm); + vm->log("LCM", Log::INFO, "Fail to save VM state." " Assuming that the VM is still RUNNING (will poll VM)."); @@ -349,8 +349,6 @@ void LifeCycleManager::deploy_failure_action(int vid) vm->set_state(VirtualMachine::RUNNING); - vmpool->update(vm); - vm->set_etime(the_time); vm->set_vm_info(); @@ -373,8 +371,6 @@ void LifeCycleManager::deploy_failure_action(int vid) vm->cp_previous_history(); - vmpool->update(vm); //update last_seq & state - vm->set_stime(the_time); vm->set_running_stime(the_time); @@ -383,6 +379,8 @@ void LifeCycleManager::deploy_failure_action(int vid) vmpool->update_history(vm); + vmpool->update(vm); + vm->log("LCM", Log::INFO, "Fail to live migrate VM." " Assuming that the VM is still RUNNING (will poll VM)."); @@ -416,8 +414,8 @@ void LifeCycleManager::deploy_failure_action(int vid) vm->set_state(VirtualMachine::POWEROFF); vm->set_state(VirtualMachine::LCM_INIT); - vmpool->update(vm); vmpool->update_history(vm); + vmpool->update(vm); } else if (vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED) { @@ -427,8 +425,8 @@ void LifeCycleManager::deploy_failure_action(int vid) vm->set_state(VirtualMachine::SUSPENDED); vm->set_state(VirtualMachine::LCM_INIT); - vmpool->update(vm); vmpool->update_history(vm); + vmpool->update(vm); } else if (vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED) { @@ -484,14 +482,14 @@ void LifeCycleManager::shutdown_success_action(int vid) vm->reset_info(); - vmpool->update(vm); - vm->set_epilog_stime(the_time); vm->set_running_etime(the_time); vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- tm->trigger(TMAction::EPILOG,vid); @@ -509,8 +507,6 @@ void LifeCycleManager::shutdown_success_action(int vid) vm->reset_info(); - vmpool->update(vm); - vm->set_running_etime(the_time); vm->set_etime(the_time); @@ -519,6 +515,8 @@ void LifeCycleManager::shutdown_success_action(int vid) vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- dm->trigger(DMAction::POWEROFF_SUCCESS,vid); @@ -538,14 +536,14 @@ void LifeCycleManager::shutdown_success_action(int vid) vm->reset_info(); - vmpool->update(vm); - vm->set_epilog_stime(the_time); vm->set_running_etime(the_time); vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- tm->trigger(TMAction::EPILOG_STOP,vid); @@ -582,12 +580,12 @@ void LifeCycleManager::shutdown_failure_action(int vid) vm->set_state(VirtualMachine::RUNNING); - vmpool->update(vm); - vm->clear_action(); vmpool->update_history(vm); + vmpool->update(vm); + vm->log("LCM", Log::INFO, "Fail to shutdown VM." " Assuming that the VM is still RUNNING (will poll VM)."); @@ -670,8 +668,6 @@ void LifeCycleManager::prolog_success_action(int vid) return; } - vmpool->update(vm); - vm->set_prolog_etime(the_time); vm->set_running_stime(the_time); @@ -680,6 +676,8 @@ void LifeCycleManager::prolog_success_action(int vid) vmpool->update_history(vm); + vmpool->update(vm); + vmm->trigger(action,vid); break; @@ -697,8 +695,6 @@ void LifeCycleManager::prolog_success_action(int vid) vm->reset_info(); - vmpool->update(vm); - vm->set_etime(the_time); vm->set_prolog_etime(the_time); @@ -709,6 +705,8 @@ void LifeCycleManager::prolog_success_action(int vid) vmpool->update_history(vm); + vmpool->update(vm); + if (lcm_state == VirtualMachine::PROLOG_MIGRATE_POWEROFF|| lcm_state == VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE) { @@ -827,10 +825,11 @@ void LifeCycleManager::prolog_failure_action(int vid) vm->set_prolog_stime(t); vm->set_last_poll(0); - vmpool->update(vm); //update last_seq & state + hpool->add_capacity(vm->get_hid(),vm->get_oid(),cpu,mem,disk,pci); + vmpool->update_history(vm); - hpool->add_capacity(vm->get_hid(), vm->get_oid(), cpu,mem,disk,pci); + vmpool->update(vm); trigger(LCMAction::PROLOG_SUCCESS, vm->get_oid()); break; @@ -878,17 +877,14 @@ void LifeCycleManager::epilog_success_action(int vid) if ( state == VirtualMachine::EPILOG_STOP_FAILURE ) { vm->set_state(VirtualMachine::EPILOG_STOP); - vmpool->update(vm); } else if ( state == VirtualMachine::EPILOG_UNDEPLOY_FAILURE ) { vm->set_state(VirtualMachine::EPILOG_UNDEPLOY); - vmpool->update(vm); } else if ( state == VirtualMachine::EPILOG_FAILURE ) { vm->set_state(VirtualMachine::EPILOG); - vmpool->update(vm); } state = vm->get_lcm_state(); @@ -909,6 +905,8 @@ void LifeCycleManager::epilog_success_action(int vid) { dm->trigger(DMAction::RESUBMIT, vid); + vmpool->update(vm); + vm->unlock(); return; @@ -929,6 +927,8 @@ void LifeCycleManager::epilog_success_action(int vid) vmpool->update_history(vm); + vmpool->update(vm); + vm->get_requirements(cpu, mem, disk, pci); hpool->del_capacity(vm->get_hid(), vm->get_oid(), cpu, mem, disk, pci); @@ -1068,8 +1068,6 @@ void LifeCycleManager::monitor_suspend_action(int vid) vm->reset_info(); - vmpool->update(vm); - vm->set_running_etime(the_time); vm->set_etime(the_time); @@ -1080,6 +1078,8 @@ void LifeCycleManager::monitor_suspend_action(int vid) vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- dm->trigger(DMAction::SUSPEND_SUCCESS,vid); @@ -1160,8 +1160,6 @@ void LifeCycleManager::monitor_poweroff_action(int vid) vm->set_state(VirtualMachine::SHUTDOWN_POWEROFF); - vmpool->update(vm); - vm->set_running_etime(the_time); vm->set_etime(the_time); @@ -1172,6 +1170,8 @@ void LifeCycleManager::monitor_poweroff_action(int vid) vmpool->update_history(vm); + vmpool->update(vm); + //---------------------------------------------------- dm->trigger(DMAction::POWEROFF_SUCCESS,vid); @@ -1214,8 +1214,6 @@ void LifeCycleManager::monitor_poweron_action(int vid) vm->cp_history(); - vmpool->update(vm); - vm->set_stime(the_time); vm->set_running_stime(the_time); @@ -1223,6 +1221,8 @@ void LifeCycleManager::monitor_poweron_action(int vid) vm->set_last_poll(the_time); vmpool->update_history(vm); + + vmpool->update(vm); } else if ( vm->get_state() == VirtualMachine::ACTIVE ) { @@ -1534,8 +1534,6 @@ void LifeCycleManager::snapshot_revert_success(int vid) void LifeCycleManager::snapshot_revert_failure(int vid) { - // TODO: for now, it is the same code - snapshot_revert_success(vid); }