]> git.proxmox.com Git - pve-storage.git/blob - PVE/Storage/ZFSPoolPlugin.pm
ZFS: use -p flag and remove zfs_parse_size
[pve-storage.git] / PVE / Storage / ZFSPoolPlugin.pm
1 package PVE::Storage::ZFSPoolPlugin;
2
3 use strict;
4 use warnings;
5 use IO::File;
6 use POSIX;
7 use PVE::Tools qw(run_command);
8 use PVE::Storage::Plugin;
9 use PVE::RPCEnvironment;
10 use Net::IP;
11
12 use base qw(PVE::Storage::Plugin);
13
14 sub type {
15 return 'zfspool';
16 }
17
18 sub plugindata {
19 return {
20 content => [ {images => 1, rootdir => 1}, {images => 1 , rootdir => 1}],
21 format => [ { raw => 1, subvol => 1 } , 'raw' ],
22 };
23 }
24
25 sub properties {
26 return {
27 blocksize => {
28 description => "block size",
29 type => 'string',
30 },
31 sparse => {
32 description => "use sparse volumes",
33 type => 'boolean',
34 },
35 mountpoint => {
36 description => "mount point",
37 type => 'string', format => 'pve-storage-path',
38 },
39 };
40 }
41
42 sub options {
43 return {
44 pool => { fixed => 1 },
45 blocksize => { optional => 1 },
46 sparse => { optional => 1 },
47 nodes => { optional => 1 },
48 disable => { optional => 1 },
49 content => { optional => 1 },
50 bwlimit => { optional => 1 },
51 mountpoint => { optional => 1 },
52 };
53 }
54
55 # static zfs helper methods
56
57 sub zfs_parse_zvol_list {
58 my ($text) = @_;
59
60 my $list = ();
61
62 return $list if !$text;
63
64 my @lines = split /\n/, $text;
65 foreach my $line (@lines) {
66 my ($dataset, $size, $origin, $type, $refquota) = split(/\s+/, $line);
67 next if !($type eq 'volume' || $type eq 'filesystem');
68
69 my $zvol = {};
70 my @parts = split /\//, $dataset;
71 next if scalar(@parts) < 2; # we need pool/name
72 my $name = pop @parts;
73 my $pool = join('/', @parts);
74
75 next unless $name =~ m!^(vm|base|subvol|basevol)-(\d+)-(\S+)$!;
76 $zvol->{owner} = $2;
77
78 $zvol->{pool} = $pool;
79 $zvol->{name} = $name;
80 if ($type eq 'filesystem') {
81 if ($refquota eq 'none') {
82 $zvol->{size} = 0;
83 } else {
84 $zvol->{size} = $refquota + 0;
85 }
86 $zvol->{format} = 'subvol';
87 } else {
88 $zvol->{size} = $size + 0;
89 $zvol->{format} = 'raw';
90 }
91 if ($origin !~ /^-$/) {
92 $zvol->{origin} = $origin;
93 }
94 push @$list, $zvol;
95 }
96
97 return $list;
98 }
99
100 sub parse_volname {
101 my ($class, $volname) = @_;
102
103 if ($volname =~ m/^(((base|basevol)-(\d+)-\S+)\/)?((base|basevol|vm|subvol)-(\d+)-\S+)$/) {
104 my $format = ($6 eq 'subvol' || $6 eq 'basevol') ? 'subvol' : 'raw';
105 my $isBase = ($6 eq 'base' || $6 eq 'basevol');
106 return ('images', $5, $7, $2, $4, $isBase, $format);
107 }
108
109 die "unable to parse zfs volume name '$volname'\n";
110 }
111
112 # virtual zfs methods (subclass can overwrite them)
113
114 sub on_add_hook {
115 my ($class, $storeid, $scfg, %param) = @_;
116
117 my $cfg_mountpoint = $scfg->{mountpoint};
118
119 # ignore failure, pool might currently not be imported
120 my $mountpoint;
121 eval {
122 my $res = $class->zfs_get_properties($scfg, 'mountpoint', $scfg->{pool}, 1);
123 $mountpoint = PVE::Storage::Plugin::verify_path($res, 1) if defined($res);
124 };
125
126 if (defined($cfg_mountpoint)) {
127 if (defined($mountpoint) && !($cfg_mountpoint =~ m|^\Q$mountpoint\E/?$|)) {
128 warn "warning for $storeid - mountpoint: $cfg_mountpoint " .
129 "does not match current mount point: $mountpoint\n";
130 }
131 } else {
132 $scfg->{mountpoint} = $mountpoint;
133 }
134 }
135
136 sub path {
137 my ($class, $scfg, $volname, $storeid, $snapname) = @_;
138
139 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
140
141 my $path = '';
142 my $mountpoint = $scfg->{mountpoint} // "/$scfg->{pool}";
143
144 if ($vtype eq "images") {
145 if ($name =~ m/^subvol-/ || $name =~ m/^basevol-/) {
146 $path = "$mountpoint/$name";
147 } else {
148 $path = "/dev/zvol/$scfg->{pool}/$name";
149 }
150 $path .= "\@$snapname" if defined($snapname);
151 } else {
152 die "$vtype is not allowed in ZFSPool!";
153 }
154
155 return ($path, $vmid, $vtype);
156 }
157
158 sub zfs_request {
159 my ($class, $scfg, $timeout, $method, @params) = @_;
160
161 my $cmd = [];
162
163 if ($method eq 'zpool_list') {
164 push @$cmd, 'zpool', 'list';
165 } elsif ($method eq 'zpool_import') {
166 push @$cmd, 'zpool', 'import';
167 $timeout = 15 if !$timeout || $timeout < 15;
168 } else {
169 push @$cmd, 'zfs', $method;
170 }
171 push @$cmd, @params;
172
173 my $msg = '';
174 my $output = sub { $msg .= "$_[0]\n" };
175
176 $timeout = PVE::RPCEnvironment->is_worker() ? 60*60 : 5 if !$timeout;
177
178 run_command($cmd, errmsg => "zfs error", outfunc => $output, timeout => $timeout);
179
180 return $msg;
181 }
182
183 sub zfs_wait_for_zvol_link {
184 my ($class, $scfg, $volname, $timeout) = @_;
185
186 my $default_timeout = PVE::RPCEnvironment->is_worker() ? 60*5 : 10;
187 $timeout = $default_timeout if !defined($timeout);
188
189 my ($devname, undef, undef) = $class->path($scfg, $volname);
190
191 for (my $i = 1; $i <= $timeout; $i++) {
192 last if -b $devname;
193 die "timeout: no zvol device link for '$volname' found after $timeout sec found.\n"
194 if $i == $timeout;
195
196 sleep(1);
197 }
198 }
199
200 sub alloc_image {
201 my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
202
203 my $volname = $name;
204
205 if ($fmt eq 'raw') {
206
207 die "illegal name '$volname' - should be 'vm-$vmid-*'\n"
208 if $volname && $volname !~ m/^vm-$vmid-/;
209 $volname = $class->find_free_diskname($storeid, $scfg, $vmid, $fmt)
210 if !$volname;
211
212 $class->zfs_create_zvol($scfg, $volname, $size);
213 $class->zfs_wait_for_zvol_link($scfg, $volname);
214
215 } elsif ( $fmt eq 'subvol') {
216
217 die "illegal name '$volname' - should be 'subvol-$vmid-*'\n"
218 if $volname && $volname !~ m/^subvol-$vmid-/;
219 $volname = $class->find_free_diskname($storeid, $scfg, $vmid, $fmt)
220 if !$volname;
221
222 die "illegal name '$volname' - should be 'subvol-$vmid-*'\n"
223 if $volname !~ m/^subvol-$vmid-/;
224
225 $class->zfs_create_subvol($scfg, $volname, $size);
226
227 } else {
228 die "unsupported format '$fmt'";
229 }
230
231 return $volname;
232 }
233
234 sub free_image {
235 my ($class, $storeid, $scfg, $volname, $isBase) = @_;
236
237 my (undef, $name, undef) = $class->parse_volname($volname);
238
239 $class->zfs_delete_zvol($scfg, $name);
240
241 return undef;
242 }
243
244 sub list_images {
245 my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
246
247 $cache->{zfs} = $class->zfs_list_zvol($scfg) if !$cache->{zfs};
248 my $zfspool = $scfg->{pool};
249 my $res = [];
250
251 if (my $dat = $cache->{zfs}->{$zfspool}) {
252
253 foreach my $image (keys %$dat) {
254
255 my $info = $dat->{$image};
256
257 my $volname = $info->{name};
258 my $parent = $info->{parent};
259 my $owner = $info->{vmid};
260
261 if ($parent && $parent =~ m/^(\S+)\@__base__$/) {
262 my ($basename) = ($1);
263 $info->{volid} = "$storeid:$basename/$volname";
264 } else {
265 $info->{volid} = "$storeid:$volname";
266 }
267
268 if ($vollist) {
269 my $found = grep { $_ eq $info->{volid} } @$vollist;
270 next if !$found;
271 } else {
272 next if defined ($vmid) && ($owner ne $vmid);
273 }
274
275 push @$res, $info;
276 }
277 }
278 return $res;
279 }
280
281 sub zfs_get_properties {
282 my ($class, $scfg, $properties, $dataset, $timeout) = @_;
283
284 my $result = $class->zfs_request($scfg, $timeout, 'get', '-o', 'value',
285 '-Hp', $properties, $dataset);
286 my @values = split /\n/, $result;
287 return wantarray ? @values : $values[0];
288 }
289
290 sub zfs_get_pool_stats {
291 my ($class, $scfg) = @_;
292
293 my $available = 0;
294 my $used = 0;
295
296 my @lines = $class->zfs_get_properties($scfg, 'available,used', $scfg->{pool});
297
298 if($lines[0] =~ /^(\d+)$/) {
299 $available = $1;
300 }
301
302 if($lines[1] =~ /^(\d+)$/) {
303 $used = $1;
304 }
305
306 return ($available, $used);
307 }
308
309 sub zfs_create_zvol {
310 my ($class, $scfg, $zvol, $size) = @_;
311
312 # always align size to 1M as workaround until
313 # https://github.com/zfsonlinux/zfs/issues/8541 is solved
314 my $padding = (1024 - $size % 1024) % 1024;
315 $size = $size + $padding;
316
317 my $cmd = ['create'];
318
319 push @$cmd, '-s' if $scfg->{sparse};
320
321 push @$cmd, '-b', $scfg->{blocksize} if $scfg->{blocksize};
322
323 push @$cmd, '-V', "${size}k", "$scfg->{pool}/$zvol";
324
325 $class->zfs_request($scfg, undef, @$cmd);
326 }
327
328 sub zfs_create_subvol {
329 my ($class, $scfg, $volname, $size) = @_;
330
331 my $dataset = "$scfg->{pool}/$volname";
332
333 my $cmd = ['create', '-o', 'acltype=posixacl', '-o', 'xattr=sa',
334 '-o', "refquota=${size}k", $dataset];
335
336 $class->zfs_request($scfg, undef, @$cmd);
337 }
338
339 sub zfs_delete_zvol {
340 my ($class, $scfg, $zvol) = @_;
341
342 my $err;
343
344 for (my $i = 0; $i < 6; $i++) {
345
346 eval { $class->zfs_request($scfg, undef, 'destroy', '-r', "$scfg->{pool}/$zvol"); };
347 if ($err = $@) {
348 if ($err =~ m/^zfs error:(.*): dataset is busy.*/) {
349 sleep(1);
350 } elsif ($err =~ m/^zfs error:.*: dataset does not exist.*$/) {
351 $err = undef;
352 last;
353 } else {
354 die $err;
355 }
356 } else {
357 last;
358 }
359 }
360
361 die $err if $err;
362 }
363
364 sub zfs_list_zvol {
365 my ($class, $scfg) = @_;
366
367 my $text = $class->zfs_request($scfg, 10, 'list', '-o', 'name,volsize,origin,type,refquota', '-t', 'volume,filesystem', '-Hrp');
368 my $zvols = zfs_parse_zvol_list($text);
369 return undef if !$zvols;
370
371 my $list = ();
372 foreach my $zvol (@$zvols) {
373 my $pool = $zvol->{pool};
374 my $name = $zvol->{name};
375 my $parent = $zvol->{origin};
376 if($zvol->{origin} && $zvol->{origin} =~ m/^$scfg->{pool}\/(\S+)$/){
377 $parent = $1;
378 }
379
380 $list->{$pool}->{$name} = {
381 name => $name,
382 size => $zvol->{size},
383 parent => $parent,
384 format => $zvol->{format},
385 vmid => $zvol->{owner},
386 };
387 }
388
389 return $list;
390 }
391
392 sub zfs_get_latest_snapshot {
393 my ($class, $scfg, $volname) = @_;
394
395 my $vname = ($class->parse_volname($volname))[1];
396
397 # abort rollback if snapshot is not the latest
398 my @params = ('-t', 'snapshot', '-o', 'name', '-s', 'creation');
399 my $text = $class->zfs_request($scfg, undef, 'list', @params);
400 my @snapshots = split(/\n/, $text);
401
402 my $recentsnap;
403 foreach (@snapshots) {
404 if (/$scfg->{pool}\/$vname/) {
405 s/^.*@//;
406 $recentsnap = $_;
407 }
408 }
409
410 return $recentsnap;
411 }
412
413 sub status {
414 my ($class, $storeid, $scfg, $cache) = @_;
415
416 my $total = 0;
417 my $free = 0;
418 my $used = 0;
419 my $active = 0;
420
421 eval {
422 ($free, $used) = $class->zfs_get_pool_stats($scfg);
423 $active = 1;
424 $total = $free + $used;
425 };
426 warn $@ if $@;
427
428 return ($total, $free, $used, $active);
429 }
430
431 sub volume_size_info {
432 my ($class, $scfg, $storeid, $volname, $timeout) = @_;
433
434 my (undef, $vname, undef, undef, undef, undef, $format) =
435 $class->parse_volname($volname);
436
437 my $attr = $format eq 'subvol' ? 'refquota' : 'volsize';
438 my $value = $class->zfs_get_properties($scfg, $attr, "$scfg->{pool}/$vname");
439 if ($value =~ /^(\d+)$/) {
440 return $1;
441 }
442
443 die "Could not get zfs volume size\n";
444 }
445
446 sub volume_snapshot {
447 my ($class, $scfg, $storeid, $volname, $snap) = @_;
448
449 my $vname = ($class->parse_volname($volname))[1];
450
451 $class->zfs_request($scfg, undef, 'snapshot', "$scfg->{pool}/$vname\@$snap");
452 }
453
454 sub volume_snapshot_delete {
455 my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
456
457 my $vname = ($class->parse_volname($volname))[1];
458
459 $class->deactivate_volume($storeid, $scfg, $vname, $snap, {});
460 $class->zfs_request($scfg, undef, 'destroy', "$scfg->{pool}/$vname\@$snap");
461 }
462
463 sub volume_snapshot_rollback {
464 my ($class, $scfg, $storeid, $volname, $snap) = @_;
465
466 my $vname = ($class->parse_volname($volname))[1];
467
468 $class->zfs_request($scfg, undef, 'rollback', "$scfg->{pool}/$vname\@$snap");
469 }
470
471 sub volume_rollback_is_possible {
472 my ($class, $scfg, $storeid, $volname, $snap) = @_;
473
474 my $recentsnap = $class->zfs_get_latest_snapshot($scfg, $volname);
475 if ($snap ne $recentsnap) {
476 die "can't rollback, more recent snapshots exist\n";
477 }
478
479 return 1;
480 }
481
482 sub volume_snapshot_list {
483 my ($class, $scfg, $storeid, $volname) = @_;
484
485 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
486
487 my $zpath = "$scfg->{pool}/$name";
488
489 my $snaps = [];
490
491 my $cmd = ['zfs', 'list', '-r', '-H', '-S', 'name', '-t', 'snap', '-o',
492 'name', $zpath];
493
494 my $outfunc = sub {
495 my $line = shift;
496
497 if ($line =~ m/^\Q$zpath\E@(.*)$/) {
498 push @$snaps, $1;
499 }
500 };
501
502 eval { run_command( [$cmd], outfunc => $outfunc , errfunc => sub{}); };
503
504 # return an empty array if dataset does not exist.
505 return $snaps;
506 }
507
508 sub activate_storage {
509 my ($class, $storeid, $scfg, $cache) = @_;
510
511 # Note: $scfg->{pool} can include dataset <pool>/<dataset>
512 my $pool = $scfg->{pool};
513 $pool =~ s!/.*$!!;
514
515 my $pool_imported = sub {
516 my @param = ('-o', 'name', '-H', "$pool");
517 my $res = eval { $class->zfs_request($scfg, undef, 'zpool_list', @param) };
518 if ($@) {
519 warn "$@\n";
520 return undef;
521 }
522 return defined($res) && $res =~ m/$pool/;
523 };
524
525 if (!$pool_imported->()) {
526 # import can only be done if not yet imported!
527 my @param = ('-d', '/dev/disk/by-id/', '-o', 'cachefile=none', "$pool");
528 eval { $class->zfs_request($scfg, undef, 'zpool_import', @param) };
529 if (my $err = $@) {
530 # just could've raced with another import, so recheck if it is imported
531 die "could not activate storage '$storeid', $@\n" if !$pool_imported->();
532 }
533 }
534 return 1;
535 }
536
537 sub deactivate_storage {
538 my ($class, $storeid, $scfg, $cache) = @_;
539 return 1;
540 }
541
542 sub activate_volume {
543 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
544
545 return 1 if defined($snapname);
546
547 my (undef, undef, undef, undef, undef, undef, $format) = $class->parse_volname($volname);
548
549 return 1 if $format ne 'raw';
550
551 $class->zfs_wait_for_zvol_link($scfg, $volname);
552
553 return 1;
554 }
555
556 sub deactivate_volume {
557 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
558 return 1;
559 }
560
561 sub clone_image {
562 my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
563
564 $snap ||= '__base__';
565
566 my ($vtype, $basename, $basevmid, undef, undef, $isBase, $format) =
567 $class->parse_volname($volname);
568
569 die "clone_image only works on base images\n" if !$isBase;
570
571 my $name = $class->find_free_diskname($storeid, $scfg, $vmid, $format);
572
573 if ($format eq 'subvol') {
574 my $size = $class->zfs_request($scfg, undef, 'list', '-H', '-o', 'refquota', "$scfg->{pool}/$basename");
575 chomp($size);
576 $class->zfs_request($scfg, undef, 'clone', "$scfg->{pool}/$basename\@$snap", "$scfg->{pool}/$name", '-o', "refquota=$size");
577 } else {
578 $class->zfs_request($scfg, undef, 'clone', "$scfg->{pool}/$basename\@$snap", "$scfg->{pool}/$name");
579 }
580
581 return "$basename/$name";
582 }
583
584 sub create_base {
585 my ($class, $storeid, $scfg, $volname) = @_;
586
587 my $snap = '__base__';
588
589 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) =
590 $class->parse_volname($volname);
591
592 die "create_base not possible with base image\n" if $isBase;
593
594 my $newname = $name;
595 if ( $format eq 'subvol' ) {
596 $newname =~ s/^subvol-/basevol-/;
597 } else {
598 $newname =~ s/^vm-/base-/;
599 }
600 my $newvolname = $basename ? "$basename/$newname" : "$newname";
601
602 $class->zfs_request($scfg, undef, 'rename', "$scfg->{pool}/$name", "$scfg->{pool}/$newname");
603
604 my $running = undef; #fixme : is create_base always offline ?
605
606 $class->volume_snapshot($scfg, $storeid, $newname, $snap, $running);
607
608 return $newvolname;
609 }
610
611 sub volume_resize {
612 my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
613
614 my $new_size = int($size/1024);
615
616 my (undef, $vname, undef, undef, undef, undef, $format) =
617 $class->parse_volname($volname);
618
619 my $attr = $format eq 'subvol' ? 'refquota' : 'volsize';
620
621 # align size to 1M so we always have a valid multiple of the volume block size
622 if ($format eq 'raw') {
623 my $padding = (1024 - $new_size % 1024) % 1024;
624 $new_size = $new_size + $padding;
625 }
626
627 $class->zfs_request($scfg, undef, 'set', "$attr=${new_size}k", "$scfg->{pool}/$vname");
628
629 return $new_size;
630 }
631
632 sub storage_can_replicate {
633 my ($class, $scfg, $storeid, $format) = @_;
634
635 return 1 if $format eq 'raw' || $format eq 'subvol';
636
637 return 0;
638 }
639
640 sub volume_has_feature {
641 my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
642
643 my $features = {
644 snapshot => { current => 1, snap => 1},
645 clone => { base => 1},
646 template => { current => 1},
647 copy => { base => 1, current => 1},
648 sparseinit => { base => 1, current => 1},
649 replicate => { base => 1, current => 1},
650 };
651
652 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
653 $class->parse_volname($volname);
654
655 my $key = undef;
656
657 if ($snapname) {
658 $key = 'snap';
659 } else {
660 $key = $isBase ? 'base' : 'current';
661 }
662
663 return 1 if $features->{$feature}->{$key};
664
665 return undef;
666 }
667
668 sub volume_export {
669 my ($class, $scfg, $storeid, $fh, $volname, $format, $snapshot, $base_snapshot, $with_snapshots) = @_;
670
671 die "unsupported export stream format for $class: $format\n"
672 if $format ne 'zfs';
673
674 die "$class storage can only export snapshots\n"
675 if !defined($snapshot);
676
677 my $dataset = ($class->parse_volname($volname))[1];
678
679 my $fd = fileno($fh);
680 die "internal error: invalid file handle for volume_export\n"
681 if !defined($fd);
682 $fd = ">&$fd";
683
684 # For zfs we always create a replication stream (-R) which means the remote
685 # side will always delete non-existing source snapshots. This should work
686 # for all our use cases.
687 my $cmd = ['zfs', 'send', '-Rpv'];
688 if (defined($base_snapshot)) {
689 my $arg = $with_snapshots ? '-I' : '-i';
690 push @$cmd, $arg, $base_snapshot;
691 }
692 push @$cmd, '--', "$scfg->{pool}/$dataset\@$snapshot";
693
694 run_command($cmd, output => $fd);
695
696 return;
697 }
698
699 sub volume_export_formats {
700 my ($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots) = @_;
701
702 my @formats = ('zfs');
703 # TODOs:
704 # push @formats, 'fies' if $volname !~ /^(?:basevol|subvol)-/;
705 # push @formats, 'raw' if !$base_snapshot && !$with_snapshots;
706 return @formats;
707 }
708
709 sub volume_import {
710 my ($class, $scfg, $storeid, $fh, $volname, $format, $base_snapshot, $with_snapshots, $allow_rename) = @_;
711
712 die "unsupported import stream format for $class: $format\n"
713 if $format ne 'zfs';
714
715 my $fd = fileno($fh);
716 die "internal error: invalid file handle for volume_import\n"
717 if !defined($fd);
718
719 my (undef, $dataset, $vmid) = $class->parse_volname($volname);
720 my $zfspath = "$scfg->{pool}/$dataset";
721 my $suffix = defined($base_snapshot) ? "\@$base_snapshot" : '';
722 my $exists = 0 == run_command(['zfs', 'get', '-H', 'name', $zfspath.$suffix],
723 noerr => 1, errfunc => sub {});
724 if (defined($base_snapshot)) {
725 die "base snapshot '$zfspath\@$base_snapshot' doesn't exist\n" if !$exists;
726 } elsif ($exists) {
727 die "volume '$zfspath' already exists\n" if !$allow_rename;
728 warn "volume '$zfspath' already exists - importing with a different name\n";
729 $dataset = $class->find_free_diskname($storeid, $scfg, $vmid, $format);
730 $zfspath = "$scfg->{pool}/$dataset";
731 }
732
733 eval { run_command(['zfs', 'recv', '-F', '--', $zfspath], input => "<&$fd") };
734 if (my $err = $@) {
735 if (defined($base_snapshot)) {
736 eval { run_command(['zfs', 'rollback', '-r', '--', "$zfspath\@$base_snapshot"]) };
737 } else {
738 eval { run_command(['zfs', 'destroy', '-r', '--', $zfspath]) };
739 }
740 die $err;
741 }
742
743 return "$storeid:$dataset";
744 }
745
746 sub volume_import_formats {
747 my ($class, $scfg, $storeid, $volname, $base_snapshot, $with_snapshots) = @_;
748
749 return $class->volume_export_formats($scfg, $storeid, $volname, undef, $base_snapshot, $with_snapshots);
750 }
751
752 1;