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 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmdisk"]);
1100 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1101 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1103 my $old_guid = $tmp_guid;
1104 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap1');
1106 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1108 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmdisk", 'snap1');
1109 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmdisk"]);
1111 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
1112 if ($old_guid ne $tmp_guid) {
1114 warn "Test7 a: Zvol makes no rollback";
1129 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmbase"]);
1130 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1131 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1133 my $old_guid = $tmp_guid;
1134 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap1');
1136 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1138 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase", 'snap1');
1139 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmbase"]);
1141 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
1142 if ($old_guid ne $tmp_guid) {
1144 warn "Test7 b: Zvol makes no rollback";
1159 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmbase/$vmlinked"]);
1160 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1161 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1163 my $old_guid = $tmp_guid;
1164 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1166 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1168 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1169 PVE
::Storage
::activate_volumes
($cfg, ["$storagename:$vmbase/$vmlinked"]);
1171 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
1172 if ($old_guid ne $tmp_guid) {
1174 warn "Test7 c: Zvol makes no rollback";
1189 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap1');
1191 run_command
("touch \/$zpath\/$ctdisk\/test.txt", outfunc
=> $parse_guid);
1193 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctdisk", 'snap1');
1195 run_command
("ls \/$zpath\/$ctdisk\/test.txt", errofunc
=> sub {});
1213 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap1');
1215 run_command
("touch \/$zpath\/$ctbase\/test.txt", outfunc
=> $parse_guid);
1217 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase", 'snap1');
1219 run_command
("ls \/$zpath\/$ctbase\/test.txt", errofunc
=> sub {});
1237 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1239 run_command
("touch \/$zpath\/$ctlinked\/test.txt", outfunc
=> $parse_guid);
1241 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1243 run_command
("ls \/$zpath\/$ctlinked\/test.txt", errofunc
=> sub {});
1261 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap2');
1264 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmdisk", 'snap1');
1268 warn "Test7 h: Not allowed to rollback";
1277 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap2');
1280 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase", 'snap1');
1284 warn "Test7 i: Not allowed to rollback";
1293 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap2');
1296 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1300 warn "Test7 j: Not allowed to rollback";
1309 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap2');
1312 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctdisk", 'snap1');
1316 warn "Test7 k: Not allowed to rollback";
1325 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap2');
1328 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase", 'snap1');
1332 warn "Test7 l: Not allowed to rollback";
1341 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase/$ctlinked", 'snap2');
1344 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1348 warn "Test7 m: Not allowed to rollback";
1356 $tests->{7} = $test7;
1360 print "\nrun test6 \"volume_rollback_is_possible\"\n";
1363 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap1');
1365 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmdisk", 'snap1')) {
1367 warn "Test6 a: Rollback sould possible"
1376 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap1');
1378 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase", 'snap1')) {
1380 warn "Test6 b: Rollback sould possible"
1389 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmlinked", 'snap1');
1391 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1')) {
1393 warn "Test6 c: Rollback sould possible"
1402 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap1');
1404 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctdisk", 'snap1')) {
1406 warn "Test6 d: Rollback sould possible"
1415 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap1');
1417 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase", 'snap1')) {
1419 warn "Test6 e: Rollback sould possible"
1428 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctlinked", 'snap1');
1430 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1')) {
1432 warn "Test6 f: Rollback sould possible"
1441 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap2');
1442 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmdisk", 'snap1');
1446 warn "Test6 g: Rollback should not possible";
1450 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap2');
1451 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase", 'snap1');
1455 warn "Test6 h: Rollback should not possible";
1459 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmlinked", 'snap2');
1460 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1464 warn "Test6 j: Rollback should not possible";
1468 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap2');
1469 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctdisk", 'snap1');
1473 warn "Test6 k: Rollback should not possible";
1477 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap2');
1478 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase", 'snap1');
1482 warn "Test6 l: Rollback should not possible";
1486 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctlinked", 'snap2');
1487 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1');
1491 warn "Test6 m: Rollback should not possible";
1494 $tests->{6} = $test6;
1498 print "\nrun test5 \"volume_snapshot_delete\"\n";
1499 my $out = sub{my $tmp = shift;};
1502 run_command
("zfs snapshot $zpath\/$vmdisk\@snap");
1504 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmdisk", 'snap');
1506 run_command
("zfs list $zpath\/$vmdisk\@snap", errfunc
=> $out, outfunc
=> $out);
1510 warn "Test5 a: snapshot still exists";
1515 warn "Test5 PVE a: $@";
1524 run_command
("zfs snapshot $zpath\/$vmbase\@snap");
1526 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase", 'snap');
1528 run_command
("zfs list $zpath\/$vmbase\@snap", errmsg
=> $out, outfunc
=> $out);
1532 warn "Test5 b: snapshot still exists";
1537 warn "Test5 PVE b: $@";
1546 run_command
("zfs snapshot $zpath\/$vmlinked\@snap");
1548 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap');
1550 run_command
("zfs list $zpath\/$vmlinked\@snap", errmsg
=> $out, outfunc
=> $out);
1554 warn "Test5 c: snapshot still exists";
1559 warn "Test5 PVE c: $@";
1568 run_command
("zfs snapshot $zpath\/$ctdisk\@snap");
1570 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctdisk", 'snap');
1572 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1576 warn "Test5 d: snapshot still exists";
1581 warn "Test5 PVE d: $@";
1590 run_command
("zfs snapshot $zpath\/$ctbase\@snap");
1592 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctbase", 'snap');
1594 run_command
("zfs list $zpath\/$ctbase\@snap", errmsg
=> $out, outfunc
=> $out);
1598 warn "Test5 e: snapshot still exists";
1603 warn "Test5 PVE e: $@";
1612 run_command
("zfs snapshot $zpath\/$ctlinked\@snap");
1614 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap');
1616 run_command
("zfs list $zpath\/$ctlinked\@snap", errmsg
=> $out, outfunc
=> $out);
1620 warn "Test5 f: snapshot still exists";
1625 warn "Test5 PVE f: $@";
1632 print "######Ignore Output if no Test5 g: is included######\n";
1634 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase", '__base__');
1636 run_command
("zfs list $zpath\/$vmbase\@__base__", outfunc
=> $out);
1645 warn "Test5 PVE g: snapshot __base__ can be erased";
1647 print "######End Ignore#######\n";
1649 $tests->{5} = $test5;
1653 print "\nrun test4 \"volume_snapshot\"\n";
1657 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap');
1659 run_command
("zfs list $zpath\/$vmdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1672 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap');
1674 run_command
("zfs list $zpath\/$vmbase\@snap", errmsg
=> $out, outfunc
=> $out);
1687 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap');
1689 run_command
("zfs list $zpath\/$vmdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1702 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap');
1704 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1717 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap');
1719 run_command
("zfs list $zpath\/$ctbase\@snap", errmsg
=> $out, outfunc
=> $out);
1732 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap');
1734 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1746 $tests->{4} = $test4;
1750 print "\nrun test3 \"volume_has_feature\"\n";
1753 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmdisk", undef, 0)) {
1755 warn "Test3 a failed";
1764 if (PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase", undef, 0)) {
1766 warn "Test3 b failed";
1775 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1777 warn "Test3 c failed";
1786 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctdisk", undef, 0)) {
1788 warn "Test3 d failed";
1797 if (PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase", undef, 0)) {
1799 warn "Test3 e failed";
1808 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1810 warn "Test3 f failed";
1819 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmdisk", undef, 0)) {
1821 warn "Test3 g failed";
1830 if (!PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase", undef, 0)) {
1832 warn "Test3 h failed";
1841 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1843 warn "Test3 h failed";
1852 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctdisk", undef, 0)) {
1854 warn "Test3 i failed";
1863 if (!PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase", undef, 0)) {
1865 warn "Test3 j failed";
1874 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1876 warn "Test3 k failed";
1885 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmdisk", undef, 0)) {
1887 warn "Test3 l failed";
1896 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase", undef, 0)) {
1898 warn "Test3 m failed";
1907 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1909 warn "Test3 n failed";
1918 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctdisk", undef, 0)) {
1920 warn "Test3 o failed";
1929 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase", undef, 0)) {
1931 warn "Test3 p failed";
1940 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1942 warn "Test3 q failed";
1951 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmdisk", undef, 0)) {
1953 warn "Test3 r failed";
1962 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase", undef, 0)) {
1964 warn "Test3 s failed";
1973 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1975 warn "Test3 t failed";
1984 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctdisk", undef, 0)) {
1986 warn "Test3 u failed";
1995 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase", undef, 0)) {
1997 warn "Test3 v failed";
2006 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
2008 warn "Test3 w failed";
2017 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmdisk", undef, 0)) {
2019 warn "Test3 x failed";
2028 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase", undef, 0)) {
2030 warn "Test3 y failed";
2039 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
2041 warn "Test3 z failed";
2050 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctdisk", undef, 0)) {
2052 warn "Test3 A failed";
2061 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase", undef, 0)) {
2063 warn "Test3 B failed";
2072 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
2074 warn "Test3 C failed";
2083 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmdisk", 'test', 0)) {
2085 warn "Test3 a1 failed";
2090 warn "Test3 a1: $@";
2094 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase", 'test', 0)) {
2096 warn "Test3 b1 failed";
2101 warn "Test3 b1: $@";
2105 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2107 warn "Test3 c1 failed";
2112 warn "Test3 c1: $@";
2116 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctdisk", 'test', 0)) {
2118 warn "Test3 d1 failed";
2123 warn "Test3 d1: $@";
2127 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase", 'test', 0)) {
2129 warn "Test3 e1 failed";
2134 warn "Test3 e1: $@";
2138 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2140 warn "Test3 f1 failed";
2145 warn "Test3 f1: $@";
2149 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmdisk", 'test', 0)) {
2151 warn "Test3 g1 failed";
2156 warn "Test3 g1: $@";
2160 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase", 'test', 0)) {
2162 warn "Test3 h1 failed";
2167 warn "Test3 h1: $@";
2171 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2173 warn "Test3 h1 failed";
2178 warn "Test3 h1: $@";
2182 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctdisk", 'test', 0)) {
2184 warn "Test3 i1 failed";
2189 warn "Test3 i1: $@";
2193 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase", 'test', 0)) {
2195 warn "Test3 j1 failed";
2200 warn "Test3 j1: $@";
2204 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2206 warn "Test3 k1 failed";
2211 warn "Test3 k1: $@";
2215 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmdisk", 'test', 0)) {
2217 warn "Test3 l1 failed";
2222 warn "Test3 l1: $@";
2226 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase", 'test', 0)) {
2228 warn "Test3 m1 failed";
2233 warn "Test3 m1: $@";
2237 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2239 warn "Test3 n1 failed";
2244 warn "Test3 n1: $@";
2248 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctdisk", 'test', 0)) {
2250 warn "Test3 o1 failed";
2255 warn "Test3 o1: $@";
2259 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase", 'test', 0)) {
2261 warn "Test3 p1 failed";
2266 warn "Test3 p1: $@";
2270 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2272 warn "Test3 q1 failed";
2277 warn "Test3 q1: $@";
2281 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmdisk", 'test', 0)) {
2283 warn "Test3 r1 failed";
2288 warn "Test3 r1: $@";
2292 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase", 'test', 0)) {
2294 warn "Test3 s1 failed";
2299 warn "Test3 s1: $@";
2303 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2305 warn "Test3 t1 failed";
2310 warn "Test3 t1: $@";
2314 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctdisk", 'test', 0)) {
2316 warn "Test3 u1 failed";
2321 warn "Test3 u1: $@";
2325 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase", 'test', 0)) {
2327 warn "Test3 v1 failed";
2332 warn "Test3 v1: $@";
2336 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2338 warn "Test3 w1 failed";
2343 warn "Test3 w1: $@";
2347 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmdisk", 'test', 0)) {
2349 warn "Test3 x1 failed";
2354 warn "Test3 x1: $@";
2358 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase", 'test', 0)) {
2360 warn "Test3 y1 failed";
2365 warn "Test3 y1: $@";
2369 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2371 warn "Test3 z1 failed";
2376 warn "Test3 z1: $@";
2380 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctdisk", 'test', 0)) {
2382 warn "Test3 A1 failed";
2387 warn "Test3 A1: $@";
2391 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase", 'test', 0)) {
2393 warn "Test3 B1 failed";
2398 warn "Test3 B1: $@";
2402 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2404 warn "Test3 C1 failed";
2409 warn "Test3 C1: $@";
2412 $tests->{3} = $test3;
2416 print "\nrun test2 \"volume_resize\"\n";
2417 my $newsize = ($volsize + 1) * 1024 * 1024 * 1024;
2420 if (($newsize/1024) !=
2421 PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmdisk", $newsize, 0)) {
2423 warn "Test2 a failed";
2426 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmdisk")) {
2428 warn "Test2 a failed";
2437 warn "Test2 b failed" if ($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmbase", $newsize, 0);
2438 warn "Test2 b failed" if $newsize !=
2439 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase");
2447 if (($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmbase\/$vmlinked", $newsize, 0)) {
2449 warn "Test2 c failed";
2452 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2454 warn "Test2 c failed";
2463 if (($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctdisk", $newsize, 0)) {
2465 warn "Test2 d failed";
2468 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctdisk")) {
2470 warn "Test2 d failed"
2479 if (($newsize/1024) !=
2480 PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctbase", $newsize, 0)) {
2482 warn "Test2 e failed";
2485 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase")) {
2487 warn "Test2 e failed";
2496 if (($newsize/1024) !=
2497 PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctbase\/$ctlinked", $newsize, 0)) {
2499 warn "Test2 f failed";
2502 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase\/$ctlinked")) {
2504 warn "Test2 f failed";
2512 $tests->{2} = $test2;
2516 print "\nrun test1 \"volume_size_info\"\n";
2517 my $size = ($volsize * 1024 * 1024 * 1024);
2520 if ($size != PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmdisk")) {
2522 warn "Test1 a failed";
2527 warn "Test1 a : $@";
2531 if ($size != PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase")) {
2533 warn "Test1 b failed";
2539 warn "Test1 b : $@";
2544 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2546 warn "Test1 c failed";
2551 warn "Test1 c : $@";
2556 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctdisk")) {
2558 warn "Test1 d failed";
2563 warn "Test1 d : $@";
2568 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase")) {
2570 warn "Test1 e failed";
2575 warn "Test1 e : $@";
2580 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2582 warn "Test1 f failed"
2587 warn "Test1 f : $@";
2591 $tests->{1} = $test1;
2595 print "create zvol $vmdisk\n" if $verbose;
2596 run_command
("zfs create -V${volsize}G $zpath\/$vmdisk");
2598 print "create zvol $vmbase\n" if $verbose;
2599 run_command
("zfs create -V${volsize}G $zpath\/$vmbase");
2600 run_command
("zfs snapshot $zpath\/$vmbase$basesnap");
2602 print "create linked clone $vmlinked\n" if $verbose;
2603 run_command
("zfs clone $zpath\/$vmbase$basesnap $zpath\/$vmlinked");
2606 print "create subvol $ctdisk\n" if $verbose;
2607 run_command
("zfs create -o refquota=${volsize}G $zpath\/$ctdisk");
2609 print "create subvol $ctbase\n" if $verbose;
2610 run_command
("zfs create -o refquota=${volsize}G $zpath\/$ctbase");
2611 run_command
("zfs snapshot $zpath\/$ctbase$basesnap");
2613 print "create linked clone $ctlinked\n" if $verbose;
2614 run_command
("zfs clone $zpath\/$ctbase$basesnap $zpath\/$ctlinked -o refquota=${volsize}G");
2617 "$storagename:$vmdisk",
2618 "$storagename:$vmbase",
2619 "$storagename:$vmbase/$vmlinked",
2620 "$storagename:$ctdisk",
2621 "$storagename:$ctbase",
2622 "$storagename:$ctbase/$ctlinked",
2625 PVE
::Storage
::activate_volumes
($cfg, $vollist);
2630 print "destroy $pool\/$subvol\n" if $verbose;
2631 eval { run_command
("zfs destroy $zpath -r"); };
2633 print "cleanup failed: $@\nretrying once\n" if $verbose;
2634 eval { run_command
("zfs destroy $zpath -r"); };
2646 run_command
("truncate -s 8G zpool.img");
2653 run_command
("zpool create $subvol $pwd\/zpool.img");
2660 sub clean_up_zpool
{
2663 run_command
("zpool destroy -f $subvol");
2670 sub volume_is_base
{
2671 my ($cfg, $volid) = @_;
2673 my (undef, undef, undef, undef, undef, $isBase, undef) = PVE
::Storage
::parse_volname
($cfg, $volid);
2678 if ($> != 0) { #EUID
2679 warn "not root, skipping zfs tests\n";
2683 eval { run_command
("zpool status"); };
2685 warn "zpool status failed, not running tests: $@\n";
2692 print "Start tests for ZFSPoolPlugin\n";
2704 'order' => {'zfstank99' => 1,}
2709 for (my $i = $start_test; $i <= $end_test; $i++) {
2721 $time = time - $time;
2723 print "Stop tests for ZFSPoolPlugin\n";
2724 print "$count tests failed\n";
2725 print "Time: ${time}s\n";
2727 exit -1 if $count > 0;