[pve-devel] [RFC storage 8/16] storage_migrate: use only storeid when no volume name is specified
Fabian Ebner
f.ebner at proxmox.com
Wed Jan 29 14:30:06 CET 2020
so the migration code doesn't need to know how the volid on
the targetstorage would look like (e.g. VM has disk
mydir:123/vm-123-disk-0.raw and targetstorage is an LVM).
Previously it would fail, because the current volname was
passed to 'pvesm import' which is an invalid name for an LVM storage.
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
PVE/Storage.pm | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index d708c03..6aea2ef 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -561,7 +561,6 @@ sub storage_migrate {
my ($cfg, $volid, $target_sshinfo, $target_storeid, $target_volname, $base_snapshot, $snapshot, $ratelimit_bps, $insecure, $with_snapshots, $logfunc) = @_;
my ($storeid, $volname) = parse_volume_id($volid);
- $target_volname = $volname if !$target_volname;
my $scfg = storage_config($cfg, $storeid);
@@ -570,7 +569,7 @@ sub storage_migrate {
my $tcfg = storage_config($cfg, $target_storeid);
- my $target_volid = "${target_storeid}:${target_volname}";
+ my $target_volid_or_storeid = defined($target_volname) ? "${target_storeid}:${target_volname}" : "$target_storeid";
my $target_ip = $target_sshinfo->{ip};
@@ -601,7 +600,7 @@ sub storage_migrate {
$with_snapshots = $with_snapshots ? 1 : 0; # sanitize for passing as cli parameter
my $send = ['pvesm', 'export', $volid, $format, '-', '-with-snapshots', $with_snapshots];
- my $recv = [@$ssh, '--', 'pvesm', 'import', $target_volid, $format, $import_fn, '-with-snapshots', $with_snapshots];
+ my $recv = [@$ssh, '--', 'pvesm', 'import', $target_volid_or_storeid, $format, $import_fn, '-with-snapshots', $with_snapshots];
if (defined($snapshot)) {
push @$send, '-snapshot', $snapshot
}
@@ -609,6 +608,11 @@ sub storage_migrate {
push @$recv, '-delete-snapshot', $snapshot;
}
+ my $vmid = (parse_volname($cfg, $volid))[2];
+ if (!defined($target_volname)) {
+ push @$recv, '-vmid', $vmid;
+ }
+
if (defined($base_snapshot)) {
# Check if the snapshot exists on the remote side:
push @$send, '-base', $base_snapshot;
--
2.20.1
More information about the pve-devel
mailing list