[pve-devel] [PATCH v2 storage 6/6] migrate: query transfer stream formats
Wolfgang Bumiller
w.bumiller at proxmox.com
Thu May 11 10:24:13 CEST 2017
---
This removes the last zfs specific portion of this code path. If the
other storage types get their formats added (they should at least
support 'raw', and if they support subvolumes, maybe 'tar'?) this code
path in storage_migrate() should replace all the other cases of this
function.
Note: this currently moves the volume_snapshot() further up - but I'm
not sure we need that. This basically allows volume_transfer_formats()
to check the actually existing snapshot by name, but I think that
parameter can mostly be treated as a boolean for whether to use one...
PVE/Storage.pm | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 4c8b9d1..2f5904e 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -625,25 +625,28 @@ sub storage_migrate {
my (undef, $volname) = parse_volname($cfg, $volid);
my $zfspath = "$scfg->{pool}\/$volname";
- 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 $cleanup_target = ['ssh', "root\@$target_host", '--', 'pvesm', 'delsnapshot', $volid, '__migration__'];
-
- if (defined($base_snapshot)) {
- # Check if the snapshot exists on the remote side:
- push @$send, '-snapshot', $base_snapshot;
- push @$recv, '-base', $base_snapshot;
- }
-
volume_snapshot($cfg, $volid, '__migration__');
- eval{
+ eval {
+ my @formats = volume_transfer_formats($cfg, $volid, '__migration__', $base_snapshot, 1);
+ die "cannot migrate from storage tye '$scfg->{type}' to '$tcfg->{type}'\n" if !@formats;
+ my $format = $formats[0];
+
+ my $send = ['pvesm', 'export', $volid, $format, '-', '-snapshot', '__migration__', '-with-snapshots', '1'];
+ my $recv = ['ssh', "root\@$target_host", '--', 'pvesm', 'import', $volid, $format, '-', '-with-snapshots', '1'];
+
+ if (defined($base_snapshot)) {
+ # Check if the snapshot exists on the remote side:
+ push @$send, '-snapshot', $base_snapshot;
+ push @$recv, '-base', $base_snapshot;
+ }
+
run_command([$send, $recv]);
};
my $err = $@;
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($cleanup_target); };
+ eval { run_command(['ssh', "root\@$target_host", '--', 'pvesm', 'delsnapshot', $volid, '__migration__']) };
warn "could not remove target snapshot: $@\n" if $@;
die $err if $err;
} else {
--
2.11.0
More information about the pve-devel
mailing list