I have an Ubuntu server running xen (with xen-tools only) and when the server experiences a power failure I have to manually run xl create /etc/xen/MY_DOMU_GUEST.cfg
to restart the vm.
My config settings for restarting look like this:
/etc/xen/MY_DOMU_GUEST.cfg
:
on_poweroff = 'restart'
on_reboot = 'restart'
on_crash = 'restart'
But it doesn't start on dom0 boot. Am I missing something?
I found the answer here: https://askubuntu.com/questions/196444/how-do-i-auto-start-xen-guests-on-boot/906499#906499
The Short Answer
To load all config files on boot link the
auto
folder directly to/etc/xen
:To load only specific config files link each individually:
Explanation
There's a lesser-known
xen
config file/etc/default/xendomains
.There you can find in the comments documentation for three default settings:
To summarize the docs:
XENDOMAINS_SAVE
causes the VMs to be saved on a properreboot
.XENDOMAINS_RESTORE
causes the VMs to be brought back up from the saved state when saved (whether saved manually withxl save
or due to host reboot).XENDOMAINS_AUTO
specifies a folder from which to load configs for VMs when no save state exists (i.e.XENDOMAINS_SAVE
is disabled or there was a power failure or explicitshutdown
instead of areboot
)If you create the
auto
folder under/etc/xen
and give it symlinks to the config file of the virtual machine (DomU guest) you'd like to start on physical machine (Dom0 host) then generally speaking they'll restore from the saved state that happens during the physical (host) server on reboot, but when that isn't available (such as after a shutdown or power failure or crash), they'll still load anyway.If you'd rather always have the VMs shutdown on reboot rather than save state you can set
XENDOMAINS_SAVE=
andXENDOMAINS_RESTORE=false
.The Old Way
It used to be that where there is now
on_shutdown
,on_reboot
, andon_crash
that you could also configureon_xend_start = 'start'
andon_xend_stop = 'shutdown'
... but those are not the current practice.Current (apply to the VM state itself):
Ignored / Deprecated (apply to the host state):
I know this is old post but there is an easier way.
Create a script MyScripNameHere.sh in this script add the following syntax, and add appropriate permissions to execute as root.
#!/bin/bash
export PATH=/opt/xensource/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr
sleep 60
xe vm-start vm="VMNAMEHERE1"
sleep 5
xe vm-start vm="VMNAMEHERE2"
Then add the path to the script in rc.local , however before execution add sleep 60 This will autostart all the VM in the script list. This is if you do not want to deal with UUID or pooling.