8 use Data
::Dumper
qw(Dumper);
11 use PVE
::Tools
qw(run_command);
13 $Data::Dumper
::Sortkeys
= 1;
17 my $storagename = "zfstank99";
18 my $subvol = 'regressiontest';
19 my $mountpoint = "${subvol}_mnt";
23 my $vmdisk = "vm-102-disk-1";
24 my $vmbase = "base-100-disk-1";
25 my $vmlinked = "vm-101-disk-1";
26 my $ctdisk = "subvol-202-disk-1";
27 my $ctbase = "basevol-200-disk-1";
28 my $ctlinked = "subvol-201-disk-1";
30 my $basesnap = '@__base__';
33 #create zfs subvol for testing
40 my $end_test = $testnum;
45 $start_test = $ARGV[0];
46 } elsif (@ARGV == 1) {
47 $start_test = $ARGV[0];
53 print "\nrun test19 \"path\"\n";
58 @res = PVE
::Storage
::path
($cfg, "$storagename:$vmdisk");
59 if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmdisk") {
62 warn "Test 19 a: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmdisk'\ get \'$res[0]\'";
64 if ($res[1] ne "102") {
69 warn "Test 19 a: owner is not correct: expected \'102\' get \'$res[1]\'";
71 if ($res[2] ne "images") {
76 warn "Test 19 a: owner is not correct: expected \'images\' get \'$res[2]\'";
87 @res = PVE
::Storage
::path
($cfg, "$storagename:$vmbase");
88 if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmbase") {
91 warn "Test 19 b: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmbase'\ get \'$res[0]\'";
93 if ($res[1] ne "100") {
98 warn "Test 19 b: owner is not correct: expected \'100\' get \'$res[1]\'";
100 if ($res[2] ne "images") {
105 warn "Test 19 b: owner is not correct: expected \'images\' get \'$res[2]\'";
110 warn "Test 19 b: $@";
116 @res = PVE
::Storage
::path
($cfg, "$storagename:$vmbase\/$vmlinked");
117 if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmlinked") {
120 warn "Test 19 c: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmlinked'\ get \'$res[0]\'";
122 if ($res[1] ne "101") {
127 warn "Test 19 c: owner is not correct: expected \'101\' get \'$res[1]\'";
129 if ($res[2] ne "images") {
134 warn "Test 19 c: owner is not correct: expected \'images\' get \'$res[2]\'";
139 warn "Test 19 c: $@";
145 @res = PVE
::Storage
::path
($cfg, "$storagename:$ctdisk");
146 if ($res[0] ne "\/$mountpoint\/$ctdisk") {
149 warn "Test 19 d: path is not correct: expected \'\/$mountpoint\/$ctdisk'\ get \'$res[0]\'";
151 if ($res[1] ne "202") {
156 warn "Test 19 d: owner is not correct: expected \'202\' get \'$res[1]\'";
158 if ($res[2] ne "images") {
163 warn "Test 19 d: owner is not correct: expected \'images\' get \'$res[2]\'";
168 warn "Test 19 d: $@";
174 @res = PVE
::Storage
::path
($cfg, "$storagename:$ctbase");
175 if ($res[0] ne "\/$mountpoint\/$ctbase") {
178 warn "Test 19 e: path is not correct: expected \'\/$mountpoint\/$ctbase'\ get \'$res[0]\'";
180 if ($res[1] ne "200") {
185 warn "Test 19 e: owner is not correct: expected \'200\' get \'$res[1]\'";
187 if ($res[2] ne "images") {
192 warn "Test 19 e: owner is not correct: expected \'images\' get \'$res[2]\'";
197 warn "Test 19 e: $@";
203 @res = PVE
::Storage
::path
($cfg, "$storagename:$ctbase\/$ctlinked");
204 if ($res[0] ne "\/$mountpoint\/$ctlinked") {
207 warn "Test 19 f: path is not correct: expected \'\/$mountpoint\/$ctlinked'\ get \'$res[0]\'";
209 if ($res[1] ne "201") {
214 warn "Test 19 f: owner is not correct: expected \'201\' get \'$res[1]\'";
216 if ($res[2] ne "images") {
221 warn "Test 19 f: owner is not correct: expected \'images\' get \'$res[2]\'";
226 warn "Test 19 f: $@";
229 $tests->{19} = $test19;
233 print "\nrun test18 \"scan_zfs\"\n";
237 $res = PVE
::Storage
::scan_zfs
($cfg, $storagename);
240 foreach my $subvol (@$res){
241 if ($subvol->{pool
} eq 'regressiontest') {
247 warn "Test 18 a: not pool";
252 warn "Test 18 a: $@";
257 $res = PVE
::Storage
::scan_zfs
($cfg, $storagename);
259 foreach my $subvol (@$res){
260 if ($subvol->{pool
} eq 'zfspool/subvol') {
266 foreach my $subvol (@$res){
267 if ($subvol->{pool
} eq 'zfspool/basevol') {
275 warn "Test 18 a: $@";
278 $tests->{18} = $test18;
282 print "\nrun test17 \"deactivate_storage\"\n";
285 PVE
::Storage
::activate_storage
($cfg, $storagename);
286 PVE
::Storage
::deactivate_storage
($cfg, $storagename);
290 warn "Test 17 a: $@";
293 $tests->{17} = $test17;
297 print "\nrun test16 \"activate_storage\"\n";
300 PVE
::Storage
::activate_storage
($cfg, $storagename);
304 warn "Test 16 a: $@";
307 $tests->{16} = $test16;
311 print "\nrun test15 \"template_list and vdisk_list\"\n";
313 my $hash = Dumper
{};
315 my $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "vztmpl");
316 if ( $hash ne $res ) {
318 warn "Test 15 a failed\n";
322 $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "iso");
323 if ( $hash ne $res ) {
325 warn "Test 15 b failed\n";
329 $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "backup");
330 if ( $hash ne $res ) {
332 warn "Test 15 c failed\n";
336 $hash = Dumper
{'zfstank99' => [
339 'volid' => 'zfstank99:base-100-disk-1',
340 'name' => 'base-100-disk-1',
342 'size' => 1073741824,
347 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 100, ["$storagename:$vmbase"]);
349 if ( $hash ne $res ) {
351 warn "Test 15 d failed\n";
355 $hash = Dumper
{'zfstank99' => [
358 'volid' => 'zfstank99:vm-102-disk-1',
359 'name' => 'vm-102-disk-1',
361 'size' => 1073741824,
366 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 102, ["$storagename:$vmdisk"]);
367 if ( $hash ne $res ) {
369 warn "Test 15 e failed\n";
373 $hash = Dumper
{'zfstank99' => [
375 'parent' => 'base-100-disk-1@__base__',
376 'volid' => "$storagename:$vmbase\/$vmlinked",
377 'name' => 'vm-101-disk-1',
379 'size' => 1073741824,
384 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 101, ["$storagename:$vmbase\/$vmlinked"]);
385 if ( $hash ne $res ) {
387 warn "Test 15 f failed\n";
391 $hash = Dumper
{'zfstank99' => [
394 'volid' => 'zfstank99:basevol-200-disk-1',
395 'name' => 'basevol-200-disk-1',
397 'size' => 1073741824,
402 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 200, ["$storagename:$ctbase"]);
403 if ( $hash ne $res ) {
405 warn "Test 15 g failed\n";
409 $hash = Dumper
{'zfstank99' => [
412 'volid' => 'zfstank99:subvol-202-disk-1',
413 'name' => 'subvol-202-disk-1',
415 'size' => 1073741824,
420 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 202, ["$storagename:$ctdisk"]);
421 if ( $hash ne $res ) {
423 warn "Test 15 h failed\n";
427 $hash = Dumper
{'zfstank99' => [
429 'parent' => 'basevol-200-disk-1@__base__',
430 'volid' => "$storagename:$ctbase\/$ctlinked",
431 'name' => 'subvol-201-disk-1',
433 'size' => 1073741824,
437 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 201, ["$storagename:$ctbase\/$ctlinked"]);
438 if ( $hash ne $res ) {
440 warn "Test 15 i failed\n";
443 $tests->{15} = $test15;
447 print "\nrun test14 \"vdisk_free\"\n";
450 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmdisk");
453 run_command
("zfs list $zpath\/$vmdisk", outfunc
=> sub {}, errfunc
=> sub {});
457 warn "Test14 a: vdisk still exists\n";
466 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase");
470 warn "Test14 b: free vdisk should not work\n";
474 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase\/$vmlinked");
477 run_command
("zfs list $zpath\/$vmlinked", outfunc
=> sub {}, errfunc
=> sub {});
481 warn "Test14 c: vdisk still exists\n";
490 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctdisk");
493 run_command
("zfs list $zpath\/$ctdisk", outfunc
=> sub {}, errfunc
=> sub {});
497 warn "Test14 d: vdisk still exists\n";
506 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase");
510 warn "Test14 e: free vdisk should not work\n";
514 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase\/$ctlinked");
517 run_command
("zfs list $zpath\/$ctlinked", outfunc
=> sub {}, errfunc
=> sub {});
521 warn "Test14 f: vdisk still exists\n";
530 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase");
533 run_command
("zfs list $zpath\/$vmbase", outfunc
=> sub {}, errfunc
=> sub {});
537 warn "Test14 g: vdisk still exists\n";
546 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase");
549 run_command
("zfs list $zpath\/$ctbase", outfunc
=> sub {}, errfunc
=> sub {});
553 warn "Test14 h: vdisk still exists\n";
561 $tests->{14} = $test14;
565 print "\nrun test13 \"vdisk_alloc\"\n";
568 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "112", "raw", undef ,1024 * 1024);
570 if ($tmp_volid ne "$storagename:vm-112-disk-0") {
571 die "volname:$tmp_volid don't match\n";
574 run_command
("zfs get -H volsize $zpath\/vm-112-disk-0", outfunc
=>
575 sub { my $tmp = shift;
576 if ($tmp !~ m/^$zpath\/vm-112-disk-0
.*volsize
.*1G
.*$/) {
577 die "size don't match\n";
592 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "112", "raw", undef ,2048 * 1024);
594 if ($tmp_volid ne "$storagename:vm-112-disk-1") {
595 die "volname:$tmp_volid don't match\n";
598 run_command
("zfs get -H volsize $zpath\/vm-112-disk-1", outfunc
=>
599 sub { my $tmp = shift;
600 if ($tmp !~ m/^$zpath\/vm-112-disk-1
.*volsize
.*2G
.*$/) {
601 die "size don't match\n";
616 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "113", "subvol", undef ,1024 * 1024);
618 if ($tmp_volid ne "$storagename:subvol-113-disk-0") {
619 die "volname:$tmp_volid don't match\n";
622 run_command
("zfs get -H refquota $zpath\/subvol-113-disk-0", outfunc
=>
623 sub { my $tmp = shift;
624 if ($tmp !~ m/^$zpath\/subvol
-113-disk
-0.*refquota
.*1G
.*$/) {
625 die "size don't match\n";
640 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "113", "subvol", undef ,2048 * 1024);
642 if ($tmp_volid ne "$storagename:subvol-113-disk-1") {
643 die "volname:$tmp_volid don't match\n";
646 run_command
("zfs get -H refquota $zpath\/subvol-113-disk-1", outfunc
=>
647 sub { my $tmp = shift;
648 if ($tmp !~ m/^$zpath\/subvol
-113-disk
-1.*refquota
.*G
.*$/) {
649 die "size don't match\n";
663 $tests->{13} = $test13;
667 print "\nrun test12 \"vdisk_create_base\"\n";
670 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$vmdisk");
672 if ($tmp_volid ne "$storagename:base-102-disk-1") {
676 run_command
("zfs list $zpath\/base-102-disk-1", outfunc
=> sub {});
689 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$vmlinked");
691 if ($tmp_volid ne "$storagename:base-101-disk-1") {
695 run_command
("zfs list $zpath\/base-101-disk-1", outfunc
=> sub {});
708 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$ctdisk");
710 if ($tmp_volid ne "$storagename:basevol-202-disk-1") {
714 run_command
("zfs list $zpath\/basevol-202-disk-1", outfunc
=> sub {});
727 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$ctlinked");
729 if ($tmp_volid ne "$storagename:basevol-201-disk-1") {
733 run_command
("zfs list $zpath\/basevol-201-disk-1", outfunc
=> sub {});
745 $tests->{12} = $test12;
749 print "\nrun test11 \"volume_is_base\"\n";
752 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmdisk", 110);
756 warn "Test11 a: clone_image only works on base images";
760 if ("$storagename:$vmbase\/vm-110-disk-0" ne
761 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmbase", 110, '__base__')){
765 run_command
("zfs list -H -o volsize $zpath\/vm-110-disk-0", outfunc
=> sub {
769 warn "Test11 b not correct volsize" if $line !~ m/$volsize/;
778 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmbase\/$vmlinked", 111);
782 warn "Test11 c: clone_image only works on base images";
786 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctdisk", 110);
790 warn "Test11 d: clone_image only works on base images";
794 if ( "$storagename:$ctbase\/subvol-210-disk-0" ne
795 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctbase", 210, '__base__')){
799 run_command
("zfs list -H -o refquota $zpath\/subvol-210-disk-0", outfunc
=> sub {
803 warn "Test11 e not correct volsize" if $line !~ m/$volsize/;
812 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctbase\/$ctlinked", 211);
816 warn "Test11 f: clone_image only works on base images";
819 $tests->{11} = $test11;
823 print "\nrun test10 \"volume_is_base\"\n";
826 if (1 == volume_is_base
($cfg, "$storagename:$vmdisk")) {
828 warn "Test10 a: is no base";
838 if (0 == volume_is_base
($cfg, "$storagename:$vmbase")) {
840 warn "Test10 b: is base";
850 if (1 == volume_is_base
($cfg, "$storagename:$vmbase\/$vmlinked")) {
852 warn "Test10 c: is no base";
862 if (1 == volume_is_base
($cfg, "$storagename:$ctdisk")) {
864 warn "Test10 d: is no base";
874 if (0 == volume_is_base
($cfg, "$storagename:$ctbase")) {
876 warn "Test10 e: is base";
886 if (1 == volume_is_base
($cfg, "$storagename:$ctbase\/$ctlinked")) {
888 warn "Test10 f: is no base";
897 $tests->{10} = $test10;
901 print "\nrun test9 \"parse_volume_id\"\n";
904 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmdisk");
906 if ($store ne $storagename || $disk ne $vmdisk) {
908 warn "Test9 a: parsing wrong";
918 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmbase");
920 if ($store ne $storagename || $disk ne $vmbase) {
922 warn "Test9 b: parsing wrong";
932 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmbase\/$vmlinked");
934 if ($store ne $storagename || $disk ne "$vmbase\/$vmlinked") {
936 warn "Test9 c: parsing wrong";
946 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctdisk");
948 if ($store ne $storagename || $disk ne $ctdisk) {
950 warn "Test9 d: parsing wrong";
960 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctbase");
962 if ($store ne $storagename || $disk ne $ctbase) {
964 warn "Test9 e: parsing wrong";
974 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctbase\/$ctlinked");
976 if ($store ne $storagename || $disk ne "$ctbase\/$ctlinked") {
978 warn "Test9 f: parsing wrong";
987 $tests->{9} = $test9;
991 print "\nrun test8 \"parse_volname\"\n";
994 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmdisk");
996 if ($vtype ne 'images' || $vmid ne '102' || $name ne $vmdisk ||
997 defined($basename) || defined($basevmid) || $isBase ||
1000 warn "Test8 a: parsing wrong";
1010 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmbase");
1012 if ($vtype ne 'images' || $vmid ne '100' || $name ne $vmbase ||
1013 defined($basename) || defined($basevmid) || !$isBase ||
1016 warn "Test8 b: parsing wrong";
1025 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmbase\/$vmlinked");
1027 if ($vtype ne 'images' || $name ne $vmlinked || $vmid ne '101' ||
1028 $basename ne $vmbase || $basevmid ne '100' || $isBase ||
1031 warn "Test8 c: parsing wrong";
1040 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctdisk");
1042 if ($vtype ne 'images' || $vmid ne '202' || $name ne $ctdisk ||
1043 defined($basename) || defined($basevmid) || $isBase ||
1044 $format ne 'subvol') {
1046 warn "Test8 d: parsing wrong";
1056 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctbase");
1057 if ($vtype ne 'images' || $vmid ne '200' || $name ne $ctbase ||
1058 defined($basename) || defined($basevmid) || !$isBase ||
1059 $format ne 'subvol') {
1061 warn "Test8 e: parsing wrong";
1070 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctbase\/$ctlinked");
1072 if ($vtype ne 'images' || $name ne $ctlinked || $vmid ne '201' ||
1073 $basename ne $ctbase || $basevmid ne '200' || $isBase ||
1074 $format ne 'subvol') {
1076 warn "Test8 f: parsing wrong";
1084 $tests->{8} = $test8;
1088 print "\nrun test7 \"volume_rollback\"\n";
1091 my $parse_guid = sub {
1094 if ( $line =~ m/^Disk identifier \(GUID\)\: (.*)$/ ) {
1100 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmdisk"]);
1101 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1102 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1104 my $old_guid = $tmp_guid;
1105 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap1');
1107 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1109 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmdisk", 'snap1');
1110 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmdisk"]);
1112 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1113 if ($old_guid ne $tmp_guid) {
1115 warn "Test7 a: Zvol makes no rollback";
1130 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmbase"]);
1131 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1132 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1134 my $old_guid = $tmp_guid;
1135 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap1');
1137 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1139 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase", 'snap1');
1140 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmbase"]);
1142 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1143 if ($old_guid ne $tmp_guid) {
1145 warn "Test7 b: Zvol makes no rollback";
1160 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmbase/$vmlinked"]);
1161 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1162 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1164 my $old_guid = $tmp_guid;
1165 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1167 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1169 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1170 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmbase/$vmlinked"]);
1172 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1173 if ($old_guid ne $tmp_guid) {
1175 warn "Test7 c: Zvol makes no rollback";
1190 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap1');
1192 run_command
("touch \/$mountpoint\/$ctdisk\/test.txt", outfunc
=> $parse_guid);
1194 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctdisk", 'snap1');
1196 run_command
("ls \/$mountpoint\/$ctdisk\/test.txt", errofunc
=> sub {});
1214 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap1');
1216 run_command
("touch \/$mountpoint\/$ctbase\/test.txt", outfunc
=> $parse_guid);
1218 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase", 'snap1');
1220 run_command
("ls \/$mountpoint\/$ctbase\/test.txt", errofunc
=> sub {});
1238 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1240 run_command
("touch \/$mountpoint\/$ctlinked\/test.txt", outfunc
=> $parse_guid);
1242 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1244 run_command
("ls \/$zpath\/$ctlinked\/test.txt", errofunc
=> sub {});
1262 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap2');
1265 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmdisk", 'snap1');
1269 warn "Test7 h: Not allowed to rollback";
1278 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap2');
1281 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase", 'snap1');
1285 warn "Test7 i: Not allowed to rollback";
1294 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap2');
1297 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1301 warn "Test7 j: Not allowed to rollback";
1310 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap2');
1313 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctdisk", 'snap1');
1317 warn "Test7 k: Not allowed to rollback";
1326 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap2');
1329 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase", 'snap1');
1333 warn "Test7 l: Not allowed to rollback";
1342 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase/$ctlinked", 'snap2');
1345 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1349 warn "Test7 m: Not allowed to rollback";
1357 $tests->{7} = $test7;
1361 print "\nrun test6 \"volume_rollback_is_possible\"\n";
1364 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap1');
1366 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmdisk", 'snap1')) {
1368 warn "Test6 a: Rollback sould possible"
1377 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap1');
1379 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase", 'snap1')) {
1381 warn "Test6 b: Rollback sould possible"
1390 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmlinked", 'snap1');
1392 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1')) {
1394 warn "Test6 c: Rollback sould possible"
1403 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap1');
1405 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctdisk", 'snap1')) {
1407 warn "Test6 d: Rollback sould possible"
1416 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap1');
1418 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase", 'snap1')) {
1420 warn "Test6 e: Rollback sould possible"
1429 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctlinked", 'snap1');
1431 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1')) {
1433 warn "Test6 f: Rollback sould possible"
1442 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap2');
1443 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmdisk", 'snap1');
1447 warn "Test6 g: Rollback should not possible";
1451 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap2');
1452 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase", 'snap1');
1456 warn "Test6 h: Rollback should not possible";
1460 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmlinked", 'snap2');
1461 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1465 warn "Test6 j: Rollback should not possible";
1469 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap2');
1470 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctdisk", 'snap1');
1474 warn "Test6 k: Rollback should not possible";
1478 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap2');
1479 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase", 'snap1');
1483 warn "Test6 l: Rollback should not possible";
1487 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctlinked", 'snap2');
1488 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1');
1492 warn "Test6 m: Rollback should not possible";
1495 $tests->{6} = $test6;
1499 print "\nrun test5 \"volume_snapshot_delete\"\n";
1500 my $out = sub{my $tmp = shift;};
1503 run_command
("zfs snapshot $zpath\/$vmdisk\@snap");
1505 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmdisk", 'snap');
1507 run_command
("zfs list $zpath\/$vmdisk\@snap", errfunc
=> $out, outfunc
=> $out);
1511 warn "Test5 a: snapshot still exists";
1516 warn "Test5 PVE a: $@";
1525 run_command
("zfs snapshot $zpath\/$vmbase\@snap");
1527 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase", 'snap');
1529 run_command
("zfs list $zpath\/$vmbase\@snap", errmsg
=> $out, outfunc
=> $out);
1533 warn "Test5 b: snapshot still exists";
1538 warn "Test5 PVE b: $@";
1547 run_command
("zfs snapshot $zpath\/$vmlinked\@snap");
1549 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap');
1551 run_command
("zfs list $zpath\/$vmlinked\@snap", errmsg
=> $out, outfunc
=> $out);
1555 warn "Test5 c: snapshot still exists";
1560 warn "Test5 PVE c: $@";
1569 run_command
("zfs snapshot $zpath\/$ctdisk\@snap");
1571 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctdisk", 'snap');
1573 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1577 warn "Test5 d: snapshot still exists";
1582 warn "Test5 PVE d: $@";
1591 run_command
("zfs snapshot $zpath\/$ctbase\@snap");
1593 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctbase", 'snap');
1595 run_command
("zfs list $zpath\/$ctbase\@snap", errmsg
=> $out, outfunc
=> $out);
1599 warn "Test5 e: snapshot still exists";
1604 warn "Test5 PVE e: $@";
1613 run_command
("zfs snapshot $zpath\/$ctlinked\@snap");
1615 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap');
1617 run_command
("zfs list $zpath\/$ctlinked\@snap", errmsg
=> $out, outfunc
=> $out);
1621 warn "Test5 f: snapshot still exists";
1626 warn "Test5 PVE f: $@";
1633 print "######Ignore Output if no Test5 g: is included######\n";
1635 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase", '__base__');
1637 run_command
("zfs list $zpath\/$vmbase\@__base__", outfunc
=> $out);
1646 warn "Test5 PVE g: snapshot __base__ can be erased";
1648 print "######End Ignore#######\n";
1650 $tests->{5} = $test5;
1654 print "\nrun test4 \"volume_snapshot\"\n";
1658 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap');
1660 run_command
("zfs list $zpath\/$vmdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1673 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap');
1675 run_command
("zfs list $zpath\/$vmbase\@snap", errmsg
=> $out, outfunc
=> $out);
1688 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap');
1690 run_command
("zfs list $zpath\/$vmdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1703 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap');
1705 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1718 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap');
1720 run_command
("zfs list $zpath\/$ctbase\@snap", errmsg
=> $out, outfunc
=> $out);
1733 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap');
1735 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1747 $tests->{4} = $test4;
1751 print "\nrun test3 \"volume_has_feature\"\n";
1754 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmdisk", undef, 0)) {
1756 warn "Test3 a failed";
1765 if (PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase", undef, 0)) {
1767 warn "Test3 b failed";
1776 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1778 warn "Test3 c failed";
1787 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctdisk", undef, 0)) {
1789 warn "Test3 d failed";
1798 if (PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase", undef, 0)) {
1800 warn "Test3 e failed";
1809 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1811 warn "Test3 f failed";
1820 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmdisk", undef, 0)) {
1822 warn "Test3 g failed";
1831 if (!PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase", undef, 0)) {
1833 warn "Test3 h failed";
1842 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1844 warn "Test3 h failed";
1853 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctdisk", undef, 0)) {
1855 warn "Test3 i failed";
1864 if (!PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase", undef, 0)) {
1866 warn "Test3 j failed";
1875 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1877 warn "Test3 k failed";
1886 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmdisk", undef, 0)) {
1888 warn "Test3 l failed";
1897 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase", undef, 0)) {
1899 warn "Test3 m failed";
1908 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1910 warn "Test3 n failed";
1919 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctdisk", undef, 0)) {
1921 warn "Test3 o failed";
1930 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase", undef, 0)) {
1932 warn "Test3 p failed";
1941 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1943 warn "Test3 q failed";
1952 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmdisk", undef, 0)) {
1954 warn "Test3 r failed";
1963 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase", undef, 0)) {
1965 warn "Test3 s failed";
1974 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1976 warn "Test3 t failed";
1985 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctdisk", undef, 0)) {
1987 warn "Test3 u failed";
1996 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase", undef, 0)) {
1998 warn "Test3 v failed";
2007 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
2009 warn "Test3 w failed";
2018 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmdisk", undef, 0)) {
2020 warn "Test3 x failed";
2029 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase", undef, 0)) {
2031 warn "Test3 y failed";
2040 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
2042 warn "Test3 z failed";
2051 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctdisk", undef, 0)) {
2053 warn "Test3 A failed";
2062 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase", undef, 0)) {
2064 warn "Test3 B failed";
2073 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
2075 warn "Test3 C failed";
2084 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmdisk", 'test', 0)) {
2086 warn "Test3 a1 failed";
2091 warn "Test3 a1: $@";
2095 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase", 'test', 0)) {
2097 warn "Test3 b1 failed";
2102 warn "Test3 b1: $@";
2106 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2108 warn "Test3 c1 failed";
2113 warn "Test3 c1: $@";
2117 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctdisk", 'test', 0)) {
2119 warn "Test3 d1 failed";
2124 warn "Test3 d1: $@";
2128 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase", 'test', 0)) {
2130 warn "Test3 e1 failed";
2135 warn "Test3 e1: $@";
2139 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2141 warn "Test3 f1 failed";
2146 warn "Test3 f1: $@";
2150 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmdisk", 'test', 0)) {
2152 warn "Test3 g1 failed";
2157 warn "Test3 g1: $@";
2161 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase", 'test', 0)) {
2163 warn "Test3 h1 failed";
2168 warn "Test3 h1: $@";
2172 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2174 warn "Test3 h1 failed";
2179 warn "Test3 h1: $@";
2183 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctdisk", 'test', 0)) {
2185 warn "Test3 i1 failed";
2190 warn "Test3 i1: $@";
2194 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase", 'test', 0)) {
2196 warn "Test3 j1 failed";
2201 warn "Test3 j1: $@";
2205 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2207 warn "Test3 k1 failed";
2212 warn "Test3 k1: $@";
2216 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmdisk", 'test', 0)) {
2218 warn "Test3 l1 failed";
2223 warn "Test3 l1: $@";
2227 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase", 'test', 0)) {
2229 warn "Test3 m1 failed";
2234 warn "Test3 m1: $@";
2238 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2240 warn "Test3 n1 failed";
2245 warn "Test3 n1: $@";
2249 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctdisk", 'test', 0)) {
2251 warn "Test3 o1 failed";
2256 warn "Test3 o1: $@";
2260 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase", 'test', 0)) {
2262 warn "Test3 p1 failed";
2267 warn "Test3 p1: $@";
2271 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2273 warn "Test3 q1 failed";
2278 warn "Test3 q1: $@";
2282 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmdisk", 'test', 0)) {
2284 warn "Test3 r1 failed";
2289 warn "Test3 r1: $@";
2293 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase", 'test', 0)) {
2295 warn "Test3 s1 failed";
2300 warn "Test3 s1: $@";
2304 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2306 warn "Test3 t1 failed";
2311 warn "Test3 t1: $@";
2315 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctdisk", 'test', 0)) {
2317 warn "Test3 u1 failed";
2322 warn "Test3 u1: $@";
2326 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase", 'test', 0)) {
2328 warn "Test3 v1 failed";
2333 warn "Test3 v1: $@";
2337 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2339 warn "Test3 w1 failed";
2344 warn "Test3 w1: $@";
2348 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmdisk", 'test', 0)) {
2350 warn "Test3 x1 failed";
2355 warn "Test3 x1: $@";
2359 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase", 'test', 0)) {
2361 warn "Test3 y1 failed";
2366 warn "Test3 y1: $@";
2370 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2372 warn "Test3 z1 failed";
2377 warn "Test3 z1: $@";
2381 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctdisk", 'test', 0)) {
2383 warn "Test3 A1 failed";
2388 warn "Test3 A1: $@";
2392 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase", 'test', 0)) {
2394 warn "Test3 B1 failed";
2399 warn "Test3 B1: $@";
2403 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2405 warn "Test3 C1 failed";
2410 warn "Test3 C1: $@";
2413 $tests->{3} = $test3;
2417 print "\nrun test2 \"volume_resize\"\n";
2418 my $newsize = ($volsize + 1) * 1024 * 1024 * 1024;
2421 if (($newsize/1024) !=
2422 PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmdisk", $newsize, 0)) {
2424 warn "Test2 a failed";
2427 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmdisk")) {
2429 warn "Test2 a failed";
2438 warn "Test2 b failed" if ($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmbase", $newsize, 0);
2439 warn "Test2 b failed" if $newsize !=
2440 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase");
2448 if (($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmbase\/$vmlinked", $newsize, 0)) {
2450 warn "Test2 c failed";
2453 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2455 warn "Test2 c failed";
2464 if (($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctdisk", $newsize, 0)) {
2466 warn "Test2 d failed";
2469 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctdisk")) {
2471 warn "Test2 d failed"
2480 if (($newsize/1024) !=
2481 PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctbase", $newsize, 0)) {
2483 warn "Test2 e failed";
2486 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase")) {
2488 warn "Test2 e failed";
2497 if (($newsize/1024) !=
2498 PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctbase\/$ctlinked", $newsize, 0)) {
2500 warn "Test2 f failed";
2503 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase\/$ctlinked")) {
2505 warn "Test2 f failed";
2513 $tests->{2} = $test2;
2517 print "\nrun test1 \"volume_size_info\"\n";
2518 my $size = ($volsize * 1024 * 1024 * 1024);
2521 if ($size != PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmdisk")) {
2523 warn "Test1 a failed";
2528 warn "Test1 a : $@";
2532 if ($size != PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase")) {
2534 warn "Test1 b failed";
2540 warn "Test1 b : $@";
2545 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2547 warn "Test1 c failed";
2552 warn "Test1 c : $@";
2557 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctdisk")) {
2559 warn "Test1 d failed";
2564 warn "Test1 d : $@";
2569 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase")) {
2571 warn "Test1 e failed";
2576 warn "Test1 e : $@";
2581 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2583 warn "Test1 f failed"
2588 warn "Test1 f : $@";
2592 $tests->{1} = $test1;
2596 print "create zvol $vmdisk\n" if $verbose;
2597 run_command
("zfs create -V${volsize}G $zpath\/$vmdisk");
2599 print "create zvol $vmbase\n" if $verbose;
2600 run_command
("zfs create -V${volsize}G $zpath\/$vmbase");
2601 run_command
("zfs snapshot $zpath\/$vmbase$basesnap");
2603 print "create linked clone $vmlinked\n" if $verbose;
2604 run_command
("zfs clone $zpath\/$vmbase$basesnap $zpath\/$vmlinked");
2607 print "create subvol $ctdisk\n" if $verbose;
2608 run_command
("zfs create -o refquota=${volsize}G $zpath\/$ctdisk");
2610 print "create subvol $ctbase\n" if $verbose;
2611 run_command
("zfs create -o refquota=${volsize}G $zpath\/$ctbase");
2612 run_command
("zfs snapshot $zpath\/$ctbase$basesnap");
2614 print "create linked clone $ctlinked\n" if $verbose;
2615 run_command
("zfs clone $zpath\/$ctbase$basesnap $zpath\/$ctlinked -o refquota=${volsize}G");
2618 "$storagename:$vmdisk",
2619 "$storagename:$vmbase",
2620 "$storagename:$vmbase/$vmlinked",
2621 "$storagename:$ctdisk",
2622 "$storagename:$ctbase",
2623 "$storagename:$ctbase/$ctlinked",
2626 PVE
::Storage
::activate_volumes
($cfg, $vollist);
2631 print "destroy $pool\/$subvol\n" if $verbose;
2632 eval { run_command
("zfs destroy $zpath -r"); };
2634 print "cleanup failed: $@\nretrying once\n" if $verbose;
2635 eval { run_command
("zfs destroy $zpath -r"); };
2647 run_command
("truncate -s 8G zpool.img");
2654 run_command
("zpool create -m \/$mountpoint $subvol $pwd\/zpool.img");
2661 sub clean_up_zpool
{
2664 run_command
("zpool destroy -f $subvol");
2671 sub volume_is_base
{
2672 my ($cfg, $volid) = @_;
2674 my (undef, undef, undef, undef, undef, $isBase, undef) = PVE
::Storage
::parse_volname
($cfg, $volid);
2679 if ($> != 0) { #EUID
2680 warn "not root, skipping zfs tests\n";
2684 eval { run_command
("zpool status"); };
2686 warn "zpool status failed, not running tests: $@\n";
2693 print "Start tests for ZFSPoolPlugin\n";
2702 'mountpoint' => "\/$mountpoint",
2706 'order' => {'zfstank99' => 1,}
2711 for (my $i = $start_test; $i <= $end_test; $i++) {
2726 $time = time - $time;
2728 print "Stop tests for ZFSPoolPlugin\n";
2729 print "$count tests failed\n";
2730 print "Time: ${time}s\n";
2732 exit -1 if $count > 0;