From: Eric Blake Date: Fri, 7 Oct 2011 21:55:59 +0000 (-0600) Subject: snapshot: sort snapshot-list --tree X-Git-Tag: v0.9.7-rc1~171 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40baa1c89953d0a56836b5c9478f023828870af5;p=thirdparty%2Flibvirt.git snapshot: sort snapshot-list --tree Otherwise, the results are not repeatable. * tools/virsh.c (cmdSnapshotList): Print tree in predictable order. --- diff --git a/tools/virsh.c b/tools/virsh.c index 9532bc303a..20b3dc5a61 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -13209,6 +13209,8 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) if (actual < 0) goto cleanup; + qsort(&names[0], actual, sizeof(char*), namesorter); + if (tree) { char indentBuf[INDENT_BUFLEN]; char **parents = vshMalloc(ctl, sizeof(char *) * actual); @@ -13245,8 +13247,6 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) ret = true; goto cleanup; } else { - qsort(&names[0], actual, sizeof(char*), namesorter); - for (i = 0; i < actual; i++) { /* free up memory from previous iterations of the loop */ VIR_FREE(parent);