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

Bostjan Skufca bostjan at a2o.si
Wed Mar 4 19:18:08 UTC 2015


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20150304/5d891bd1/attachment.html>


More information about the lxc-devel mailing list