5 use Data
::Dumper
qw(Dumper);
8 use PVE
::Tools
qw(run_command);
10 $Data::Dumper
::Sortkeys
= 1;
14 my $storagename = "zfstank99";
15 my $subvol = 'regressiontest';
19 my $vmdisk = "vm-102-disk-1";
20 my $vmbase = "base-100-disk-1";
21 my $vmlinked = "vm-101-disk-1";
22 my $ctdisk = "subvol-202-disk-1";
23 my $ctbase = "basevol-200-disk-1";
24 my $ctlinked = "subvol-201-disk-1";
26 my $basesnap = '@__base__';
29 #create zfs suvol for testing
36 my $end_test = $testnum;
41 $start_test = $ARGV[0];
42 } elsif (@ARGV == 1) {
43 $start_test = $ARGV[0];
49 print "\nrun test19 \"path\"\n";
54 @res = PVE
::Storage
::path
($cfg, "$storagename:$vmdisk");
55 if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmdisk") {
58 warn "Test 19 a: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmdisk'\ get \'$res[0]\'";
60 if ($res[1] ne "102") {
65 warn "Test 19 a: owner is not correct: expected \'102\' get \'$res[1]\'";
67 if ($res[2] ne "images") {
72 warn "Test 19 a: owner is not correct: expected \'images\' get \'$res[2]\'";
83 @res = PVE
::Storage
::path
($cfg, "$storagename:$vmbase");
84 if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmbase") {
87 warn "Test 19 b: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmbase'\ get \'$res[0]\'";
89 if ($res[1] ne "100") {
94 warn "Test 19 b: owner is not correct: expected \'100\' get \'$res[1]\'";
96 if ($res[2] ne "images") {
101 warn "Test 19 b: owner is not correct: expected \'images\' get \'$res[2]\'";
106 warn "Test 19 b: $@";
112 @res = PVE
::Storage
::path
($cfg, "$storagename:$vmbase\/$vmlinked");
113 if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmlinked") {
116 warn "Test 19 c: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmlinked'\ get \'$res[0]\'";
118 if ($res[1] ne "101") {
123 warn "Test 19 c: owner is not correct: expected \'101\' get \'$res[1]\'";
125 if ($res[2] ne "images") {
130 warn "Test 19 c: owner is not correct: expected \'images\' get \'$res[2]\'";
135 warn "Test 19 c: $@";
141 @res = PVE
::Storage
::path
($cfg, "$storagename:$ctdisk");
142 if ($res[0] ne "\/regressiontest\/$ctdisk") {
145 warn "Test 19 d: path is not correct: expected \'/regressiontest\/$ctdisk'\ get \'$res[0]\'";
147 if ($res[1] ne "202") {
152 warn "Test 19 d: owner is not correct: expected \'202\' get \'$res[1]\'";
154 if ($res[2] ne "images") {
159 warn "Test 19 d: owner is not correct: expected \'images\' get \'$res[2]\'";
164 warn "Test 19 d: $@";
170 @res = PVE
::Storage
::path
($cfg, "$storagename:$ctbase");
171 if ($res[0] ne "\/regressiontest\/$ctbase") {
174 warn "Test 19 e: path is not correct: expected \'\/regressiontest\/$ctbase'\ get \'$res[0]\'";
176 if ($res[1] ne "200") {
181 warn "Test 19 e: owner is not correct: expected \'200\' get \'$res[1]\'";
183 if ($res[2] ne "images") {
188 warn "Test 19 e: owner is not correct: expected \'images\' get \'$res[2]\'";
193 warn "Test 19 e: $@";
199 @res = PVE
::Storage
::path
($cfg, "$storagename:$ctbase\/$ctlinked");
200 if ($res[0] ne "\/regressiontest\/$ctlinked") {
203 warn "Test 19 f: path is not correct: expected \'\/regressiontest\/$ctlinked'\ get \'$res[0]\'";
205 if ($res[1] ne "201") {
210 warn "Test 19 f: owner is not correct: expected \'201\' get \'$res[1]\'";
212 if ($res[2] ne "images") {
217 warn "Test 19 f: owner is not correct: expected \'images\' get \'$res[2]\'";
222 warn "Test 19 f: $@";
225 $tests->{19} = $test19;
229 print "\nrun test17 \"scan_zfs\"\n";
233 $res = PVE
::Storage
::scan_zfs
($cfg, $storagename);
236 foreach my $subvol (@$res){
237 if ($subvol->{pool
} eq 'regressiontest') {
243 warn "Test 18 a: not pool";
248 warn "Test 18 a: $@";
253 $res = PVE
::Storage
::scan_zfs
($cfg, $storagename);
255 foreach my $subvol (@$res){
256 if ($subvol->{pool
} eq 'zfspool/subvol') {
262 foreach my $subvol (@$res){
263 if ($subvol->{pool
} eq 'zfspool/basevol') {
271 warn "Test 18 a: $@";
274 $tests->{18} = $test18;
278 print "\nrun test17 \"deactivate_storage\"\n";
281 PVE
::Storage
::activate_storage
($cfg, $storagename);
282 PVE
::Storage
::deactivate_storage
($cfg, $storagename);
286 warn "Test 17 a: $@";
289 $tests->{17} = $test17;
293 print "\nrun test16 \"activate_storage\"\n";
296 PVE
::Storage
::activate_storage
($cfg, $storagename);
300 warn "Test 16 a: $@";
303 $tests->{16} = $test16;
307 print "\nrun test15 \"template_list and vdisk_list\"\n";
309 my $hash = Dumper
{};
311 my $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "vztmpl");
312 if ( $hash ne $res ) {
314 warn "Test 15 a failed\n";
318 $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "iso");
319 if ( $hash ne $res ) {
321 warn "Test 15 b failed\n";
325 $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "backup");
326 if ( $hash ne $res ) {
328 warn "Test 15 c failed\n";
332 $hash = Dumper
{'zfstank99' => [
335 'volid' => 'zfstank99:base-100-disk-1',
336 'name' => 'base-100-disk-1',
338 'size' => 1073741824,
343 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 100, ["$storagename:$vmbase"]);
345 if ( $hash ne $res ) {
347 warn "Test 15 d failed\n";
351 $hash = Dumper
{'zfstank99' => [
354 'volid' => 'zfstank99:vm-102-disk-1',
355 'name' => 'vm-102-disk-1',
357 'size' => 1073741824,
362 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 102, ["$storagename:$vmdisk"]);
363 if ( $hash ne $res ) {
365 warn "Test 15 e failed\n";
369 $hash = Dumper
{'zfstank99' => [
371 'parent' => 'base-100-disk-1@__base__',
372 'volid' => "$storagename:$vmbase\/$vmlinked",
373 'name' => 'vm-101-disk-1',
375 'size' => 1073741824,
380 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 101, ["$storagename:$vmbase\/$vmlinked"]);
381 if ( $hash ne $res ) {
383 warn "Test 15 f failed\n";
387 $hash = Dumper
{'zfstank99' => [
390 'volid' => 'zfstank99:basevol-200-disk-1',
391 'name' => 'basevol-200-disk-1',
393 'size' => 1073741824,
398 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 200, ["$storagename:$ctbase"]);
399 if ( $hash ne $res ) {
401 warn "Test 15 g failed\n";
405 $hash = Dumper
{'zfstank99' => [
408 'volid' => 'zfstank99:subvol-202-disk-1',
409 'name' => 'subvol-202-disk-1',
411 'size' => 1073741824,
416 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 202, ["$storagename:$ctdisk"]);
417 if ( $hash ne $res ) {
419 warn "Test 15 h failed\n";
423 $hash = Dumper
{'zfstank99' => [
425 'parent' => 'basevol-200-disk-1@__base__',
426 'volid' => "$storagename:$ctbase\/$ctlinked",
427 'name' => 'subvol-201-disk-1',
429 'size' => 1073741824,
433 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 201, ["$storagename:$ctbase\/$ctlinked"]);
434 if ( $hash ne $res ) {
436 warn "Test 15 i failed\n";
439 $tests->{15} = $test15;
443 print "\nrun test14 \"vdisk_free\"\n";
446 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmdisk");
449 run_command
("zfs list $zpath\/$vmdisk", outfunc
=> sub {}, errfunc
=> sub {});
453 warn "Test14 a: vdisk still exists\n";
462 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase");
466 warn "Test14 b: free vdisk should not work\n";
470 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase\/$vmlinked");
473 run_command
("zfs list $zpath\/$vmlinked", outfunc
=> sub {}, errfunc
=> sub {});
477 warn "Test14 c: vdisk still exists\n";
486 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctdisk");
489 run_command
("zfs list $zpath\/$ctdisk", outfunc
=> sub {}, errfunc
=> sub {});
493 warn "Test14 d: vdisk still exists\n";
502 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase");
506 warn "Test14 e: free vdisk should not work\n";
510 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase\/$ctlinked");
513 run_command
("zfs list $zpath\/$ctlinked", outfunc
=> sub {}, errfunc
=> sub {});
517 warn "Test14 f: vdisk still exists\n";
526 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase");
529 run_command
("zfs list $zpath\/$vmbase", outfunc
=> sub {}, errfunc
=> sub {});
533 warn "Test14 g: vdisk still exists\n";
542 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase");
545 run_command
("zfs list $zpath\/$ctbase", outfunc
=> sub {}, errfunc
=> sub {});
549 warn "Test14 h: vdisk still exists\n";
557 $tests->{14} = $test14;
561 print "\nrun test13 \"vdisk_alloc\"\n";
564 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "112", "raw", undef ,1024 * 1024);
566 if ($tmp_volid ne "$storagename:vm-112-disk-1") {
567 die "volname:$tmp_volid don't match\n";
570 run_command
("zfs get -H volsize $zpath\/vm-112-disk-1", outfunc
=>
571 sub { my $tmp = shift;
572 if ($tmp !~ m/^$zpath\/vm-112-disk-1
.*volsize
.*1G
.*$/) {
573 die "size don't match\n";
588 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "112", "raw", undef ,2048 * 1024);
590 if ($tmp_volid ne "$storagename:vm-112-disk-2") {
591 die "volname:$tmp_volid don't match\n";
594 run_command
("zfs get -H volsize $zpath\/vm-112-disk-2", outfunc
=>
595 sub { my $tmp = shift;
596 if ($tmp !~ m/^$zpath\/vm-112-disk-2
.*volsize
.*2G
.*$/) {
597 die "size don't match\n";
612 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "113", "subvol", undef ,1024 * 1024);
614 if ($tmp_volid ne "$storagename:subvol-113-disk-1") {
615 die "volname:$tmp_volid don't match\n";
618 run_command
("zfs get -H refquota $zpath\/subvol-113-disk-1", outfunc
=>
619 sub { my $tmp = shift;
620 if ($tmp !~ m/^$zpath\/subvol
-113-disk
-1.*refquota
.*1G
.*$/) {
621 die "size don't match\n";
636 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "113", "subvol", undef ,2048 * 1024);
638 if ($tmp_volid ne "$storagename:subvol-113-disk-2") {
639 die "volname:$tmp_volid don't match\n";
642 run_command
("zfs get -H refquota $zpath\/subvol-113-disk-2", outfunc
=>
643 sub { my $tmp = shift;
644 if ($tmp !~ m/^$zpath\/subvol
-113-disk
-2.*refquota
.*G
.*$/) {
645 die "size don't match\n";
659 $tests->{13} = $test13;
663 print "\nrun test12 \"vdisk_create_base\"\n";
666 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$vmdisk");
668 if ($tmp_volid ne "$storagename:base-102-disk-1") {
672 run_command
("zfs list $zpath\/base-102-disk-1", outfunc
=> sub {});
685 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$vmlinked");
687 if ($tmp_volid ne "$storagename:base-101-disk-1") {
691 run_command
("zfs list $zpath\/base-101-disk-1", outfunc
=> sub {});
704 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$ctdisk");
706 if ($tmp_volid ne "$storagename:basevol-202-disk-1") {
710 run_command
("zfs list $zpath\/basevol-202-disk-1", outfunc
=> sub {});
723 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$ctlinked");
725 if ($tmp_volid ne "$storagename:basevol-201-disk-1") {
729 run_command
("zfs list $zpath\/basevol-201-disk-1", outfunc
=> sub {});
741 $tests->{12} = $test12;
745 print "\nrun test11 \"volume_is_base\"\n";
748 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmdisk", 110);
752 warn "Test11 a: clone_image only works on base images";
756 if ("$storagename:$vmbase\/vm-110-disk-1" ne
757 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmbase", 110, '__base__')){
761 run_command
("zfs list -H -o volsize $zpath\/vm-110-disk-1", outfunc
=> sub {
765 warn "Test11 b not correct volsize" if $line !~ m/$volsize/;
774 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmbase\/$vmlinked", 111);
778 warn "Test11 c: clone_image only works on base images";
782 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctdisk", 110);
786 warn "Test11 d: clone_image only works on base images";
790 if ( "$storagename:$ctbase\/subvol-210-disk-1" ne
791 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctbase", 210, '__base__')){
795 run_command
("zfs list -H -o refquota $zpath\/subvol-210-disk-1", outfunc
=> sub {
799 warn "Test11 e not correct volsize" if $line !~ m/$volsize/;
808 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctbase\/$ctlinked", 211);
812 warn "Test11 f: clone_image only works on base images";
815 $tests->{11} = $test11;
819 print "\nrun test10 \"volume_is_base\"\n";
822 if (1 == volume_is_base
($cfg, "$storagename:$vmdisk")) {
824 warn "Test10 a: is no base";
834 if (0 == volume_is_base
($cfg, "$storagename:$vmbase")) {
836 warn "Test10 b: is base";
846 if (1 == volume_is_base
($cfg, "$storagename:$vmbase\/$vmlinked")) {
848 warn "Test10 c: is no base";
858 if (1 == volume_is_base
($cfg, "$storagename:$ctdisk")) {
860 warn "Test10 d: is no base";
870 if (0 == volume_is_base
($cfg, "$storagename:$ctbase")) {
872 warn "Test10 e: is base";
882 if (1 == volume_is_base
($cfg, "$storagename:$ctbase\/$ctlinked")) {
884 warn "Test10 f: is no base";
893 $tests->{10} = $test10;
897 print "\nrun test9 \"parse_volume_id\"\n";
900 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmdisk");
902 if ($store ne $storagename || $disk ne $vmdisk) {
904 warn "Test9 a: parsing wrong";
914 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmbase");
916 if ($store ne $storagename || $disk ne $vmbase) {
918 warn "Test9 b: parsing wrong";
928 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmbase\/$vmlinked");
930 if ($store ne $storagename || $disk ne "$vmbase\/$vmlinked") {
932 warn "Test9 c: parsing wrong";
942 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctdisk");
944 if ($store ne $storagename || $disk ne $ctdisk) {
946 warn "Test9 d: parsing wrong";
956 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctbase");
958 if ($store ne $storagename || $disk ne $ctbase) {
960 warn "Test9 e: parsing wrong";
970 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctbase\/$ctlinked");
972 if ($store ne $storagename || $disk ne "$ctbase\/$ctlinked") {
974 warn "Test9 f: parsing wrong";
983 $tests->{9} = $test9;
987 print "\nrun test8 \"parse_volname\"\n";
990 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmdisk");
992 if ($vtype ne 'images' || $vmid ne '102' || $name ne $vmdisk ||
993 defined($basename) || defined($basevmid) || $isBase ||
996 warn "Test8 a: parsing wrong";
1006 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmbase");
1008 if ($vtype ne 'images' || $vmid ne '100' || $name ne $vmbase ||
1009 defined($basename) || defined($basevmid) || !$isBase ||
1012 warn "Test8 b: parsing wrong";
1021 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmbase\/$vmlinked");
1023 if ($vtype ne 'images' || $name ne $vmlinked || $vmid ne '101' ||
1024 $basename ne $vmbase || $basevmid ne '100' || $isBase ||
1027 warn "Test8 c: parsing wrong";
1036 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctdisk");
1038 if ($vtype ne 'images' || $vmid ne '202' || $name ne $ctdisk ||
1039 defined($basename) || defined($basevmid) || $isBase ||
1040 $format ne 'subvol') {
1042 warn "Test8 d: parsing wrong";
1052 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctbase");
1053 if ($vtype ne 'images' || $vmid ne '200' || $name ne $ctbase ||
1054 defined($basename) || defined($basevmid) || !$isBase ||
1055 $format ne 'subvol') {
1057 warn "Test8 e: parsing wrong";
1066 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctbase\/$ctlinked");
1068 if ($vtype ne 'images' || $name ne $ctlinked || $vmid ne '201' ||
1069 $basename ne $ctbase || $basevmid ne '200' || $isBase ||
1070 $format ne 'subvol') {
1072 warn "Test8 f: parsing wrong";
1080 $tests->{8} = $test8;
1084 print "\nrun test7 \"volume_rollback\"\n";
1087 my $parse_guid = sub {
1090 if ( $line =~ m/^Disk identifier \(GUID\)\: (.*)$/ ) {
1096 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1097 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1099 my $old_guid = $tmp_guid;
1100 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap1');
1102 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1104 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmdisk", 'snap1');
1106 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1107 if ($old_guid ne $tmp_guid) {
1109 warn "Test7 a: Zvol makes no rollback";
1124 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1125 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1127 my $old_guid = $tmp_guid;
1128 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap1');
1130 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1132 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase", 'snap1');
1134 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1135 if ($old_guid ne $tmp_guid) {
1137 warn "Test7 b: Zvol makes no rollback";
1152 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1153 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1155 my $old_guid = $tmp_guid;
1156 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1158 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1160 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1162 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1163 if ($old_guid ne $tmp_guid) {
1165 warn "Test7 c: Zvol makes no rollback";
1180 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap1');
1182 run_command
("touch \/$zpath\/$ctdisk\/test.txt", outfunc
=> $parse_guid);
1184 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctdisk", 'snap1');
1186 run_command
("ls \/$zpath\/$ctdisk\/test.txt", errofunc
=> sub {});
1204 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap1');
1206 run_command
("touch \/$zpath\/$ctbase\/test.txt", outfunc
=> $parse_guid);
1208 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase", 'snap1');
1210 run_command
("ls \/$zpath\/$ctbase\/test.txt", errofunc
=> sub {});
1228 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1230 run_command
("touch \/$zpath\/$ctlinked\/test.txt", outfunc
=> $parse_guid);
1232 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1234 run_command
("ls \/$zpath\/$ctlinked\/test.txt", errofunc
=> sub {});
1252 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap2');
1255 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmdisk", 'snap1');
1259 warn "Test7 h: Not allowed to rollback";
1268 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap2');
1271 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase", 'snap1');
1275 warn "Test7 i: Not allowed to rollback";
1284 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap2');
1287 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1291 warn "Test7 j: Not allowed to rollback";
1300 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap2');
1303 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctdisk", 'snap1');
1307 warn "Test7 k: Not allowed to rollback";
1316 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap2');
1319 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase", 'snap1');
1323 warn "Test7 l: Not allowed to rollback";
1332 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase/$ctlinked", 'snap2');
1335 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1339 warn "Test7 m: Not allowed to rollback";
1347 $tests->{7} = $test7;
1351 print "\nrun test6 \"volume_rollback_is_possible\"\n";
1354 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap1');
1356 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmdisk", 'snap1')) {
1358 warn "Test6 a: Rollback sould possible"
1367 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap1');
1369 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase", 'snap1')) {
1371 warn "Test6 b: Rollback sould possible"
1380 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmlinked", 'snap1');
1382 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1')) {
1384 warn "Test6 c: Rollback sould possible"
1393 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap1');
1395 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctdisk", 'snap1')) {
1397 warn "Test6 d: Rollback sould possible"
1406 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap1');
1408 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase", 'snap1')) {
1410 warn "Test6 e: Rollback sould possible"
1419 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctlinked", 'snap1');
1421 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1')) {
1423 warn "Test6 f: Rollback sould possible"
1432 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap2');
1433 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmdisk", 'snap1');
1437 warn "Test6 g: Rollback should not possible";
1441 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap2');
1442 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase", 'snap1');
1446 warn "Test6 h: Rollback should not possible";
1450 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmlinked", 'snap2');
1451 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1455 warn "Test6 j: Rollback should not possible";
1459 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap2');
1460 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctdisk", 'snap1');
1464 warn "Test6 k: Rollback should not possible";
1468 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap2');
1469 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase", 'snap1');
1473 warn "Test6 l: Rollback should not possible";
1477 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctlinked", 'snap2');
1478 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1');
1482 warn "Test6 m: Rollback should not possible";
1485 $tests->{6} = $test6;
1489 print "\nrun test5 \"volume_snapshot_delete\"\n";
1490 my $out = sub{my $tmp = shift;};
1493 run_command
("zfs snapshot $zpath\/$vmdisk\@snap");
1495 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmdisk", 'snap');
1497 run_command
("zfs list $zpath\/$vmdisk\@snap", errfunc
=> $out, outfunc
=> $out);
1501 warn "Test5 a: snapshot still exists";
1506 warn "Test5 PVE a: $@";
1515 run_command
("zfs snapshot $zpath\/$vmbase\@snap");
1517 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase", 'snap');
1519 run_command
("zfs list $zpath\/$vmbase\@snap", errmsg
=> $out, outfunc
=> $out);
1523 warn "Test5 b: snapshot still exists";
1528 warn "Test5 PVE b: $@";
1537 run_command
("zfs snapshot $zpath\/$vmlinked\@snap");
1539 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap');
1541 run_command
("zfs list $zpath\/$vmlinked\@snap", errmsg
=> $out, outfunc
=> $out);
1545 warn "Test5 c: snapshot still exists";
1550 warn "Test5 PVE c: $@";
1559 run_command
("zfs snapshot $zpath\/$ctdisk\@snap");
1561 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctdisk", 'snap');
1563 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1567 warn "Test5 d: snapshot still exists";
1572 warn "Test5 PVE d: $@";
1581 run_command
("zfs snapshot $zpath\/$ctbase\@snap");
1583 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctbase", 'snap');
1585 run_command
("zfs list $zpath\/$ctbase\@snap", errmsg
=> $out, outfunc
=> $out);
1589 warn "Test5 e: snapshot still exists";
1594 warn "Test5 PVE e: $@";
1603 run_command
("zfs snapshot $zpath\/$ctlinked\@snap");
1605 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap');
1607 run_command
("zfs list $zpath\/$ctlinked\@snap", errmsg
=> $out, outfunc
=> $out);
1611 warn "Test5 f: snapshot still exists";
1616 warn "Test5 PVE f: $@";
1623 print "######Ignore Output if no Test5 g: is includet######\n";
1625 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase", '__base__');
1627 run_command
("zfs list $zpath\/$vmbase\@__base__", outfunc
=> $out);
1636 warn "Test5 PVE g: snapshot __base__ can be erased";
1638 print "######End Ignroe#######\n";
1640 $tests->{5} = $test5;
1644 print "\nrun test4 \"volume_snapshot\"\n";
1648 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap');
1650 run_command
("zfs list $zpath\/$vmdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1663 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap');
1665 run_command
("zfs list $zpath\/$vmbase\@snap", errmsg
=> $out, outfunc
=> $out);
1678 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap');
1680 run_command
("zfs list $zpath\/$vmdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1693 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap');
1695 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1708 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap');
1710 run_command
("zfs list $zpath\/$ctbase\@snap", errmsg
=> $out, outfunc
=> $out);
1723 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap');
1725 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1737 $tests->{4} = $test4;
1741 print "\nrun test3 \"volume_has_feature\"\n";
1744 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmdisk", undef, 0)) {
1746 warn "Test3 a failed";
1755 if (PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase", undef, 0)) {
1757 warn "Test3 b failed";
1766 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1768 warn "Test3 c failed";
1777 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctdisk", undef, 0)) {
1779 warn "Test3 d failed";
1788 if (PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase", undef, 0)) {
1790 warn "Test3 e failed";
1799 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1801 warn "Test3 f failed";
1810 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmdisk", undef, 0)) {
1812 warn "Test3 g failed";
1821 if (!PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase", undef, 0)) {
1823 warn "Test3 h failed";
1832 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1834 warn "Test3 h failed";
1843 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctdisk", undef, 0)) {
1845 warn "Test3 i failed";
1854 if (!PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase", undef, 0)) {
1856 warn "Test3 j failed";
1865 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1867 warn "Test3 k failed";
1876 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmdisk", undef, 0)) {
1878 warn "Test3 l failed";
1887 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase", undef, 0)) {
1889 warn "Test3 m failed";
1898 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1900 warn "Test3 n failed";
1909 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctdisk", undef, 0)) {
1911 warn "Test3 o failed";
1920 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase", undef, 0)) {
1922 warn "Test3 p failed";
1931 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1933 warn "Test3 q failed";
1942 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmdisk", undef, 0)) {
1944 warn "Test3 r failed";
1953 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase", undef, 0)) {
1955 warn "Test3 s failed";
1964 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1966 warn "Test3 t failed";
1975 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctdisk", undef, 0)) {
1977 warn "Test3 u failed";
1986 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase", undef, 0)) {
1988 warn "Test3 v failed";
1997 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1999 warn "Test3 w failed";
2008 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmdisk", undef, 0)) {
2010 warn "Test3 x failed";
2019 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase", undef, 0)) {
2021 warn "Test3 y failed";
2030 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
2032 warn "Test3 z failed";
2041 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctdisk", undef, 0)) {
2043 warn "Test3 A failed";
2052 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase", undef, 0)) {
2054 warn "Test3 B failed";
2063 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
2065 warn "Test3 C failed";
2074 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmdisk", 'test', 0)) {
2076 warn "Test3 a1 failed";
2081 warn "Test3 a1: $@";
2085 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase", 'test', 0)) {
2087 warn "Test3 b1 failed";
2092 warn "Test3 b1: $@";
2096 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2098 warn "Test3 c1 failed";
2103 warn "Test3 c1: $@";
2107 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctdisk", 'test', 0)) {
2109 warn "Test3 d1 failed";
2114 warn "Test3 d1: $@";
2118 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase", 'test', 0)) {
2120 warn "Test3 e1 failed";
2125 warn "Test3 e1: $@";
2129 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2131 warn "Test3 f1 failed";
2136 warn "Test3 f1: $@";
2140 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmdisk", 'test', 0)) {
2142 warn "Test3 g1 failed";
2147 warn "Test3 g1: $@";
2151 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase", 'test', 0)) {
2153 warn "Test3 h1 failed";
2158 warn "Test3 h1: $@";
2162 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2164 warn "Test3 h1 failed";
2169 warn "Test3 h1: $@";
2173 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctdisk", 'test', 0)) {
2175 warn "Test3 i1 failed";
2180 warn "Test3 i1: $@";
2184 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase", 'test', 0)) {
2186 warn "Test3 j1 failed";
2191 warn "Test3 j1: $@";
2195 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2197 warn "Test3 k1 failed";
2202 warn "Test3 k1: $@";
2206 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmdisk", 'test', 0)) {
2208 warn "Test3 l1 failed";
2213 warn "Test3 l1: $@";
2217 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase", 'test', 0)) {
2219 warn "Test3 m1 failed";
2224 warn "Test3 m1: $@";
2228 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2230 warn "Test3 n1 failed";
2235 warn "Test3 n1: $@";
2239 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctdisk", 'test', 0)) {
2241 warn "Test3 o1 failed";
2246 warn "Test3 o1: $@";
2250 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase", 'test', 0)) {
2252 warn "Test3 p1 failed";
2257 warn "Test3 p1: $@";
2261 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2263 warn "Test3 q1 failed";
2268 warn "Test3 q1: $@";
2272 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmdisk", 'test', 0)) {
2274 warn "Test3 r1 failed";
2279 warn "Test3 r1: $@";
2283 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase", 'test', 0)) {
2285 warn "Test3 s1 failed";
2290 warn "Test3 s1: $@";
2294 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2296 warn "Test3 t1 failed";
2301 warn "Test3 t1: $@";
2305 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctdisk", 'test', 0)) {
2307 warn "Test3 u1 failed";
2312 warn "Test3 u1: $@";
2316 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase", 'test', 0)) {
2318 warn "Test3 v1 failed";
2323 warn "Test3 v1: $@";
2327 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2329 warn "Test3 w1 failed";
2334 warn "Test3 w1: $@";
2338 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmdisk", 'test', 0)) {
2340 warn "Test3 x1 failed";
2345 warn "Test3 x1: $@";
2349 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase", 'test', 0)) {
2351 warn "Test3 y1 failed";
2356 warn "Test3 y1: $@";
2360 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2362 warn "Test3 z1 failed";
2367 warn "Test3 z1: $@";
2371 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctdisk", 'test', 0)) {
2373 warn "Test3 A1 failed";
2378 warn "Test3 A1: $@";
2382 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase", 'test', 0)) {
2384 warn "Test3 B1 failed";
2389 warn "Test3 B1: $@";
2393 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2395 warn "Test3 C1 failed";
2400 warn "Test3 C1: $@";
2403 $tests->{3} = $test3;
2407 print "\nrun test2 \"volume_resize\"\n";
2408 my $newsize = ($volsize + 1) * 1024 * 1024 * 1024;
2411 if (($newsize/1024) !=
2412 PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmdisk", $newsize, 0)) {
2414 warn "Test2 a failed";
2417 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmdisk")) {
2419 warn "Test2 a failed";
2428 warn "Test2 b failed" if ($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmbase", $newsize, 0);
2429 warn "Test2 b failed" if $newsize !=
2430 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase");
2438 if (($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmbase\/$vmlinked", $newsize, 0)) {
2440 warn "Test2 c failed";
2443 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2445 warn "Test2 c failed";
2454 if (($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctdisk", $newsize, 0)) {
2456 warn "Test2 d failed";
2459 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctdisk")) {
2461 warn "Test2 d failed"
2470 if (($newsize/1024) !=
2471 PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctbase", $newsize, 0)) {
2473 warn "Test2 e failed";
2476 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase")) {
2478 warn "Test2 e failed";
2487 if (($newsize/1024) !=
2488 PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctbase\/$ctlinked", $newsize, 0)) {
2490 warn "Test2 f failed";
2493 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase\/$ctlinked")) {
2495 warn "Test2 f failed";
2503 $tests->{2} = $test2;
2507 print "\nrun test1 \"volume_size_info\"\n";
2508 my $size = ($volsize * 1024 * 1024 * 1024);
2511 if ($size != PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmdisk")) {
2513 warn "Test1 a failed";
2518 warn "Test1 a : $@";
2522 if ($size != PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase")) {
2524 warn "Test1 b failed";
2530 warn "Test1 b : $@";
2535 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2537 warn "Test1 c failed";
2542 warn "Test1 c : $@";
2547 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctdisk")) {
2549 warn "Test1 d failed";
2554 warn "Test1 d : $@";
2559 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase")) {
2561 warn "Test1 e failed";
2566 warn "Test1 e : $@";
2571 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2573 warn "Test1 f failed"
2578 warn "Test1 f : $@";
2582 $tests->{1} = $test1;
2589 print "create zvol $vmdisk\n" if $verbose;
2590 run_command
("zfs create -V${volsize}G $zpath\/$vmdisk");
2592 print "create zvol $vmbase\n" if $verbose;
2593 run_command
("zfs create -V${volsize}G $zpath\/$vmbase");
2594 run_command
("zfs snapshot $zpath\/$vmbase$basesnap");
2596 print "create linked clone $vmlinked\n" if $verbose;
2597 run_command
("zfs clone $zpath\/$vmbase$basesnap $zpath\/$vmlinked");
2600 print "create subvol $ctdisk\n" if $verbose;
2601 run_command
("zfs create -o refquota=${volsize}G $zpath\/$ctdisk");
2603 print "create subvol $vmbase\n" if $verbose;
2604 run_command
("zfs create -o refquota=${volsize}G $zpath\/$ctbase");
2605 run_command
("zfs snapshot $zpath\/$ctbase$basesnap");
2607 print "create linked clone $vmlinked\n" if $verbose;
2608 run_command
("zfs clone $zpath\/$ctbase$basesnap $zpath\/$ctlinked -o refquota=${volsize}G");
2609 run_command
("udevadm trigger --subsystem-match block");
2610 run_command
("udevadm settle --timeout 10 --exit-if-exists=/dev/zvol/$zpath\/$ctlinked");
2615 print "destroy $pool\/$subvol\n" if $verbose;
2616 eval { run_command
("zfs destroy $zpath -r"); };
2618 print "cleanup failed: $@\nretrying once\n" if $verbose;
2619 eval { run_command
("zfs destroy $zpath -r"); };
2631 run_command
("truncate -s 8G zpool.img");
2638 run_command
("zpool create $subvol $pwd\/zpool.img");
2645 sub clean_up_zpool
{
2648 run_command
("zpool destroy $subvol");
2655 sub volume_is_base
{
2656 my ($cfg, $volid) = @_;
2658 my (undef, undef, undef, undef, undef, $isBase, undef) = PVE
::Storage
::parse_volname
($cfg, $volid);
2667 print "Start tests for ZFSPoolPlugin\n";
2679 'order' => {'zfstank99' => 1,}
2684 for (my $i = $start_test; $i <= $end_test; $i++) {
2696 $time = time - $time;
2698 print "Stop tests for ZFSPoolPlugin\n";
2699 print "$count tests failed\n";
2700 print "Time: ${time}s\n";