From 022a70ff75d72099324220dc1da27ada9d165346 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 3 Apr 2020 16:37:36 +0200 Subject: [PATCH] add helper to get the lxc version Signed-off-by: Wolfgang Bumiller --- src/PVE/LXC.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 9033322..de4389d 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -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; -- 2.39.5