]> git.proxmox.com Git - qemu-server.git/commitdiff
migrate: use correct target storage id for checks
authorFabian Ebner <f.ebner@proxmox.com>
Fri, 25 Jun 2021 12:32:05 +0000 (14:32 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 22 Sep 2021 06:57:35 +0000 (08:57 +0200)
The '--targetstorage' parameter does not apply to shared storages.

Example for a problem solved with the enabled check: Given a VM with
images only on a shared storage 'storeA', not available on the target
node (i.e. restricted by the nodes property). Then using
'--targetstorage storeB' would make offline migration suddenly
"work", but of course the disks would not be accessible and then
trying to migrate back would fail...

Example for a problem solved with the content type check: if a
VM had a shared ISO image, and there was a '--targetstorage storeA'
option, availablity of the 'iso' content type is checked for
'storeA', which is wrong as the ISO would not be moved to that
storage.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/QemuMigrate.pm

index 5ecc2a7179d1680bbb49cda6d43dded737749018..b7812ddc0387797e911b8dace4be6ff45a4a82c3 100644 (file)
@@ -337,9 +337,15 @@ sub prepare {
        my ($sid, $volname) = PVE::Storage::parse_volume_id($volid, 1);
 
        # check if storage is available on both nodes
-       my $targetsid = PVE::QemuServer::map_storage($self->{opts}->{storagemap}, $sid);
-
        my $scfg = PVE::Storage::storage_check_enabled($storecfg, $sid);
+
+       my $targetsid;
+       if ($scfg->{shared}) {
+           $targetsid = $sid;
+       } else {
+           $targetsid = PVE::QemuServer::map_storage($self->{opts}->{storagemap}, $sid);
+       }
+
        my $target_scfg = PVE::Storage::storage_check_enabled(
            $storecfg,
            $targetsid,
@@ -472,9 +478,16 @@ sub scan_local_volumes {
 
            my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
 
-           my $targetsid = PVE::QemuServer::map_storage($self->{opts}->{storagemap}, $sid);
            # check if storage is available on both nodes
            my $scfg = PVE::Storage::storage_check_enabled($storecfg, $sid);
+
+           my $targetsid;
+           if ($scfg->{shared}) {
+               $targetsid = $sid;
+           } else {
+               $targetsid = PVE::QemuServer::map_storage($self->{opts}->{storagemap}, $sid);
+           }
+
            PVE::Storage::storage_check_enabled($storecfg, $targetsid, $self->{node});
 
            return if $scfg->{shared};