[pve-devel] [PATCH] add possibility check at migration

Wolfgang Link w.link at proxmox.com
Fri Mar 18 09:06:46 CET 2016


Now we check before we migrate, if a storage is a licked clone.
If this is true we check also if it is on a shared storage because outer way it would not possible to migrate.
---
 PVE/QemuMigrate.pm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 6c734ca..03259a1 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -125,6 +125,30 @@ sub lock_vm {
     return PVE::QemuConfig->lock_config($vmid, $code, @param);
 }
 
+my $has_local_disk_parent = sub {
+    my ($conf, $scfg) = @_;
+
+    my $ret = 0;
+    
+    PVE::QemuServer::foreach_drive($conf, sub {
+	my ($ds, $drive) = @_;
+
+	return if PVE::QemuServer::drive_is_cdrom($drive);
+
+	my $volid = $drive->{file};
+
+	return if !$volid || $volid =~ m|^/|;
+
+	my ($sid) = PVE::Storage::parse_volume_id($volid);
+
+	return if $scfg->{ids}->{$sid}->{shared};
+
+	$ret = 1 if (PVE::Storage::parse_volname($scfg ,$volid))[3];
+    });
+
+    return $ret;
+};
+
 sub prepare {
     my ($self, $vmid) = @_;
 
@@ -160,6 +184,9 @@ sub prepare {
 
     # fixme: check if storage is available on both nodes
 
+    die "Can't migrate linked clones\n"
+	if &$has_local_disk_parent($conf, $self->{storecfg});
+
     # test ssh connection
     my $cmd = [ @{$self->{rem_ssh}}, '/bin/true' ];
     eval { $self->cmd_quiet($cmd); };
-- 
2.1.4





More information about the pve-devel mailing list