[pve-devel] [PATCH cd-builder 1/2] fix #1999: sort listsnapshot output by snaptime

Rhonda D'Vine rhonda at proxmox.com
Fri May 3 11:48:49 CEST 2019


Signed-off-by: Rhonda D'Vine <rhonda at proxmox.com>
---
 PVE/CLI/qm.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index cea2549..fc06fa5 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -922,7 +922,7 @@ our $cmddef = {
     listsnapshot => [ "PVE::API2::Qemu", 'snapshot_list', ['vmid'], { node => $nodename },
 		    sub {
 			my $res = shift;
-			foreach my $e (@$res) {
+			foreach my $e (sort { $a->{snaptime} ? ( $b->{snaptime} ? ($a->{snaptime} <=> $b->{snaptime}) : -1 ) : 1 } @$res) {
 			    my $headline = $e->{description} || 'no-description';
 			    $headline =~ s/\n.*//sg;
 			    my $parent = $e->{parent} // 'no-parent';
-- 
2.11.0





More information about the pve-devel mailing list