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

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Jun 7 10:08:04 CEST 2016


On Tue, Jun 07, 2016 at 09:10:07AM +0200, Wolfgang Link wrote:
> 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"]]);

The destination needs "conv=sparse" otherwise you end up filling up the
lvm-thin devices with zeroes. It might also be worth considering adding
"-C" to the ssh call.

> +	    };
> +	    if (my $err = $@) {
> +		run_command(['/usr/bin/ssh', "root\@${target_host}",
> +			 'pvesm', 'free', $volid]);
> +	    } else {
> +		vdisk_free($cfg, $volid);

Shouldn't this use 'ssh ... pvesm free'?

> +	    }
> +	} else {
> +	    die "$errstr - target type $tcfg->{type} is not valid\n";
> +	}
>      } else {
>  	die "$errstr - source type '$scfg->{type}' not implemented\n";
>      }
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 



More information about the pve-devel mailing list