# Migrate VM on host crash

**URL:** <https://forum.opennebula.io/t/migrate-vm-on-host-crash/648>\
**Category:** Product Support\
**Created:** [April 26, 2015, 9:21pm UTC](https://forum.opennebula.io/t/migrate-vm-on-host-crash/648 "2015-04-26T21:21:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![karsten](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@karsten](https://forum.opennebula.io/u/karsten)\
**Post date:** [April 26, 2015, 9:21pm UTC](https://forum.opennebula.io/t/migrate-vm-on-host-crash/648/1 "2015-04-26T21:21:13Z")

</div>

Hi,

I use Ceph for shared storage and cephfs for system store. I have not setup the hosts in a cluster.

Is there some way that I can setup a per VM auto recover function when a host is in failor ?  
Is there som API call that I can call from my monitoring that gets trickered if a host is down together with a given VM to automaticly migrate + start the lost VM on a running host.

Thanks,

- Karsten

---

<div class="post-metadata">

**Author:** ![thomasalrin](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/thomasalrin/32/4297_2.png) [@thomasalrin](https://forum.opennebula.io/u/thomasalrin)\
**Post date:** [April 27, 2015, 6:52am UTC](https://forum.opennebula.io/t/migrate-vm-on-host-crash/648/2 "2015-04-27T06:52:56Z")

</div>

Hi Karsten,

I think, vm hooks can solve your problem.  
Refer [http://docs.opennebula.org/4.12/integration/infrastructure\_integration/hooks.html](http://docs.opennebula.org/4.12/integration/infrastructure_integration/hooks.html)

---

<div class="post-metadata">

**Author:** ![cmartin](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/cmartin/32/4278_2.png) [@cmartin](https://forum.opennebula.io/u/cmartin)\
**Post date:** [April 28, 2015, 9:21am UTC](https://forum.opennebula.io/t/migrate-vm-on-host-crash/648/3 "2015-04-28T09:21:36Z")

</div>

Hi,

As @thomasalrin said, you can use a hook for that.  
The fault tolerance hook included in oned.conf has a -m option to do exactly that: migrate VMs to a new host when a host reaches the failure state.

```
# *******************************************************************************
# Fault Tolerance Hooks
# *******************************************************************************
# This hook is used to perform recovery actions when a host fails.
# Script to implement host failure tolerance
# It can be set to
# -m migrate VMs to another host. Only for images in shared storage
# -r recreate VMs running in the host. State will be lost.
# -d delete VMs running in the host
# Additional flags
# -f force resubmission of suspended VMs
# -p <n> avoid resubmission if host comes
# back after n monitoring cycles
# *******************************************************************************

HOST_HOOK = [
    name = "error",
    on = "ERROR",
    command = "ft/host_error.rb",
    arguments = "$ID -m -p 5",
    remote = "no" ]
#-------------------------------------------------------------------------------
```

---

<div class="post-metadata">

**Author:** ![bpsRobert](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@bpsRobert](https://forum.opennebula.io/u/bpsRobert)\
**Post date:** [July 20, 2015, 3:47pm UTC](https://forum.opennebula.io/t/migrate-vm-on-host-crash/648/4 "2015-07-20T15:47:39Z")

</div>

Are these hook options “-m” for migrate, available in one4.8 also?

---

<div class="post-metadata">

**Author:** ![cmartin](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/cmartin/32/4278_2.png) [@cmartin](https://forum.opennebula.io/u/cmartin)\
**Post date:** [July 21, 2015, 9:58am UTC](https://forum.opennebula.io/t/migrate-vm-on-host-crash/648/5 "2015-07-21T09:58:18Z")

</div>

No, the migrate option was introduced in ONE 4.10

---

<div class="post-metadata">

**Author:** ![karsten](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@karsten](https://forum.opennebula.io/u/karsten)\
**Post date:** [December 17, 2015, 4:19pm UTC](https://forum.opennebula.io/t/migrate-vm-on-host-crash/648/6 "2015-12-17T16:19:10Z")

</div>

I know it has been a while, but thanks for your repsons.
