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';
22 my $vmdisk = "vm-102-disk-1";
23 my $vmbase = "base-100-disk-1";
24 my $vmlinked = "vm-101-disk-1";
25 my $ctdisk = "subvol-202-disk-1";
26 my $ctbase = "basevol-200-disk-1";
27 my $ctlinked = "subvol-201-disk-1";
29 my $basesnap = '@__base__';
32 #create zfs subvol for testing
39 my $end_test = $testnum;
44 $start_test = $ARGV[0];
45 } elsif (@ARGV == 1) {
46 $start_test = $ARGV[0];
52 print "\nrun test19 \"path\"\n";
57 @res = PVE
::Storage
::path
($cfg, "$storagename:$vmdisk");
58 if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmdisk") {
61 warn "Test 19 a: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmdisk'\ get \'$res[0]\'";
63 if ($res[1] ne "102") {
68 warn "Test 19 a: owner is not correct: expected \'102\' get \'$res[1]\'";
70 if ($res[2] ne "images") {
75 warn "Test 19 a: owner is not correct: expected \'images\' get \'$res[2]\'";
86 @res = PVE
::Storage
::path
($cfg, "$storagename:$vmbase");
87 if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmbase") {
90 warn "Test 19 b: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmbase'\ get \'$res[0]\'";
92 if ($res[1] ne "100") {
97 warn "Test 19 b: owner is not correct: expected \'100\' get \'$res[1]\'";
99 if ($res[2] ne "images") {
104 warn "Test 19 b: owner is not correct: expected \'images\' get \'$res[2]\'";
109 warn "Test 19 b: $@";
115 @res = PVE
::Storage
::path
($cfg, "$storagename:$vmbase\/$vmlinked");
116 if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmlinked") {
119 warn "Test 19 c: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmlinked'\ get \'$res[0]\'";
121 if ($res[1] ne "101") {
126 warn "Test 19 c: owner is not correct: expected \'101\' get \'$res[1]\'";
128 if ($res[2] ne "images") {
133 warn "Test 19 c: owner is not correct: expected \'images\' get \'$res[2]\'";
138 warn "Test 19 c: $@";
144 @res = PVE
::Storage
::path
($cfg, "$storagename:$ctdisk");
145 if ($res[0] ne "\/regressiontest\/$ctdisk") {
148 warn "Test 19 d: path is not correct: expected \'/regressiontest\/$ctdisk'\ get \'$res[0]\'";
150 if ($res[1] ne "202") {
155 warn "Test 19 d: owner is not correct: expected \'202\' get \'$res[1]\'";
157 if ($res[2] ne "images") {
162 warn "Test 19 d: owner is not correct: expected \'images\' get \'$res[2]\'";
167 warn "Test 19 d: $@";
173 @res = PVE
::Storage
::path
($cfg, "$storagename:$ctbase");
174 if ($res[0] ne "\/regressiontest\/$ctbase") {
177 warn "Test 19 e: path is not correct: expected \'\/regressiontest\/$ctbase'\ get \'$res[0]\'";
179 if ($res[1] ne "200") {
184 warn "Test 19 e: owner is not correct: expected \'200\' get \'$res[1]\'";
186 if ($res[2] ne "images") {
191 warn "Test 19 e: owner is not correct: expected \'images\' get \'$res[2]\'";
196 warn "Test 19 e: $@";
202 @res = PVE
::Storage
::path
($cfg, "$storagename:$ctbase\/$ctlinked");
203 if ($res[0] ne "\/regressiontest\/$ctlinked") {
206 warn "Test 19 f: path is not correct: expected \'\/regressiontest\/$ctlinked'\ get \'$res[0]\'";
208 if ($res[1] ne "201") {
213 warn "Test 19 f: owner is not correct: expected \'201\' get \'$res[1]\'";
215 if ($res[2] ne "images") {
220 warn "Test 19 f: owner is not correct: expected \'images\' get \'$res[2]\'";
225 warn "Test 19 f: $@";
228 $tests->{19} = $test19;
232 print "\nrun test18 \"scan_zfs\"\n";
236 $res = PVE
::Storage
::scan_zfs
($cfg, $storagename);
239 foreach my $subvol (@$res){
240 if ($subvol->{pool
} eq 'regressiontest') {
246 warn "Test 18 a: not pool";
251 warn "Test 18 a: $@";
256 $res = PVE
::Storage
::scan_zfs
($cfg, $storagename);
258 foreach my $subvol (@$res){
259 if ($subvol->{pool
} eq 'zfspool/subvol') {
265 foreach my $subvol (@$res){
266 if ($subvol->{pool
} eq 'zfspool/basevol') {
274 warn "Test 18 a: $@";
277 $tests->{18} = $test18;
281 print "\nrun test17 \"deactivate_storage\"\n";
284 PVE
::Storage
::activate_storage
($cfg, $storagename);
285 PVE
::Storage
::deactivate_storage
($cfg, $storagename);
289 warn "Test 17 a: $@";
292 $tests->{17} = $test17;
296 print "\nrun test16 \"activate_storage\"\n";
299 PVE
::Storage
::activate_storage
($cfg, $storagename);
303 warn "Test 16 a: $@";
306 $tests->{16} = $test16;
310 print "\nrun test15 \"template_list and vdisk_list\"\n";
312 my $hash = Dumper
{};
314 my $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "vztmpl");
315 if ( $hash ne $res ) {
317 warn "Test 15 a failed\n";
321 $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "iso");
322 if ( $hash ne $res ) {
324 warn "Test 15 b failed\n";
328 $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "backup");
329 if ( $hash ne $res ) {
331 warn "Test 15 c failed\n";
335 $hash = Dumper
{'zfstank99' => [
338 'volid' => 'zfstank99:base-100-disk-1',
339 'name' => 'base-100-disk-1',
341 'size' => 1073741824,
346 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 100, ["$storagename:$vmbase"]);
348 if ( $hash ne $res ) {
350 warn "Test 15 d failed\n";
354 $hash = Dumper
{'zfstank99' => [
357 'volid' => 'zfstank99:vm-102-disk-1',
358 'name' => 'vm-102-disk-1',
360 'size' => 1073741824,
365 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 102, ["$storagename:$vmdisk"]);
366 if ( $hash ne $res ) {
368 warn "Test 15 e failed\n";
372 $hash = Dumper
{'zfstank99' => [
374 'parent' => 'base-100-disk-1@__base__',
375 'volid' => "$storagename:$vmbase\/$vmlinked",
376 'name' => 'vm-101-disk-1',
378 'size' => 1073741824,
383 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 101, ["$storagename:$vmbase\/$vmlinked"]);
384 if ( $hash ne $res ) {
386 warn "Test 15 f failed\n";
390 $hash = Dumper
{'zfstank99' => [
393 'volid' => 'zfstank99:basevol-200-disk-1',
394 'name' => 'basevol-200-disk-1',
396 'size' => 1073741824,
401 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 200, ["$storagename:$ctbase"]);
402 if ( $hash ne $res ) {
404 warn "Test 15 g failed\n";
408 $hash = Dumper
{'zfstank99' => [
411 'volid' => 'zfstank99:subvol-202-disk-1',
412 'name' => 'subvol-202-disk-1',
414 'size' => 1073741824,
419 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 202, ["$storagename:$ctdisk"]);
420 if ( $hash ne $res ) {
422 warn "Test 15 h failed\n";
426 $hash = Dumper
{'zfstank99' => [
428 'parent' => 'basevol-200-disk-1@__base__',
429 'volid' => "$storagename:$ctbase\/$ctlinked",
430 'name' => 'subvol-201-disk-1',
432 'size' => 1073741824,
436 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 201, ["$storagename:$ctbase\/$ctlinked"]);
437 if ( $hash ne $res ) {
439 warn "Test 15 i failed\n";
442 $tests->{15} = $test15;
446 print "\nrun test14 \"vdisk_free\"\n";
449 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmdisk");
452 run_command
("zfs list $zpath\/$vmdisk", outfunc
=> sub {}, errfunc
=> sub {});
456 warn "Test14 a: vdisk still exists\n";
465 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase");
469 warn "Test14 b: free vdisk should not work\n";
473 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase\/$vmlinked");
476 run_command
("zfs list $zpath\/$vmlinked", outfunc
=> sub {}, errfunc
=> sub {});
480 warn "Test14 c: vdisk still exists\n";
489 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctdisk");
492 run_command
("zfs list $zpath\/$ctdisk", outfunc
=> sub {}, errfunc
=> sub {});
496 warn "Test14 d: vdisk still exists\n";
505 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase");
509 warn "Test14 e: free vdisk should not work\n";
513 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase\/$ctlinked");
516 run_command
("zfs list $zpath\/$ctlinked", outfunc
=> sub {}, errfunc
=> sub {});
520 warn "Test14 f: vdisk still exists\n";
529 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase");
532 run_command
("zfs list $zpath\/$vmbase", outfunc
=> sub {}, errfunc
=> sub {});
536 warn "Test14 g: vdisk still exists\n";
545 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase");
548 run_command
("zfs list $zpath\/$ctbase", outfunc
=> sub {}, errfunc
=> sub {});
552 warn "Test14 h: vdisk still exists\n";
560 $tests->{14} = $test14;
564 print "\nrun test13 \"vdisk_alloc\"\n";
567 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "112", "raw", undef ,1024 * 1024);
569 if ($tmp_volid ne "$storagename:vm-112-disk-0") {
570 die "volname:$tmp_volid don't match\n";
573 run_command
("zfs get -H volsize $zpath\/vm-112-disk-0", outfunc
=>
574 sub { my $tmp = shift;
575 if ($tmp !~ m/^$zpath\/vm-112-disk-0
.*volsize
.*1G
.*$/) {
576 die "size don't match\n";
591 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "112", "raw", undef ,2048 * 1024);
593 if ($tmp_volid ne "$storagename:vm-112-disk-1") {
594 die "volname:$tmp_volid don't match\n";
597 run_command
("zfs get -H volsize $zpath\/vm-112-disk-1", outfunc
=>
598 sub { my $tmp = shift;
599 if ($tmp !~ m/^$zpath\/vm-112-disk-1
.*volsize
.*2G
.*$/) {
600 die "size don't match\n";
615 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "113", "subvol", undef ,1024 * 1024);
617 if ($tmp_volid ne "$storagename:subvol-113-disk-0") {
618 die "volname:$tmp_volid don't match\n";
621 run_command
("zfs get -H refquota $zpath\/subvol-113-disk-0", outfunc
=>
622 sub { my $tmp = shift;
623 if ($tmp !~ m/^$zpath\/subvol
-113-disk
-0.*refquota
.*1G
.*$/) {
624 die "size don't match\n";
639 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "113", "subvol", undef ,2048 * 1024);
641 if ($tmp_volid ne "$storagename:subvol-113-disk-1") {
642 die "volname:$tmp_volid don't match\n";
645 run_command
("zfs get -H refquota $zpath\/subvol-113-disk-1", outfunc
=>
646 sub { my $tmp = shift;
647 if ($tmp !~ m/^$zpath\/subvol
-113-disk
-1.*refquota
.*G
.*$/) {
648 die "size don't match\n";
662 $tests->{13} = $test13;
666 print "\nrun test12 \"vdisk_create_base\"\n";
669 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$vmdisk");
671 if ($tmp_volid ne "$storagename:base-102-disk-1") {
675 run_command
("zfs list $zpath\/base-102-disk-1", outfunc
=> sub {});
688 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$vmlinked");
690 if ($tmp_volid ne "$storagename:base-101-disk-1") {
694 run_command
("zfs list $zpath\/base-101-disk-1", outfunc
=> sub {});
707 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$ctdisk");
709 if ($tmp_volid ne "$storagename:basevol-202-disk-1") {
713 run_command
("zfs list $zpath\/basevol-202-disk-1", outfunc
=> sub {});
726 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$ctlinked");
728 if ($tmp_volid ne "$storagename:basevol-201-disk-1") {
732 run_command
("zfs list $zpath\/basevol-201-disk-1", outfunc
=> sub {});
744 $tests->{12} = $test12;
748 print "\nrun test11 \"volume_is_base\"\n";
751 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmdisk", 110);
755 warn "Test11 a: clone_image only works on base images";
759 if ("$storagename:$vmbase\/vm-110-disk-0" ne
760 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmbase", 110, '__base__')){
764 run_command
("zfs list -H -o volsize $zpath\/vm-110-disk-0", outfunc
=> sub {
768 warn "Test11 b not correct volsize" if $line !~ m/$volsize/;
777 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmbase\/$vmlinked", 111);
781 warn "Test11 c: clone_image only works on base images";
785 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctdisk", 110);
789 warn "Test11 d: clone_image only works on base images";
793 if ( "$storagename:$ctbase\/subvol-210-disk-0" ne
794 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctbase", 210, '__base__')){
798 run_command
("zfs list -H -o refquota $zpath\/subvol-210-disk-0", outfunc
=> sub {
802 warn "Test11 e not correct volsize" if $line !~ m/$volsize/;
811 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctbase\/$ctlinked", 211);
815 warn "Test11 f: clone_image only works on base images";
818 $tests->{11} = $test11;
822 print "\nrun test10 \"volume_is_base\"\n";
825 if (1 == volume_is_base
($cfg, "$storagename:$vmdisk")) {
827 warn "Test10 a: is no base";
837 if (0 == volume_is_base
($cfg, "$storagename:$vmbase")) {
839 warn "Test10 b: is base";
849 if (1 == volume_is_base
($cfg, "$storagename:$vmbase\/$vmlinked")) {
851 warn "Test10 c: is no base";
861 if (1 == volume_is_base
($cfg, "$storagename:$ctdisk")) {
863 warn "Test10 d: is no base";
873 if (0 == volume_is_base
($cfg, "$storagename:$ctbase")) {
875 warn "Test10 e: is base";
885 if (1 == volume_is_base
($cfg, "$storagename:$ctbase\/$ctlinked")) {
887 warn "Test10 f: is no base";
896 $tests->{10} = $test10;
900 print "\nrun test9 \"parse_volume_id\"\n";
903 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmdisk");
905 if ($store ne $storagename || $disk ne $vmdisk) {
907 warn "Test9 a: parsing wrong";
917 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmbase");
919 if ($store ne $storagename || $disk ne $vmbase) {
921 warn "Test9 b: parsing wrong";
931 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmbase\/$vmlinked");
933 if ($store ne $storagename || $disk ne "$vmbase\/$vmlinked") {
935 warn "Test9 c: parsing wrong";
945 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctdisk");
947 if ($store ne $storagename || $disk ne $ctdisk) {
949 warn "Test9 d: parsing wrong";
959 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctbase");
961 if ($store ne $storagename || $disk ne $ctbase) {
963 warn "Test9 e: parsing wrong";
973 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctbase\/$ctlinked");
975 if ($store ne $storagename || $disk ne "$ctbase\/$ctlinked") {
977 warn "Test9 f: parsing wrong";
986 $tests->{9} = $test9;
990 print "\nrun test8 \"parse_volname\"\n";
993 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmdisk");
995 if ($vtype ne 'images' || $vmid ne '102' || $name ne $vmdisk ||
996 defined($basename) || defined($basevmid) || $isBase ||
999 warn "Test8 a: parsing wrong";
1009 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmbase");
1011 if ($vtype ne 'images' || $vmid ne '100' || $name ne $vmbase ||
1012 defined($basename) || defined($basevmid) || !$isBase ||
1015 warn "Test8 b: parsing wrong";
1024 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmbase\/$vmlinked");
1026 if ($vtype ne 'images' || $name ne $vmlinked || $vmid ne '101' ||
1027 $basename ne $vmbase || $basevmid ne '100' || $isBase ||
1030 warn "Test8 c: parsing wrong";
1039 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctdisk");
1041 if ($vtype ne 'images' || $vmid ne '202' || $name ne $ctdisk ||
1042 defined($basename) || defined($basevmid) || $isBase ||
1043 $format ne 'subvol') {
1045 warn "Test8 d: parsing wrong";
1055 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctbase");
1056 if ($vtype ne 'images' || $vmid ne '200' || $name ne $ctbase ||
1057 defined($basename) || defined($basevmid) || !$isBase ||
1058 $format ne 'subvol') {
1060 warn "Test8 e: parsing wrong";
1069 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctbase\/$ctlinked");
1071 if ($vtype ne 'images' || $name ne $ctlinked || $vmid ne '201' ||
1072 $basename ne $ctbase || $basevmid ne '200' || $isBase ||
1073 $format ne 'subvol') {
1075 warn "Test8 f: parsing wrong";
1083 $tests->{8} = $test8;
1087 print "\nrun test7 \"volume_rollback\"\n";
1090 my $parse_guid = sub {
1093 if ( $line =~ m/^Disk identifier \(GUID\)\: (.*)$/ ) {
1099 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1100 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1102 my $old_guid = $tmp_guid;
1103 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap1');
1105 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1107 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmdisk", 'snap1');
1109 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1110 if ($old_guid ne $tmp_guid) {
1112 warn "Test7 a: Zvol makes no rollback";
1127 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1128 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1130 my $old_guid = $tmp_guid;
1131 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap1');
1133 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1135 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase", 'snap1');
1137 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1138 if ($old_guid ne $tmp_guid) {
1140 warn "Test7 b: Zvol makes no rollback";
1155 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1156 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1158 my $old_guid = $tmp_guid;
1159 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1161 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1163 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1165 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1166 if ($old_guid ne $tmp_guid) {
1168 warn "Test7 c: Zvol makes no rollback";
1183 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap1');
1185 run_command
("touch \/$zpath\/$ctdisk\/test.txt", outfunc
=> $parse_guid);
1187 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctdisk", 'snap1');
1189 run_command
("ls \/$zpath\/$ctdisk\/test.txt", errofunc
=> sub {});
1207 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap1');
1209 run_command
("touch \/$zpath\/$ctbase\/test.txt", outfunc
=> $parse_guid);
1211 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase", 'snap1');
1213 run_command
("ls \/$zpath\/$ctbase\/test.txt", errofunc
=> sub {});
1231 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1233 run_command
("touch \/$zpath\/$ctlinked\/test.txt", outfunc
=> $parse_guid);
1235 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1237 run_command
("ls \/$zpath\/$ctlinked\/test.txt", errofunc
=> sub {});
1255 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap2');
1258 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmdisk", 'snap1');
1262 warn "Test7 h: Not allowed to rollback";
1271 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap2');
1274 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase", 'snap1');
1278 warn "Test7 i: Not allowed to rollback";
1287 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap2');
1290 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1294 warn "Test7 j: Not allowed to rollback";
1303 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap2');
1306 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctdisk", 'snap1');
1310 warn "Test7 k: Not allowed to rollback";
1319 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap2');
1322 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase", 'snap1');
1326 warn "Test7 l: Not allowed to rollback";
1335 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase/$ctlinked", 'snap2');
1338 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1342 warn "Test7 m: Not allowed to rollback";
1350 $tests->{7} = $test7;
1354 print "\nrun test6 \"volume_rollback_is_possible\"\n";
1357 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap1');
1359 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmdisk", 'snap1')) {
1361 warn "Test6 a: Rollback sould possible"
1370 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap1');
1372 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase", 'snap1')) {
1374 warn "Test6 b: Rollback sould possible"
1383 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmlinked", 'snap1');
1385 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1')) {
1387 warn "Test6 c: Rollback sould possible"
1396 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap1');
1398 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctdisk", 'snap1')) {
1400 warn "Test6 d: Rollback sould possible"
1409 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap1');
1411 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase", 'snap1')) {
1413 warn "Test6 e: Rollback sould possible"
1422 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctlinked", 'snap1');
1424 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1')) {
1426 warn "Test6 f: Rollback sould possible"
1435 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap2');
1436 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmdisk", 'snap1');
1440 warn "Test6 g: Rollback should not possible";
1444 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap2');
1445 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase", 'snap1');
1449 warn "Test6 h: Rollback should not possible";
1453 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmlinked", 'snap2');
1454 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1458 warn "Test6 j: Rollback should not possible";
1462 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap2');
1463 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctdisk", 'snap1');
1467 warn "Test6 k: Rollback should not possible";
1471 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap2');
1472 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase", 'snap1');
1476 warn "Test6 l: Rollback should not possible";
1480 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctlinked", 'snap2');
1481 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1');
1485 warn "Test6 m: Rollback should not possible";
1488 $tests->{6} = $test6;
1492 print "\nrun test5 \"volume_snapshot_delete\"\n";
1493 my $out = sub{my $tmp = shift;};
1496 run_command
("zfs snapshot $zpath\/$vmdisk\@snap");
1498 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmdisk", 'snap');
1500 run_command
("zfs list $zpath\/$vmdisk\@snap", errfunc
=> $out, outfunc
=> $out);
1504 warn "Test5 a: snapshot still exists";
1509 warn "Test5 PVE a: $@";
1518 run_command
("zfs snapshot $zpath\/$vmbase\@snap");
1520 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase", 'snap');
1522 run_command
("zfs list $zpath\/$vmbase\@snap", errmsg
=> $out, outfunc
=> $out);
1526 warn "Test5 b: snapshot still exists";
1531 warn "Test5 PVE b: $@";
1540 run_command
("zfs snapshot $zpath\/$vmlinked\@snap");
1542 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap');
1544 run_command
("zfs list $zpath\/$vmlinked\@snap", errmsg
=> $out, outfunc
=> $out);
1548 warn "Test5 c: snapshot still exists";
1553 warn "Test5 PVE c: $@";
1562 run_command
("zfs snapshot $zpath\/$ctdisk\@snap");
1564 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctdisk", 'snap');
1566 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1570 warn "Test5 d: snapshot still exists";
1575 warn "Test5 PVE d: $@";
1584 run_command
("zfs snapshot $zpath\/$ctbase\@snap");
1586 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctbase", 'snap');
1588 run_command
("zfs list $zpath\/$ctbase\@snap", errmsg
=> $out, outfunc
=> $out);
1592 warn "Test5 e: snapshot still exists";
1597 warn "Test5 PVE e: $@";
1606 run_command
("zfs snapshot $zpath\/$ctlinked\@snap");
1608 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap');
1610 run_command
("zfs list $zpath\/$ctlinked\@snap", errmsg
=> $out, outfunc
=> $out);
1614 warn "Test5 f: snapshot still exists";
1619 warn "Test5 PVE f: $@";
1626 print "######Ignore Output if no Test5 g: is included######\n";
1628 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase", '__base__');
1630 run_command
("zfs list $zpath\/$vmbase\@__base__", outfunc
=> $out);
1639 warn "Test5 PVE g: snapshot __base__ can be erased";
1641 print "######End Ignore#######\n";
1643 $tests->{5} = $test5;
1647 print "\nrun test4 \"volume_snapshot\"\n";
1651 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap');
1653 run_command
("zfs list $zpath\/$vmdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1666 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap');
1668 run_command
("zfs list $zpath\/$vmbase\@snap", errmsg
=> $out, outfunc
=> $out);
1681 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap');
1683 run_command
("zfs list $zpath\/$vmdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1696 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap');
1698 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1711 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap');
1713 run_command
("zfs list $zpath\/$ctbase\@snap", errmsg
=> $out, outfunc
=> $out);
1726 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap');
1728 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1740 $tests->{4} = $test4;
1744 print "\nrun test3 \"volume_has_feature\"\n";
1747 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmdisk", undef, 0)) {
1749 warn "Test3 a failed";
1758 if (PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase", undef, 0)) {
1760 warn "Test3 b failed";
1769 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1771 warn "Test3 c failed";
1780 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctdisk", undef, 0)) {
1782 warn "Test3 d failed";
1791 if (PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase", undef, 0)) {
1793 warn "Test3 e failed";
1802 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1804 warn "Test3 f failed";
1813 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmdisk", undef, 0)) {
1815 warn "Test3 g failed";
1824 if (!PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase", undef, 0)) {
1826 warn "Test3 h failed";
1835 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1837 warn "Test3 h failed";
1846 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctdisk", undef, 0)) {
1848 warn "Test3 i failed";
1857 if (!PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase", undef, 0)) {
1859 warn "Test3 j failed";
1868 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1870 warn "Test3 k failed";
1879 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmdisk", undef, 0)) {
1881 warn "Test3 l failed";
1890 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase", undef, 0)) {
1892 warn "Test3 m failed";
1901 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1903 warn "Test3 n failed";
1912 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctdisk", undef, 0)) {
1914 warn "Test3 o failed";
1923 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase", undef, 0)) {
1925 warn "Test3 p failed";
1934 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1936 warn "Test3 q failed";
1945 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmdisk", undef, 0)) {
1947 warn "Test3 r failed";
1956 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase", undef, 0)) {
1958 warn "Test3 s failed";
1967 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1969 warn "Test3 t failed";
1978 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctdisk", undef, 0)) {
1980 warn "Test3 u failed";
1989 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase", undef, 0)) {
1991 warn "Test3 v failed";
2000 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
2002 warn "Test3 w failed";
2011 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmdisk", undef, 0)) {
2013 warn "Test3 x failed";
2022 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase", undef, 0)) {
2024 warn "Test3 y failed";
2033 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
2035 warn "Test3 z failed";
2044 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctdisk", undef, 0)) {
2046 warn "Test3 A failed";
2055 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase", undef, 0)) {
2057 warn "Test3 B failed";
2066 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
2068 warn "Test3 C failed";
2077 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmdisk", 'test', 0)) {
2079 warn "Test3 a1 failed";
2084 warn "Test3 a1: $@";
2088 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase", 'test', 0)) {
2090 warn "Test3 b1 failed";
2095 warn "Test3 b1: $@";
2099 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2101 warn "Test3 c1 failed";
2106 warn "Test3 c1: $@";
2110 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctdisk", 'test', 0)) {
2112 warn "Test3 d1 failed";
2117 warn "Test3 d1: $@";
2121 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase", 'test', 0)) {
2123 warn "Test3 e1 failed";
2128 warn "Test3 e1: $@";
2132 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2134 warn "Test3 f1 failed";
2139 warn "Test3 f1: $@";
2143 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmdisk", 'test', 0)) {
2145 warn "Test3 g1 failed";
2150 warn "Test3 g1: $@";
2154 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase", 'test', 0)) {
2156 warn "Test3 h1 failed";
2161 warn "Test3 h1: $@";
2165 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2167 warn "Test3 h1 failed";
2172 warn "Test3 h1: $@";
2176 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctdisk", 'test', 0)) {
2178 warn "Test3 i1 failed";
2183 warn "Test3 i1: $@";
2187 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase", 'test', 0)) {
2189 warn "Test3 j1 failed";
2194 warn "Test3 j1: $@";
2198 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2200 warn "Test3 k1 failed";
2205 warn "Test3 k1: $@";
2209 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmdisk", 'test', 0)) {
2211 warn "Test3 l1 failed";
2216 warn "Test3 l1: $@";
2220 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase", 'test', 0)) {
2222 warn "Test3 m1 failed";
2227 warn "Test3 m1: $@";
2231 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2233 warn "Test3 n1 failed";
2238 warn "Test3 n1: $@";
2242 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctdisk", 'test', 0)) {
2244 warn "Test3 o1 failed";
2249 warn "Test3 o1: $@";
2253 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase", 'test', 0)) {
2255 warn "Test3 p1 failed";
2260 warn "Test3 p1: $@";
2264 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2266 warn "Test3 q1 failed";
2271 warn "Test3 q1: $@";
2275 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmdisk", 'test', 0)) {
2277 warn "Test3 r1 failed";
2282 warn "Test3 r1: $@";
2286 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase", 'test', 0)) {
2288 warn "Test3 s1 failed";
2293 warn "Test3 s1: $@";
2297 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2299 warn "Test3 t1 failed";
2304 warn "Test3 t1: $@";
2308 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctdisk", 'test', 0)) {
2310 warn "Test3 u1 failed";
2315 warn "Test3 u1: $@";
2319 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase", 'test', 0)) {
2321 warn "Test3 v1 failed";
2326 warn "Test3 v1: $@";
2330 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2332 warn "Test3 w1 failed";
2337 warn "Test3 w1: $@";
2341 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmdisk", 'test', 0)) {
2343 warn "Test3 x1 failed";
2348 warn "Test3 x1: $@";
2352 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase", 'test', 0)) {
2354 warn "Test3 y1 failed";
2359 warn "Test3 y1: $@";
2363 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2365 warn "Test3 z1 failed";
2370 warn "Test3 z1: $@";
2374 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctdisk", 'test', 0)) {
2376 warn "Test3 A1 failed";
2381 warn "Test3 A1: $@";
2385 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase", 'test', 0)) {
2387 warn "Test3 B1 failed";
2392 warn "Test3 B1: $@";
2396 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2398 warn "Test3 C1 failed";
2403 warn "Test3 C1: $@";
2406 $tests->{3} = $test3;
2410 print "\nrun test2 \"volume_resize\"\n";
2411 my $newsize = ($volsize + 1) * 1024 * 1024 * 1024;
2414 if (($newsize/1024) !=
2415 PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmdisk", $newsize, 0)) {
2417 warn "Test2 a failed";
2420 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmdisk")) {
2422 warn "Test2 a failed";
2431 warn "Test2 b failed" if ($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmbase", $newsize, 0);
2432 warn "Test2 b failed" if $newsize !=
2433 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase");
2441 if (($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmbase\/$vmlinked", $newsize, 0)) {
2443 warn "Test2 c failed";
2446 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2448 warn "Test2 c failed";
2457 if (($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctdisk", $newsize, 0)) {
2459 warn "Test2 d failed";
2462 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctdisk")) {
2464 warn "Test2 d failed"
2473 if (($newsize/1024) !=
2474 PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctbase", $newsize, 0)) {
2476 warn "Test2 e failed";
2479 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase")) {
2481 warn "Test2 e failed";
2490 if (($newsize/1024) !=
2491 PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctbase\/$ctlinked", $newsize, 0)) {
2493 warn "Test2 f failed";
2496 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase\/$ctlinked")) {
2498 warn "Test2 f failed";
2506 $tests->{2} = $test2;
2510 print "\nrun test1 \"volume_size_info\"\n";
2511 my $size = ($volsize * 1024 * 1024 * 1024);
2514 if ($size != PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmdisk")) {
2516 warn "Test1 a failed";
2521 warn "Test1 a : $@";
2525 if ($size != PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase")) {
2527 warn "Test1 b failed";
2533 warn "Test1 b : $@";
2538 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2540 warn "Test1 c failed";
2545 warn "Test1 c : $@";
2550 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctdisk")) {
2552 warn "Test1 d failed";
2557 warn "Test1 d : $@";
2562 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase")) {
2564 warn "Test1 e failed";
2569 warn "Test1 e : $@";
2574 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2576 warn "Test1 f failed"
2581 warn "Test1 f : $@";
2585 $tests->{1} = $test1;
2590 print "create zvol $vmdisk\n" if $verbose;
2591 run_command
("zfs create -V${volsize}G $zpath\/$vmdisk");
2593 print "create zvol $vmbase\n" if $verbose;
2594 run_command
("zfs create -V${volsize}G $zpath\/$vmbase");
2595 run_command
("zfs snapshot $zpath\/$vmbase$basesnap");
2597 print "create linked clone $vmlinked\n" if $verbose;
2598 run_command
("zfs clone $zpath\/$vmbase$basesnap $zpath\/$vmlinked");
2601 print "create subvol $ctdisk\n" if $verbose;
2602 run_command
("zfs create -o refquota=${volsize}G $zpath\/$ctdisk");
2604 print "create subvol $vmbase\n" if $verbose;
2605 run_command
("zfs create -o refquota=${volsize}G $zpath\/$ctbase");
2606 run_command
("zfs snapshot $zpath\/$ctbase$basesnap");
2608 print "create linked clone $vmlinked\n" if $verbose;
2609 run_command
("zfs clone $zpath\/$ctbase$basesnap $zpath\/$ctlinked -o refquota=${volsize}G");
2610 run_command
("udevadm trigger --subsystem-match block");
2611 run_command
("udevadm settle --timeout 10 --exit-if-exists=/dev/zvol/$zpath\/$ctlinked");
2616 print "destroy $pool\/$subvol\n" if $verbose;
2617 eval { run_command
("zfs destroy $zpath -r"); };
2619 print "cleanup failed: $@\nretrying once\n" if $verbose;
2620 eval { run_command
("zfs destroy $zpath -r"); };
2632 run_command
("truncate -s 8G zpool.img");
2639 run_command
("zpool create $subvol $pwd\/zpool.img");
2646 sub clean_up_zpool
{
2649 run_command
("zpool destroy -f $subvol");
2656 sub volume_is_base
{
2657 my ($cfg, $volid) = @_;
2659 my (undef, undef, undef, undef, undef, $isBase, undef) = PVE
::Storage
::parse_volname
($cfg, $volid);
2664 if ($> != 0) { #EUID
2665 warn "not root, skipping zfs tests\n";
2669 eval { run_command
("zpool status"); };
2671 warn "zpool status failed, not running tests: $@\n";
2678 print "Start tests for ZFSPoolPlugin\n";
2690 'order' => {'zfstank99' => 1,}
2695 for (my $i = $start_test; $i <= $end_test; $i++) {
2707 $time = time - $time;
2709 print "Stop tests for ZFSPoolPlugin\n";
2710 print "$count tests failed\n";
2711 print "Time: ${time}s\n";
2713 exit -1 if $count > 0;