[pve-devel] [PATCH pve-storage] Add LVM-thin storage migration

Wolfgang Link w.link at proxmox.com
Tue Jun 7 09:10:07 CEST 2016


It is now possibel to migrate LVM-thin volumes offline from one node to an other.
Also LVM what is used by Qemu.
---
 PVE/Storage.pm | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 1192ce3..22c1a4c 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -542,6 +542,41 @@ sub storage_migrate {
  	} else {
  	    die "$errstr - target type $tcfg->{type} is not valid\n";
  	}
+
+    } elsif ($scfg->{type} eq 'lvmthin' || $scfg->{type} eq 'lvm') {
+
+	if ($tcfg->{type} eq 'lvmthin' || $tcfg->{type} eq 'lvm') {
+
+	    die "$errstr - volume has to be on the same storage backend type!"
+		if $scfg->{type} ne $tcfg->{type};
+
+	    die "$errstr - pool on target has not same name as source!"
+		if $tcfg->{type} ne $scfg->{type};
+
+	    my (undef, $volname) = parse_volname($cfg, $volid);
+	    my $size = volume_size_info($cfg, $volid, 5);
+	    my $path = path($cfg, $volid);
+
+	    $volname =~ m/^vm-(\d+)-/;
+	    my $vmid = $1;
+
+	    run_command(['/usr/bin/ssh', "root\@${target_host}",
+			 'pvesm', 'alloc', $target_storeid, $vmid,
+			 $volname, $size/1024]);
+
+	    eval {
+		run_command([["dd", "if=$path"],
+			     ["/usr/bin/ssh", "root\@${target_host}", "dd", "of=$path"]]);
+	    };
+	    if (my $err = $@) {
+		run_command(['/usr/bin/ssh', "root\@${target_host}",
+			 'pvesm', 'free', $volid]);
+	    } else {
+		vdisk_free($cfg, $volid);
+	    }
+	} else {
+	    die "$errstr - target type $tcfg->{type} is not valid\n";
+	}
     } else {
 	die "$errstr - source type '$scfg->{type}' not implemented\n";
     }
-- 
2.1.4




More information about the pve-devel mailing list