From fda16abb578e326b096a41844300086b87c6078a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 17 Oct 2012 12:34:32 +0200 Subject: [PATCH 1/9] Bug #1210: Add new VM LCM state in core, BOOT_SUSPENDED. A failed boot returns the VM to SUSPENDED --- include/VirtualMachine.h | 3 ++- src/dm/DispatchManagerActions.cc | 3 ++- src/lcm/LifeCycleActions.cc | 11 +++++++---- src/lcm/LifeCycleStates.cc | 9 +++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 76df2cd372..97ad9d626a 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -85,7 +85,8 @@ public: HOTPLUG = 17, SHUTDOWN_POWEROFF = 18, BOOT_UNKNOWN = 19, - BOOT_POWEROFF = 20 + BOOT_POWEROFF = 20, + BOOT_SUSPENDED = 21 }; // ------------------------------------------------------------------------- diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc index f7aac5343e..15eab25ee2 100644 --- a/src/dm/DispatchManagerActions.cc +++ b/src/dm/DispatchManagerActions.cc @@ -556,7 +556,8 @@ int DispatchManager::restart(int vid) (vm->get_lcm_state() == VirtualMachine::UNKNOWN || vm->get_lcm_state() == VirtualMachine::BOOT || vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN || - vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF)) + vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF || + vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED)) || vm->get_state() == VirtualMachine::POWEROFF ) { Nebula& nd = Nebula::instance(); diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index c71d3afdc8..da5432dc49 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -408,7 +408,7 @@ void LifeCycleManager::restore_action(int vid) //---------------------------------------------------- vm->set_state(VirtualMachine::ACTIVE); - vm->set_state(VirtualMachine::BOOT); + vm->set_state(VirtualMachine::BOOT_SUSPENDED); vm->cp_history(); @@ -420,7 +420,7 @@ void LifeCycleManager::restore_action(int vid) vmpool->update_history(vm); - vm->log("LCM", Log::INFO, "New state is BOOT"); + vm->log("LCM", Log::INFO, "New state is BOOT_SUSPENDED"); //---------------------------------------------------- @@ -500,7 +500,8 @@ void LifeCycleManager::restart_action(int vid) (vm->get_lcm_state() == VirtualMachine::UNKNOWN || vm->get_lcm_state() == VirtualMachine::BOOT || vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN || - vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF)) + vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF || + vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED)) ||vm->get_state() == VirtualMachine::POWEROFF) { Nebula& nd = Nebula::instance(); @@ -513,7 +514,8 @@ void LifeCycleManager::restart_action(int vid) if (vm->get_state() == VirtualMachine::ACTIVE && (vm->get_lcm_state() == VirtualMachine::BOOT || vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN || - vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF)) + vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF || + vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED)) { vm->log("LCM", Log::INFO, "Sending BOOT command to VM again"); } @@ -659,6 +661,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) case VirtualMachine::BOOT: case VirtualMachine::BOOT_UNKNOWN: case VirtualMachine::BOOT_POWEROFF: + case VirtualMachine::BOOT_SUSPENDED: case VirtualMachine::RUNNING: case VirtualMachine::UNKNOWN: case VirtualMachine::SHUTDOWN: diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index bd37bdae0a..d38c2ca92c 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -373,6 +373,15 @@ void LifeCycleManager::deploy_failure_action(int vid) vm->log("LCM", Log::INFO, "Fail to boot VM. New VM state is POWEROFF"); } + else if (vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED) + { + vm->set_state(VirtualMachine::SUSPENDED); + vm->set_state(VirtualMachine::LCM_INIT); + + vmpool->update(vm); + + vm->log("LCM", Log::INFO, "Fail to boot VM. New VM state is SUSPENDED"); + } vm->unlock(); } From 6669d31f2f0e277f6b8882e5a04cac8c6d4e18e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 17 Oct 2012 12:38:38 +0200 Subject: [PATCH 2/9] Bug #1210: Add BOOT_SUSPENDED state to OCA (both Ruby & Java) --- .../java/src/org/opennebula/client/vm/VirtualMachine.java | 4 +++- src/oca/ruby/OpenNebula/VirtualMachine.rb | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java index fe8d3756aa..fb88888e6c 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java @@ -86,7 +86,8 @@ public class VirtualMachine extends PoolElement{ "HOTPLUG", "SHUTDOWN_POWEROFF", "BOOT_UNKNOWN", - "BOOT_POWEROFF" }; + "BOOT_POWEROFF", + "BOOT_SUSPENDED" }; private static final String[] SHORT_LCM_STATES = { @@ -110,6 +111,7 @@ public class VirtualMachine extends PoolElement{ "hotp", "poff", "boot", + "boot", "boot" }; /** diff --git a/src/oca/ruby/OpenNebula/VirtualMachine.rb b/src/oca/ruby/OpenNebula/VirtualMachine.rb index ccab73f4e2..8ef1c1c8d3 100644 --- a/src/oca/ruby/OpenNebula/VirtualMachine.rb +++ b/src/oca/ruby/OpenNebula/VirtualMachine.rb @@ -44,7 +44,7 @@ module OpenNebula LCM_STATE=%w{LCM_INIT PROLOG BOOT RUNNING MIGRATE SAVE_STOP SAVE_SUSPEND SAVE_MIGRATE PROLOG_MIGRATE PROLOG_RESUME EPILOG_STOP EPILOG SHUTDOWN CANCEL FAILURE CLEANUP UNKNOWN HOTPLUG SHUTDOWN_POWEROFF - BOOT_UNKNOWN BOOT_POWEROFF} + BOOT_UNKNOWN BOOT_POWEROFF BOOT_SUSPENDED} SHORT_VM_STATES={ "INIT" => "init", @@ -78,7 +78,8 @@ module OpenNebula "HOTPLUG" => "hotp", "SHUTDOWN_POWEROFF" => "shut", "BOOT_UNKNOWN" => "boot", - "BOOT_POWEROFF" => "boot" + "BOOT_POWEROFF" => "boot", + "BOOT_SUSPENDED" => "boot" } MIGRATE_REASON=%w{NONE ERROR STOP_RESUME USER CANCEL} From 9640ed1d84f0ec252e8dec930956c2f8579c9d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 17 Oct 2012 12:43:27 +0200 Subject: [PATCH 3/9] Bug #1210: Add BOOT_SUSPENDED state to oZones and Sunstone --- src/ozones/Server/public/js/ozones.js | 3 ++- src/sunstone/public/js/opennebula.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ozones/Server/public/js/ozones.js b/src/ozones/Server/public/js/ozones.js index c72410e95f..5b4630dc26 100644 --- a/src/ozones/Server/public/js/ozones.js +++ b/src/ozones/Server/public/js/ozones.js @@ -99,7 +99,8 @@ var oZones = { "HOTPLUG", "SHUTDOWN_POWEROFF", "BOOT_UNKNOWN", - "BOOT_POWEROFF"][value]); + "BOOT_POWEROFF", + "BOOT_SUSPENDED"][value]); break; case "IMAGE": case "image": diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index c65cefdafa..16dc8407d0 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -107,7 +107,8 @@ var OpenNebula = { "HOTPLUG", "SHUTDOWN_POWEROFF", "BOOT_UNKNOWN", - "BOOT_POWEROFF"][value]); + "BOOT_POWEROFF", + "BOOT_SUSPENDED"][value]); break; case "IMAGE": case "image": From 2f5f581314b4cf0b491b87b08f80cd883923ae8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 17 Oct 2012 12:53:22 +0200 Subject: [PATCH 4/9] Bug #1210: Add BOOT_SUSPENDED state to xsd and dot documentation files --- share/doc/states/states-complete.dot | 17 +++++++++++------ share/doc/xsd/acct.xsd | 1 + share/doc/xsd/vm.xsd | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/share/doc/states/states-complete.dot b/share/doc/states/states-complete.dot index 1bbf5c456b..4d2666a96a 100644 --- a/share/doc/states/states-complete.dot +++ b/share/doc/states/states-complete.dot @@ -19,7 +19,7 @@ digraph OpenNebula { "ANY \\ {suspended,done}" [ shape="box" ]; subgraph { rank = min; user} - subgraph { rank = same; boot; boot_unknown; boot_poweroff; unknown; color="white"} + subgraph { rank = same; boot; boot_suspended; boot_unknown; boot_poweroff; unknown; color="white"} subgraph { rank = same; pending; hold; color="white"} subgraph { rank = same; prolog; prolog_resume; prolog_migrate; color="white" } @@ -76,24 +76,25 @@ digraph OpenNebula { save_suspend -> suspended [style="dashed"]; # resume - stopped -> pending [label="resume"]; - suspended -> boot [label="resume"]; + stopped -> pending [label="resume"]; + + suspended -> boot_suspended [label="resume"]; + boot_suspended -> running [style="dashed"]; # delete ANY -> done [label="delete"]; # restart boot -> boot [label="restart"]; + boot_suspended -> boot_suspended [label="restart"]; poweroff -> boot_poweroff [label="restart"]; boot_poweroff -> boot_poweroff [label="restart"]; boot_poweroff -> running [style="dashed"]; - boot_poweroff -> poweroff [style="dotted"]; unknown -> boot_unknown [label="restart"]; boot_unknown -> boot_unknown [label="restart"]; boot_unknown -> running [style="dashed"]; - boot_unknown -> unknown [style="dotted"]; # reboot, reset running -> running [label="reboot / reset"]; @@ -108,11 +109,15 @@ digraph OpenNebula { # failures and misc. epilog_stop -> failure [style="dotted"]; epilog -> failure [style="dotted"]; + prolog -> failure [style="dotted"]; prolog_migrate -> failure [style="dotted"]; prolog_resume -> failure [style="dotted"]; - boot -> failure [style="dotted"]; + boot -> failure [style="dotted"]; + boot_poweroff -> poweroff [style="dotted"]; + boot_unknown -> unknown [style="dotted"]; + boot_suspended -> suspended [style="dotted"]; running -> unknown [style="dotted"]; unknown -> running [style="dashed"]; diff --git a/share/doc/xsd/acct.xsd b/share/doc/xsd/acct.xsd index c5fa3f6919..f4eef959de 100644 --- a/share/doc/xsd/acct.xsd +++ b/share/doc/xsd/acct.xsd @@ -103,6 +103,7 @@ SHUTDOWN_POWEROFF = 18 BOOT_UNKNOWN = 19 BOOT_POWEROFF = 20 + BOOT_SUSPENDED = 21 --> diff --git a/share/doc/xsd/vm.xsd b/share/doc/xsd/vm.xsd index a30ecfe3c3..ca5f8c792a 100644 --- a/share/doc/xsd/vm.xsd +++ b/share/doc/xsd/vm.xsd @@ -65,6 +65,7 @@ SHUTDOWN_POWEROFF = 18 BOOT_UNKNOWN = 19 BOOT_POWEROFF = 20 + BOOT_SUSPENDED = 21 --> From 04a4fe96068099ce6567bd3d7cf01277b8b13776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 17 Oct 2012 15:40:02 +0200 Subject: [PATCH 5/9] Bug #1210: Add new VM LCM state in core, BOOT_STOPPED. A failed boot returns the VM to EPILOG_STOP -> STOPPED --- include/VirtualMachine.h | 3 ++- src/dm/DispatchManagerActions.cc | 3 ++- src/lcm/LifeCycleActions.cc | 7 ++++-- src/lcm/LifeCycleStates.cc | 37 +++++++++++++++++++++++++++++++- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 97ad9d626a..0428156b11 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -86,7 +86,8 @@ public: SHUTDOWN_POWEROFF = 18, BOOT_UNKNOWN = 19, BOOT_POWEROFF = 20, - BOOT_SUSPENDED = 21 + BOOT_SUSPENDED = 21, + BOOT_STOPPED = 22 }; // ------------------------------------------------------------------------- diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc index 15eab25ee2..efeb0e9798 100644 --- a/src/dm/DispatchManagerActions.cc +++ b/src/dm/DispatchManagerActions.cc @@ -557,7 +557,8 @@ int DispatchManager::restart(int vid) vm->get_lcm_state() == VirtualMachine::BOOT || vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN || vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF || - vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED)) + vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED || + vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED)) || vm->get_state() == VirtualMachine::POWEROFF ) { Nebula& nd = Nebula::instance(); diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index da5432dc49..a4a84a8198 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -501,7 +501,8 @@ void LifeCycleManager::restart_action(int vid) vm->get_lcm_state() == VirtualMachine::BOOT || vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN || vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF || - vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED)) + vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED || + vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED)) ||vm->get_state() == VirtualMachine::POWEROFF) { Nebula& nd = Nebula::instance(); @@ -515,7 +516,8 @@ void LifeCycleManager::restart_action(int vid) (vm->get_lcm_state() == VirtualMachine::BOOT || vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN || vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF || - vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED)) + vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED || + vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED)) { vm->log("LCM", Log::INFO, "Sending BOOT command to VM again"); } @@ -662,6 +664,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) case VirtualMachine::BOOT_UNKNOWN: case VirtualMachine::BOOT_POWEROFF: case VirtualMachine::BOOT_SUSPENDED: + case VirtualMachine::BOOT_STOPPED: case VirtualMachine::RUNNING: case VirtualMachine::UNKNOWN: case VirtualMachine::SHUTDOWN: diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index d38c2ca92c..9a2ee62375 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -382,6 +382,34 @@ void LifeCycleManager::deploy_failure_action(int vid) vm->log("LCM", Log::INFO, "Fail to boot VM. New VM state is SUSPENDED"); } + else if (vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED) + { + Nebula& nd = Nebula::instance(); + TransferManager * tm = nd.get_tm(); + time_t the_time = time(0); + + //---------------------------------------------------- + // EPILOG_STOP STATE FROM BOOT + //---------------------------------------------------- + + vm->set_state(VirtualMachine::EPILOG_STOP); + + vmpool->update(vm); + + vm->set_epilog_stime(the_time); + + vm->set_running_etime(the_time); + + vm->set_reason(History::ERROR); + + vmpool->update_history(vm); + + vm->log("LCM", Log::INFO, "Fail to boot VM. New VM state is EPILOG_STOP"); + + //---------------------------------------------------- + + tm->trigger(TransferManager::EPILOG_STOP,vid); + } vm->unlock(); } @@ -533,7 +561,14 @@ void LifeCycleManager::prolog_success_action(int vid) // BOOT STATE //---------------------------------------------------- - vm->set_state(VirtualMachine::BOOT); + if ( lcm_state == VirtualMachine::PROLOG_RESUME ) + { + vm->set_state(VirtualMachine::BOOT_STOPPED); + } + else // PROLOG || PROLOG_MIGRATE + { + vm->set_state(VirtualMachine::BOOT); + } vmpool->update(vm); From ae8a187534f7cfd7490303866ceb4cf36bb7e2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 17 Oct 2012 15:44:21 +0200 Subject: [PATCH 6/9] Bug #1210: Add BOOT_STOPPED state to OCA (both Ruby & Java), Sunstone and oZones --- .../java/src/org/opennebula/client/vm/VirtualMachine.java | 4 +++- src/oca/ruby/OpenNebula/VirtualMachine.rb | 5 +++-- src/ozones/Server/public/js/ozones.js | 3 ++- src/sunstone/public/js/opennebula.js | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java index fb88888e6c..d402c835d2 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java @@ -87,7 +87,8 @@ public class VirtualMachine extends PoolElement{ "SHUTDOWN_POWEROFF", "BOOT_UNKNOWN", "BOOT_POWEROFF", - "BOOT_SUSPENDED" }; + "BOOT_SUSPENDED", + "BOOT_STOPPED" }; private static final String[] SHORT_LCM_STATES = { @@ -112,6 +113,7 @@ public class VirtualMachine extends PoolElement{ "poff", "boot", "boot", + "boot", "boot" }; /** diff --git a/src/oca/ruby/OpenNebula/VirtualMachine.rb b/src/oca/ruby/OpenNebula/VirtualMachine.rb index 8ef1c1c8d3..5e7c061c8b 100644 --- a/src/oca/ruby/OpenNebula/VirtualMachine.rb +++ b/src/oca/ruby/OpenNebula/VirtualMachine.rb @@ -44,7 +44,7 @@ module OpenNebula LCM_STATE=%w{LCM_INIT PROLOG BOOT RUNNING MIGRATE SAVE_STOP SAVE_SUSPEND SAVE_MIGRATE PROLOG_MIGRATE PROLOG_RESUME EPILOG_STOP EPILOG SHUTDOWN CANCEL FAILURE CLEANUP UNKNOWN HOTPLUG SHUTDOWN_POWEROFF - BOOT_UNKNOWN BOOT_POWEROFF BOOT_SUSPENDED} + BOOT_UNKNOWN BOOT_POWEROFF BOOT_SUSPENDED BOOT_STOPPED} SHORT_VM_STATES={ "INIT" => "init", @@ -79,7 +79,8 @@ module OpenNebula "SHUTDOWN_POWEROFF" => "shut", "BOOT_UNKNOWN" => "boot", "BOOT_POWEROFF" => "boot", - "BOOT_SUSPENDED" => "boot" + "BOOT_SUSPENDED" => "boot", + "BOOT_STOPPED" => "boot" } MIGRATE_REASON=%w{NONE ERROR STOP_RESUME USER CANCEL} diff --git a/src/ozones/Server/public/js/ozones.js b/src/ozones/Server/public/js/ozones.js index 5b4630dc26..3a1d54501a 100644 --- a/src/ozones/Server/public/js/ozones.js +++ b/src/ozones/Server/public/js/ozones.js @@ -100,7 +100,8 @@ var oZones = { "SHUTDOWN_POWEROFF", "BOOT_UNKNOWN", "BOOT_POWEROFF", - "BOOT_SUSPENDED"][value]); + "BOOT_SUSPENDED", + "BOOT_STOPPED"][value]); break; case "IMAGE": case "image": diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index 16dc8407d0..5c1f5d53c4 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -108,7 +108,8 @@ var OpenNebula = { "SHUTDOWN_POWEROFF", "BOOT_UNKNOWN", "BOOT_POWEROFF", - "BOOT_SUSPENDED"][value]); + "BOOT_SUSPENDED", + "BOOT_STOPPED"][value]); break; case "IMAGE": case "image": From c05870367d26e024780411cc0805bb2ee75272dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 17 Oct 2012 15:46:57 +0200 Subject: [PATCH 7/9] Bug #1210: Add BOOT_STOPPED state to xsd and dot documentation files --- share/doc/states/states-complete.dot | 31 +++++++++++++++------------- share/doc/xsd/acct.xsd | 1 + share/doc/xsd/vm.xsd | 1 + 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/share/doc/states/states-complete.dot b/share/doc/states/states-complete.dot index 4d2666a96a..8ecb7a3713 100644 --- a/share/doc/states/states-complete.dot +++ b/share/doc/states/states-complete.dot @@ -16,23 +16,23 @@ digraph OpenNebula { fontcolor="white", fontsize= "24.0"]; ANY [ shape="box" ]; - "ANY \\ {suspended,done}" [ shape="box" ]; + "ANY \\ {suspended,poweroff,done}" [ shape="box" ]; subgraph { rank = min; user} - subgraph { rank = same; boot; boot_suspended; boot_unknown; boot_poweroff; unknown; color="white"} + subgraph { rank = same; boot; boot_stopped boot_suspended; boot_unknown; boot_poweroff; unknown; color="white"} subgraph { rank = same; pending; hold; color="white"} subgraph { rank = same; prolog; prolog_resume; prolog_migrate; color="white" } subgraph { rank = max; suspended; done; failure; - stopped; poweroff; color="white" } + stopped; poweroff; ANY; color="white" } # create user -> pending [label="create"]; # deploy - pending -> prolog_resume [label="deploy"]; - prolog_resume -> boot [style="dashed"]; + pending -> prolog_resume [label="deploy (from stopped)"]; + prolog_resume -> boot_stopped [style="dashed"]; pending -> prolog [label="deploy"]; prolog -> boot [style="dashed"]; @@ -77,6 +77,7 @@ digraph OpenNebula { # resume stopped -> pending [label="resume"]; + boot_stopped -> running [style="dashed"]; suspended -> boot_suspended [label="resume"]; boot_suspended -> running [style="dashed"]; @@ -85,16 +86,17 @@ digraph OpenNebula { ANY -> done [label="delete"]; # restart - boot -> boot [label="restart"]; - boot_suspended -> boot_suspended [label="restart"]; + boot -> boot [label="restart"]; + boot_suspended -> boot_suspended [label="restart"]; + boot_stopped -> boot_stopped [label="restart"]; - poweroff -> boot_poweroff [label="restart"]; - boot_poweroff -> boot_poweroff [label="restart"]; - boot_poweroff -> running [style="dashed"]; + poweroff -> boot_poweroff [label="restart"]; + boot_poweroff -> boot_poweroff [label="restart"]; + boot_poweroff -> running [style="dashed"]; - unknown -> boot_unknown [label="restart"]; - boot_unknown -> boot_unknown [label="restart"]; - boot_unknown -> running [style="dashed"]; + unknown -> boot_unknown [label="restart"]; + boot_unknown -> boot_unknown [label="restart"]; + boot_unknown -> running [style="dashed"]; # reboot, reset running -> running [label="reboot / reset"]; @@ -104,7 +106,7 @@ digraph OpenNebula { hotplug -> running [style="dashed"]; # resubmit - "ANY \\ {suspended,done}" -> pending [label="resubmit"]; + "ANY \\ {suspended,poweroff,done}" -> pending [label="resubmit"]; # failures and misc. epilog_stop -> failure [style="dotted"]; @@ -118,6 +120,7 @@ digraph OpenNebula { boot_poweroff -> poweroff [style="dotted"]; boot_unknown -> unknown [style="dotted"]; boot_suspended -> suspended [style="dotted"]; + boot_stopped -> epilog_stop [style="dotted"]; running -> unknown [style="dotted"]; unknown -> running [style="dashed"]; diff --git a/share/doc/xsd/acct.xsd b/share/doc/xsd/acct.xsd index f4eef959de..8403b8120b 100644 --- a/share/doc/xsd/acct.xsd +++ b/share/doc/xsd/acct.xsd @@ -104,6 +104,7 @@ BOOT_UNKNOWN = 19 BOOT_POWEROFF = 20 BOOT_SUSPENDED = 21 + BOOT_STOPPED = 22 --> diff --git a/share/doc/xsd/vm.xsd b/share/doc/xsd/vm.xsd index ca5f8c792a..e341b8525a 100644 --- a/share/doc/xsd/vm.xsd +++ b/share/doc/xsd/vm.xsd @@ -66,6 +66,7 @@ BOOT_UNKNOWN = 19 BOOT_POWEROFF = 20 BOOT_SUSPENDED = 21 + BOOT_STOPPED = 22 --> From 22e605c7ec21d2e9e94e334dc99bb67ceb15d10e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 17 Oct 2012 16:34:08 +0200 Subject: [PATCH 8/9] Bug #1210: Fix bug in commit:04a4fe9, a failed PROLOG_RESUME must have STOP_RESUME history reason, otherwise the transition STOPPED->PENDING->PROLOG_RESUME will end in PENDING->PROLOG --- src/lcm/LifeCycleStates.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index 9a2ee62375..f67440c43a 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -400,7 +400,7 @@ void LifeCycleManager::deploy_failure_action(int vid) vm->set_running_etime(the_time); - vm->set_reason(History::ERROR); + vm->set_reason(History::STOP_RESUME); vmpool->update_history(vm); From 41d78ded1f80a27b2d04989cd7a75dffdd456626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 17 Oct 2012 16:58:20 +0200 Subject: [PATCH 9/9] Bug #1210: On prolog failure, add the transition PROLOG_RESUME -> STOPPED --- share/doc/states/states-complete.dot | 13 +++---- src/dm/DispatchManagerStates.cc | 3 +- src/lcm/LifeCycleStates.cc | 51 ++++++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/share/doc/states/states-complete.dot b/share/doc/states/states-complete.dot index 8ecb7a3713..4154907b57 100644 --- a/share/doc/states/states-complete.dot +++ b/share/doc/states/states-complete.dot @@ -3,7 +3,7 @@ digraph OpenNebula { graph [ nodesep=0.5, - ratio=0.8, + ratio=1, pad=0.5, ]; @@ -21,17 +21,18 @@ digraph OpenNebula { subgraph { rank = min; user} subgraph { rank = same; boot; boot_stopped boot_suspended; boot_unknown; boot_poweroff; unknown; color="white"} subgraph { rank = same; pending; hold; color="white"} - subgraph { rank = same; prolog; prolog_resume; prolog_migrate; - color="white" } + subgraph { rank = same; prolog; prolog_resume; prolog_migrate; color="white" } +// subgraph { rank = same; prolog; prolog_resume; prolog_migrate; save_migrate; color="white" } subgraph { rank = max; suspended; done; failure; stopped; poweroff; ANY; color="white" } +// stopped; poweroff; color="white" } # create user -> pending [label="create"]; # deploy - pending -> prolog_resume [label="deploy (from stopped)"]; + pending -> prolog_resume [label="deploy\n(from stopped)"]; prolog_resume -> boot_stopped [style="dashed"]; pending -> prolog [label="deploy"]; @@ -102,7 +103,7 @@ digraph OpenNebula { running -> running [label="reboot / reset"]; # attachdisk - running -> hotplug [label="attachdisk / detachdisk"] + running -> hotplug [label="attachdisk /\ndetachdisk"] hotplug -> running [style="dashed"]; # resubmit @@ -114,7 +115,7 @@ digraph OpenNebula { prolog -> failure [style="dotted"]; prolog_migrate -> failure [style="dotted"]; - prolog_resume -> failure [style="dotted"]; + prolog_resume -> stopped [style="dotted"]; boot -> failure [style="dotted"]; boot_poweroff -> poweroff [style="dotted"]; diff --git a/src/dm/DispatchManagerStates.cc b/src/dm/DispatchManagerStates.cc index 169741ea11..98053f2565 100644 --- a/src/dm/DispatchManagerStates.cc +++ b/src/dm/DispatchManagerStates.cc @@ -70,7 +70,8 @@ void DispatchManager::stop_success_action(int vid) } if ((vm->get_state() == VirtualMachine::ACTIVE) && - (vm->get_lcm_state() == VirtualMachine::EPILOG_STOP)) + (vm->get_lcm_state() == VirtualMachine::EPILOG_STOP || + vm->get_lcm_state() == VirtualMachine::PROLOG_RESUME)) { vm->set_state(VirtualMachine::STOPPED); diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index f67440c43a..e5f5c58f9c 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -594,7 +594,9 @@ void LifeCycleManager::prolog_success_action(int vid) void LifeCycleManager::prolog_failure_action(int vid) { - VirtualMachine * vm; + VirtualMachine::LcmState state; + VirtualMachine * vm; + time_t the_time = time(0); vm = vmpool->get(vid,true); @@ -604,9 +606,52 @@ void LifeCycleManager::prolog_failure_action(int vid) return; } - vm->set_prolog_etime(the_time); + state = vm->get_lcm_state(); - failure_action(vm); + if ( state == VirtualMachine::PROLOG || + state == VirtualMachine::PROLOG_MIGRATE ) + { + vm->set_prolog_etime(the_time); + + failure_action(vm); + } + else if ( state == VirtualMachine::PROLOG_RESUME ) + { + //---------------------------------------------------- + // STOPPED STATE FROM PROLOG_RESUME + //---------------------------------------------------- + + Nebula& nd = Nebula::instance(); + DispatchManager * dm = nd.get_dm(); + + int cpu,mem,disk; + + vm->set_prolog_etime(the_time); + + vm->set_resched(false); + + vmpool->update(vm); + + vm->set_etime(the_time); + + vm->set_vm_info(); + + vm->set_reason(History::STOP_RESUME); + + vmpool->update_history(vm); + + vm->get_requirements(cpu,mem,disk); + + hpool->del_capacity(vm->get_hid(),cpu,mem,disk); + + //---------------------------------------------------- + + dm->trigger(DispatchManager::STOP_SUCCESS,vid); + } + else + { + vm->log("LCM",Log::ERROR,"prolog_failure_action, VM in a wrong state"); + } vm->unlock();