Set startup order for KVM virtual machines via libvirt?

7,051

Solution 1

libvirt only provides the autostart function. If this is important for you, I would set up an init script that starts VMs in a certain order. The algorithm would be virsh start VM1; wait for service to come up (check with ping/snmp/telnet to relevant ports); virsh start VM2 and so on

Solution 2

You could use sleeps in the RC init scripts, but I would change the server applications to check for the existence of db's and any other dependencies before starting. Much better to have the test happen at the application, rather than in the HV-guest configuration.

If you can't change the app itself, then you can use its init script to make the test.

Solution 3

You can also use KVM_AutoBoot ( https://github.com/eduardolucioac/kvm_autoboot ) to start one or several virtual machines at server boot using KVM (libvirt). It is also possible to define an interval between the start of a virtual machine and the next one.

Thanks! =D

Share:
7,051

Related videos on Youtube

hdave
Author by

hdave

Updated on September 18, 2022

Comments

  • hdave
    hdave over 1 year

    I have some server applications failing because their virtual machine starts up before the database virtual machines. Anyway to configure libvirt to start them up in a certain order and possible insert delays in front of some of them?

    Running libvirt 0.9.8 on Ubuntu 12.04 x64. Most of the guests are also Ubuntu Server 12.04.

  • John Wang
    John Wang over 10 years
    I have the same trouble and tried init script solution. But it didn't work. There maybe some problem in my script since I'm not good at shell script. Could you please have a look and help me out? It's here
  • David Corsalini
    David Corsalini over 10 years
    those symlinks are generated by libvirt and are not there to be placed manually. If you want to know what else libvirt does besides creating those symlinks, you should read the code