[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] libvirt-guests - order of stopping/starting guests



Hi all,
on a previous thread [1] Eric Blake mentioned:

Without more code on the libvirt front, I think you're stuck renaming
the guests to enforce naming order (assuming that libvirt even goes by
sorted name order, as opposed to readdir() order where you have no control).

I poked around the code and experimented a little bit and found the following.

* When you first create new guest (or start already created guest) it is assigned a sequential ID, name and also UUID. IDs start from 1 and increase as long as libvirtd is running.

* When libvirt-guests wants to start/shutdown guests it relies on the file /var/lib/libvirt/libvirt-guests. The format of this file is:
URI <list of uuids>

libvirt-guests script will start the guests as written in the file.

* The libvirt-guests file is initially created from the output of `virsh list' and `virsh dominfo' (to get the UUID). virsh list will list the guests ordered by their ID.

* Order of starting/stopping guests is unreliable.


The only thing that matters wrt start/shutdown order is the guest ID at the time when the libvirt-guests file is generated. By default the order is the order in which guests were created and it can change if you randomly stop/start guests while libvirtd is running . Names or UUIDs don't play here at all.

I'm not exactly sure what IDs are used for but they change every time when a guest is stopped/started manually. Which in turn reflects the order in which libvirt-guests stops/starts all guests.

Example:
On a freshly installed system I created 5 guests in the following order:
a1, b1, a2, c1, a11. Then I left all guests running.

Upon stop/start of the libvirt-guests service the guests were stoped/started in the same order.

Then I stopped libvirt-guests and libvirtd, renamed a1 to c2 and restarted both services. c2 was first in the list - name doesn't matter.

virsh list shows IDs are 1 to 5 (c2 = 1).

Then I did: virsh shutdown c2 && virsh start c2. c2 now has id of 6.

Doing service libvirt-guests stop/start again now showed me a different order:
b1, a2, c1, a11, c2


You see how the order in which guests are started/stopped is unreliable. If I were to stop c1 while all other guests were running and then start it again (e.g. after attaching a new disk image) then it will have the highest ID number and will become last in the list used for stopping/starting guests.


I'm not sure if this can easily be fixed or it needs the concept of groups/relations implemented.


[1] - https://www.redhat.com/archives/libvir-list/2011-April/msg00789.html

Regards,
Alexander.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]