]> git.proxmox.com Git - pve-container.git/commitdiff
add helper to get the lxc version
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 3 Apr 2020 14:37:36 +0000 (16:37 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 4 Apr 2020 17:39:02 +0000 (19:39 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/LXC.pm

index 9033322e0a7f1c93b0394f89225da5156bebc09c..de4389d3a25d23fb089400890b3001a73f1905e1 100644 (file)
@@ -2346,4 +2346,20 @@ sub copy_volume {
     return $new_volid;
 }
 
+sub get_lxc_version() {
+    my $version;
+    PVE::Tools::run_command([qw(lxc-start --version)], outfunc => sub {
+       my ($line) = @_;
+       # We only parse out major & minor version numbers.
+       if ($line =~ /^(\d+)\.(\d+)(?:\D.*)?$/) {
+           $version = [$1, $2];
+       }
+    });
+
+    die "failed to get lxc version\n" if !defined($version);
+
+    # return as a list:
+    return $version->@*;
+}
+
 1;