[pve-devel] [PATCH pve-storage 6/6] LVM list_images: return creation time

Dietmar Maurer dietmar at proxmox.com
Wed Mar 4 11:46:22 CET 2020


Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 PVE/Storage/LVMPlugin.pm     | 15 +++++++++++----
 PVE/Storage/LvmThinPlugin.pm |  1 +
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/PVE/Storage/LVMPlugin.pm b/PVE/Storage/LVMPlugin.pm
index f02c110..c9fc191 100644
--- a/PVE/Storage/LVMPlugin.pm
+++ b/PVE/Storage/LVMPlugin.pm
@@ -148,9 +148,14 @@ sub lvm_vgs {
 sub lvm_list_volumes {
     my ($vgname) = @_;
 
-    my $cmd = ['/sbin/lvs', '--separator', ':', '--noheadings', '--units', 'b',
-	       '--unbuffered', '--nosuffix', '--options',
-	       'vg_name,lv_name,lv_size,lv_attr,pool_lv,data_percent,metadata_percent,snap_percent,uuid,tags,metadata_size'];
+    my $option_list = 'vg_name,lv_name,lv_size,lv_attr,pool_lv,data_percent,metadata_percent,snap_percent,uuid,tags,metadata_size,time';
+
+    my $cmd = [
+	'/sbin/lvs', '--separator', ':', '--noheadings', '--units', 'b',
+	'--unbuffered', '--nosuffix',
+	'--config', 'report/time_format="%s"',
+	'--options', $option_list,
+    ];
 
     push @$cmd, $vgname if $vgname;
 
@@ -160,7 +165,7 @@ sub lvm_list_volumes {
 
 	$line = trim($line);
 
-	my ($vg_name, $lv_name, $lv_size, $lv_attr, $pool_lv, $data_percent, $meta_percent, $snap_percent, $uuid, $tags, $meta_size) = split(':', $line);
+	my ($vg_name, $lv_name, $lv_size, $lv_attr, $pool_lv, $data_percent, $meta_percent, $snap_percent, $uuid, $tags, $meta_size, $ctime) = split(':', $line);
 	return if !$vg_name;
 	return if !$lv_name;
 
@@ -172,6 +177,7 @@ sub lvm_list_volumes {
 	};
 	$d->{pool_lv} = $pool_lv if $pool_lv;
 	$d->{tags} = $tags if $tags;
+	$d->{ctime} = $ctime;
 
 	if ($lv_type eq 't') {
 	    $data_percent ||= 0;
@@ -451,6 +457,7 @@ sub list_images {
 
 	    push @$res, {
 		volid => $volid, format => 'raw', size => $info->{lv_size}, vmid => $owner,
+		ctime => $info->{ctime},
 	    };
 	}
     }
diff --git a/PVE/Storage/LvmThinPlugin.pm b/PVE/Storage/LvmThinPlugin.pm
index 88060c7..d1c5b1f 100644
--- a/PVE/Storage/LvmThinPlugin.pm
+++ b/PVE/Storage/LvmThinPlugin.pm
@@ -165,6 +165,7 @@ sub list_images {
 
 	    push @$res, {
 		volid => $volid, format => 'raw', size => $info->{lv_size}, vmid => $owner,
+		ctime => $info->{ctime},
 	    };
 	}
     }
-- 
2.20.1




More information about the pve-devel mailing list