[lxc-devel] lxc.start.order bug - containers started in reverse order

St├ęphane Graber stgraber at ubuntu.com
Mon Apr 6 15:46:19 UTC 2015

On Wed, Mar 04, 2015 at 08:18:08PM +0100, Bostjan Skufca wrote:
> Hi there,
> I was trying to use lxc-autostart (v1.0.7, but git-master is the same) and
> realised containers are started in reverse order.
> As configuration parameter is called lxc.start.ORDER, one expects that
> container with order setting "1" will start before container with order
> setting set to "2", but this is not the case. Containers start in reverse
> order. If that is the desired behaviour, then I believe "order" should be
> called "priority" or sth.
> Anyway, I looked into src/lxc/lxc_autostart.c, and found this:
> # in main() this is called:
> qsort(&containers[0], count, sizeof(struct lxc_container *), cmporder);
> # in cmporder() the last comparison looks like this:
> return (c1_order - c2_order) * -1;
> qsort() sorts elements from lower to higher value, using callback
> cmporder(). Therefore cmporder() should return negative value if container
> c1 should be started before c2. That "* -1" achieves exactly the oposite
> result, as it causes containers to be sorted in descending order regarding
> to their order setting.
> I've submitted a pull request on github for this:
> https://github.com/lxc/lxc/pull/461
> b.

As nobody complained, I've now merged the change.

Note that I will not be pushing this to earlier releases as that'd be a
clear change of behavior for existing setups (even though the new order
is right).

St├ęphane Graber
Ubuntu developer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20150406/e539696f/attachment.sig>

More information about the lxc-devel mailing list