[pve-devel] [PATCH v7 pve-storage 07/10] Implement support for cloning images.
Fabian Grünbichler
f.gruenbichler at proxmox.com
Mon Aug 7 14:33:12 CEST 2017
On Tue, Jun 20, 2017 at 10:39:59PM +0200, mir at datanom.net wrote:
> From: Michael Rasmussen <mir at datanom.net>
>
> Signed-off-by: Michael Rasmussen <mir at datanom.net>
> ---
> PVE/Storage/FreeNASPlugin.pm | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/PVE/Storage/FreeNASPlugin.pm b/PVE/Storage/FreeNASPlugin.pm
> index 943eeab..9c0136d 100644
> --- a/PVE/Storage/FreeNASPlugin.pm
> +++ b/PVE/Storage/FreeNASPlugin.pm
> @@ -963,6 +963,33 @@ sub create_base {
> sub clone_image {
> my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
>
whitespace
> + $snap ||= "__base__$vmid";
> +
> + my ($vtype, $basename, $basevmid, undef, undef, $isBase, $format) =
> + $class->parse_volname($volname);
> +
> + die "clone_image only works on base images\n" unless $isBase;
> +
> + my $name = $freenas_find_free_diskname->($storeid, $scfg, $vmid, $format);
> +
> + $class->volume_snapshot($scfg, $storeid, $basename, $snap);
> +
whitespace
> + my $data = {
> + name => "$scfg->{pool}/$name"
> + };
> + $freenas_request->(
> + $scfg, 'POST', "storage/snapshot/$scfg->{pool}/$basename\@$snap/clone/", encode_json($data));
> +
> + $name = "$basename/$name";
why not skip this
> + # get ZFS dataset name from PVE volname
> + my (undef, $clonedname) = $class->parse_volname($name);
then you don't need this
> +
> + $freenas_create_lun->($scfg, $vmid, $clonedname);
and can use $name here
> +
whitespace
> + my $res = $class->deactivate_volume($storeid, $scfg, $basename);
> + die "Could not deactivate volume '$basename'\n" unless $res;
this can stay like it is
> +
whitespace
> + return $name;
and this becomes
return "$basename/$name";
> }
>
whitespace
> sub alloc_image {
> --
> 2.11.0
>
>
> ----
>
> This mail was virus scanned and spam checked before delivery.
> This mail is also DKIM signed. See header dkim-signature.
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list