0

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?

0

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:

ln -s /etc/xen/ /etc/xen/auto

To load only specific config files link each individually:

mkdir -p /etc/xen/auto
ln -s /etc/xen/MY_DOMU_GUEST_1.cfg /etc/xen/auto/
ln -s /etc/xen/MY_DOMU_GUEST_2.cfg /etc/xen/auto/

Explanation

There's a lesser-known xen config file /etc/default/xendomains.

There you can find in the comments documentation for three default settings:

XENDOMAINS_SAVE=/var/lib/xen/save
XENDOMAINS_RESTORE=true
XENDOMAINS_AUTO=/etc/xen/auto

To summarize the docs:

  • XENDOMAINS_SAVE causes the VMs to be saved on a proper reboot.

  • XENDOMAINS_RESTORE causes the VMs to be brought back up from the saved state when saved (whether saved manually with xl 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 explicit shutdown instead of a reboot)

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= and XENDOMAINS_RESTORE=false.

The Old Way

It used to be that where there is now on_shutdown, on_reboot, and on_crash that you could also configure on_xend_start = 'start' and on_xend_stop = 'shutdown'... but those are not the current practice.

Current (apply to the VM state itself):

on_shutdown = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'

Ignored / Deprecated (apply to the host state):

on_xend_start = 'start'
on_xend_stop = 'shutdown'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.