Merge pull request #4099 from corubba/feature/stop-order

tools: lxc-autostart: Reverse order on stop
This commit is contained in:
Stéphane Graber 2022-03-30 11:40:16 -04:00 committed by GitHub
commit d09a31dba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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");