Aliased volumes (referencing the same disk image multiple times) can
lead to unexpected behavior in a migration.

Therefore, stop the migration in such a case.

The check works by comparing the path returned by the storage plugin.
This means that we should be able to catch the common situations where
it can happen:

* by referencing the same volid multiple times
* having a different volid due to an aliased storage: different storage
name but pointing to the same location.

We decided against checking the storages themselves being aliased. It is
not possible to infer that reliably from just the storage configuration
options alone.

Signed-off-by: Aaron Lauterer <a.laute...@proxmox.com>
---
 PVE/QemuMigrate.pm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 1d21250..c0fdbce 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -294,12 +294,12 @@ sub scan_local_volumes {
 
     my $storecfg = $self->{storecfg};
     eval {
-
        # found local volumes and their origin
        my $local_volumes = $self->{local_volumes};
        my $local_volumes_errors = {};
        my $other_errors = [];
        my $abort = 0;
+       my $path_to_volid = {};
 
        my $log_error = sub {
            my ($msg, $volid) = @_;
@@ -397,6 +397,8 @@ sub scan_local_volumes {
            die "owned by other VM (owner = VM $owner)\n"
                if !$owner || ($owner != $vmid);
 
+           $path_to_volid->{$path}->{$volid} = 1;
+
            return if $attr->{is_vmstate};
 
            if (defined($snaprefs)) {
@@ -443,6 +445,12 @@ sub scan_local_volumes {
            }
         });
 
+       for my $path (keys %$path_to_volid) {
+           my @volids = keys %{$path_to_volid->{$path}};
+           die "detected not supported aliased volumes: '" . join("', '", 
@volids) . "'"
+               if (scalar @volids > 1);
+       }
+
        foreach my $vol (sort keys %$local_volumes) {
            my $type = $replicatable_volumes->{$vol} ? 'local, replicated' : 
'local';
            my $ref = $local_volumes->{$vol}->{ref};
-- 
2.30.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to