From: corubba Date: Sun, 27 Mar 2022 00:36:20 +0000 (+0100) Subject: tools: lxc-autostart: Reverse order on stop X-Git-Tag: lxc-5.0.0~24^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f8d14f72d1452089d8cea9db8e98b515c982603;p=thirdparty%2Flxc.git tools: lxc-autostart: Reverse order on stop As it was already discussed in lxc/lxd#2082, containers should be stopped in the opposite order they are started in. LXD does so already, lxc should do the same. Signed-off-by: Corubba Smith --- diff --git a/src/lxc/tools/lxc_autostart.c b/src/lxc/tools/lxc_autostart.c index 91596d4f6..062135d40 100644 --- a/src/lxc/tools/lxc_autostart.c +++ b/src/lxc/tools/lxc_autostart.c @@ -282,6 +282,11 @@ static int cmporder(const void *p1, const void *p2) return (c1_order - c2_order); } +static int cmporder_reverse(const void *p1, const void *p2) +{ + return -1 * cmporder(p1, p2); +} + static int toss_list(struct lxc_list *c_groups_list) { struct lxc_list *it, *next; @@ -332,7 +337,8 @@ int main(int argc, char *argv[]) if (!my_args.all) c_groups_lists = calloc( count, sizeof( struct lxc_list * ) ); - qsort(&containers[0], count, sizeof(struct lxc_container *), cmporder); + qsort(&containers[0], count, sizeof(struct lxc_container *), + (my_args.shutdown || my_args.hardstop) ? cmporder_reverse : cmporder); if (cmd_groups_list && my_args.all) ERROR("Specifying -a (all) with -g (groups) doesn't make sense. All option overrides");