]> git.proxmox.com Git - pve-storage.git/commitdiff
Fix: #2124 storage: add zstd support
authorAlwin Antreich <a.antreich@proxmox.com>
Tue, 28 Apr 2020 13:58:23 +0000 (15:58 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 30 Apr 2020 16:37:19 +0000 (18:37 +0200)
Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
PVE/Storage.pm
PVE/Storage/Plugin.pm
test/archive_info_test.pm
test/list_volumes_test.pm
test/parse_volname_test.pm
test/path_to_volume_id_test.pm

index 0b2745eecfeb97e647f6f6746455f4002f543390..87550b14360eade1ac15a5de96272b3e64ab2e3a 100755 (executable)
@@ -1366,10 +1366,12 @@ sub decompressor_info {
        tar => {
            gz => ['tar', '-z'],
            lzo => ['tar', '--lzop'],
+           zst => ['tar', '--zstd'],
        },
        vma => {
            gz => ['zcat'],
            lzo => ['lzop', '-d', '-c'],
+           zst => ['zstd', '-q', '-d', '-c'],
        },
     };
 
@@ -1460,7 +1462,7 @@ sub extract_vzdump_config_vma {
        my $errstring;
        my $err = sub {
            my $output = shift;
-           if ($output =~ m/lzop: Broken pipe: <stdout>/ || $output =~ m/gzip: stdout: Broken pipe/) {
+           if ($output =~ m/lzop: Broken pipe: <stdout>/ || $output =~ m/gzip: stdout: Broken pipe/ || $output =~ m/zstd: error 70 : Write error : Broken pipe/) {
                $broken_pipe = 1;
            } elsif (!defined ($errstring) && $output !~ m/^\s*$/) {
                $errstring = "Failed to extract config from VMA archive: $output\n";
index 5f3e4c1707e5809248e62b72423e78f40c8a2b36..e9da4032baba396d627313f5678bb543fac96960 100644 (file)
@@ -18,7 +18,7 @@ use JSON;
 
 use base qw(PVE::SectionConfig);
 
-use constant COMPRESSOR_RE => 'gz|lzo';
+use constant COMPRESSOR_RE => 'gz|lzo|zst';
 
 our @COMMON_TAR_FLAGS = qw(
     --one-file-system
index c9bb1b72fb8360d3a8a615606c202e69cfa3e594..283fe47a266df97b49668c4196fa19e92149292a 100644 (file)
@@ -45,10 +45,12 @@ my $decompressor = {
     tar => {
        gz  => ['tar', '-z'],
        lzo => ['tar', '--lzop'],
+       zst => ['tar', '--zstd'],
     },
     vma => {
        gz  => ['zcat'],
        lzo => ['lzop', '-d', '-c'],
+       zst => ['zstd', '-q', '-d', '-c'],
     },
 };
 
@@ -85,7 +87,7 @@ foreach my $virt (keys %$bkp_suffix) {
 my $non_bkp_suffix = {
     'openvz' => [ 'zip', 'tgz.lzo', 'tar.bz2', 'zip.gz', '', ],
     'lxc'    => [ 'zip', 'tgz.lzo', 'tar.bz2', 'zip.gz', '', ],
-    'qemu'   => [ 'vma.xz', 'vms.gz', '', ],
+    'qemu'   => [ 'vma.xz', 'vms.gz', 'vmx.zst', '', ],
     'none'   => [ 'tar.gz', ],
 };
 
index 941b9036919c0c8a059d244f6a35995e78a1a721..efcb54759e768cacd456d7de3eb63971e572acba 100644 (file)
@@ -93,6 +93,7 @@ my @tests = (
            "$storage_dir/dump/vzdump-qemu-16110-2020_03_30-21_11_40.vma.gz",
            "$storage_dir/dump/vzdump-qemu-16110-2020_03_30-21_12_45.vma.lzo",
            "$storage_dir/dump/vzdump-qemu-16110-2020_03_30-21_13_55.vma",
+           "$storage_dir/dump/vzdump-qemu-16110-2020_03_30-21_13_55.vma.zst",
            "$storage_dir/snippets/userconfig.yaml",
            "$storage_dir/snippets/hookscript.pl",
        ],
@@ -151,6 +152,14 @@ my @tests = (
                'vmid'    => '16110',
                'volid'   => 'local:backup/vzdump-qemu-16110-2020_03_30-21_13_55.vma',
            },
+           {
+               'content' => 'backup',
+               'ctime'   => 1585595635,
+               'format'  => 'vma.zst',
+               'size'    => DEFAULT_SIZE,
+               'vmid'    => '16110',
+               'volid'   => 'local:backup/vzdump-qemu-16110-2020_03_30-21_13_55.vma.zst',
+           },
            {
                'content' => 'snippets',
                'ctime'   => DEFAULT_CTIME,
@@ -174,6 +183,7 @@ my @tests = (
            "$storage_dir/images/16112/vm-16112-disk-0.raw",
            "$storage_dir/dump/vzdump-lxc-16112-2020_03_30-21_39_30.tar.lzo",
            "$storage_dir/dump/vzdump-lxc-16112-2020_03_30-21_49_30.tar.gz",
+           "$storage_dir/dump/vzdump-lxc-16112-2020_03_30-21_49_30.tar.zst",
            "$storage_dir/dump/vzdump-lxc-16112-2020_03_30-21_59_30.tgz",
        ],
        expected => [
@@ -203,6 +213,14 @@ my @tests = (
                'vmid'    => '16112',
                'volid'   => 'local:backup/vzdump-lxc-16112-2020_03_30-21_49_30.tar.gz',
            },
+           {
+               'content' => 'backup',
+               'ctime'   => 1585597770,
+               'format'  => 'tar.zst',
+               'size'    => DEFAULT_SIZE,
+               'vmid'    => '16112',
+               'volid'   => 'local:backup/vzdump-lxc-16112-2020_03_30-21_49_30.tar.zst',
+           },
            {
                'content' => 'backup',
                'ctime'   => 1585598370,
index 87c758cb9bd405c6ab5c8d74cca847d5d454d742..d6ac88543eb07c23f961b9e7aa12dd9a0d1b3ad1 100644 (file)
@@ -176,9 +176,9 @@ foreach my $s (@$disk_suffix) {
 
 # create more test cases for backup files matches
 my $bkp_suffix = {
-    qemu   => [ 'vma', 'vma.gz', 'vma.lzo' ],
-    lxc    => [ 'tar', 'tgz', 'tar.gz', 'tar.lzo' ],
-    openvz => [ 'tar', 'tgz', 'tar.gz', 'tar.lzo' ],
+    qemu   => [ 'vma', 'vma.gz', 'vma.lzo', 'vma.zst' ],
+    lxc    => [ 'tar', 'tgz', 'tar.gz', 'tar.lzo', 'tar.zst' ],
+    openvz => [ 'tar', 'tgz', 'tar.gz', 'tar.lzo', 'tar.zst' ],
 };
 
 foreach my $virt (keys %$bkp_suffix) {
index e5e24c121de63c8ec1f4ea6057f51b1ef681ce64..5eee2f6a7172d40efc8d3b5c4151b66ad8972c82 100644 (file)
@@ -100,6 +100,22 @@ my @tests = (
            'local:backup/vzdump-lxc-16112-2020_03_30-21_39_30.tar.lzo',
        ],
     },
+    {
+       description => 'Backup, vma.zst',
+       volname     => "$storage_dir/dump/vzdump-qemu-16110-2020_03_30-21_13_55.vma.zst",
+       expected    => [
+           'backup',
+           'local:backup/vzdump-qemu-16110-2020_03_30-21_13_55.vma.zst'
+       ],
+    },
+    {
+       description => 'Backup, tar.zst',
+       volname     => "$storage_dir/dump/vzdump-lxc-16112-2020_03_30-21_39_30.tar.zst",
+       expected    => [
+           'backup',
+           'local:backup/vzdump-lxc-16112-2020_03_30-21_39_30.tar.zst'
+       ],
+    },
 
     {
        description => 'ISO file',