[pve-devel] [PATCH v4 storage 3/6] migrate: use pvesm import/export for zfs
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri May 12 11:56:08 CEST 2017
The only leftover zfs specific part here is the zfs format
type parameter.
---
PVE/Storage.pm | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 7046a8e..56e7a13 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -616,27 +616,23 @@ sub storage_migrate {
if $tcfg->{pool} ne $scfg->{pool};
my (undef, $volname) = parse_volname($cfg, $volid);
-
my $zfspath = "$scfg->{pool}\/$volname";
- my $snap = ['zfs', 'snapshot', "$zfspath\@__migration__"];
-
- my $send = [['zfs', 'send', '-Rpv', "$zfspath\@__migration__"], ['ssh', "root\@$target_host",
- 'zfs', 'recv', $zfspath]];
+ my $send = ['pvesm', 'export', $volid, 'zfs', '-', '-snapshot', '__migration__', '-with-snapshots', '1'];
+ my $recv = ['ssh', "root\@$target_host", '--', 'pvesm', 'import', $volid, 'zfs', '-', '-with-snapshots', '1'];
+ my $free = ['ssh', "root\@$target_host", '--', 'pvesm', 'free', $volid, '-snapshot', '__migration__'];
- my $destroy_target = ['ssh', "root\@$target_host", 'zfs', 'destroy', "$zfspath\@__migration__"];
- run_command($snap);
+ volume_snapshot($cfg, $volid, '__migration__');
eval{
- run_command($send);
+ run_command([$send, $recv]);
};
my $err = $@;
- warn "zfs send/receive failed, cleaning up snapshot(s)..\n" if $err;
- eval { run_command(['zfs', 'destroy', "$zfspath\@__migration__"]); };
+ warn "send/receive failed, cleaning up snapshot(s)..\n" if $err;
+ eval { volume_snapshot_delete($cfg, $volid, '__migration__', 0) };
warn "could not remove source snapshot: $@\n" if $@;
- eval { run_command($destroy_target); };
+ eval { run_command($free) };
warn "could not remove target snapshot: $@\n" if $@;
die $err if $err;
-
} else {
die "$errstr - target type $tcfg->{type} is not valid\n";
}
--
2.11.0
More information about the pve-devel
mailing list