applied both patches

On Fri, Mar 16, 2018 at 11:05:55AM +0100, Dietmar Maurer wrote:
> template => linked clone
> normal VM => full clone
> 
> Signed-off-by: Dietmar Maurer <[email protected]>
> ---
>  PVE/API2/Qemu.pm | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index b1c6896..300e347 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -2476,12 +2476,10 @@ __PACKAGE__->register_method({
>              }),
>           storage => get_standard_option('pve-storage-id', {
>               description => "Target storage for full clone.",
> -             requires => 'full',
>               optional => 1,
>           }),
>           'format' => {
> -             description => "Target format for file storage.",
> -             requires => 'full',
> +             description => "Target format for file storage. Only valid for 
> full clone.",
>               type => 'string',
>               optional => 1,
>               enum => [ 'raw', 'qcow2', 'vmdk'],
> @@ -2489,9 +2487,8 @@ __PACKAGE__->register_method({
>           full => {
>               optional => 1,
>               type => 'boolean',
> -             description => "Create a full copy of all disk. This is always 
> done when " .
> +             description => "Create a full copy of all disks. This is always 
> done when " .
>                   "you clone a normal VM. For VM templates, we try to create 
> a linked clone by default.",
> -             default => 0,
>           },
>           target => get_standard_option('pve-node', {
>               description => "Target node. Only allowed if the original VM is 
> on shared storage.",
> @@ -2572,6 +2569,17 @@ __PACKAGE__->register_method({
>           die "snapshot '$snapname' does not exist\n"
>               if $snapname && !defined( $conf->{snapshots}->{$snapname});
>  
> +         my $full = extract_param($param, 'full');
> +         if (!defined($full)) {
> +             $full = !PVE::QemuConfig->is_template($conf);
> +         }
> +
> +         die "parameter 'storage' not allowed for linked clones\n"
> +             if defined($storage) && !$full;
> +
> +         die "parameter 'format' not allowed for linked clones\n"
> +             if defined($format) && !$full;
> +
>           my $oldconf = $snapname ? $conf->{snapshots}->{$snapname} : $conf;
>  
>           my $sharedvm = &$check_storage_access_clone($rpcenv, $authuser, 
> $storecfg, $oldconf, $storage);
> @@ -2610,7 +2618,7 @@ __PACKAGE__->register_method({
>                   if (PVE::QemuServer::drive_is_cdrom($drive, 1)) {
>                       $newconf->{$opt} = $value; # simply copy configuration
>                   } else {
> -                     if ($param->{full} || 
> PVE::QemuServer::drive_is_cloudinit($drive)) {
> +                     if ($full || 
> PVE::QemuServer::drive_is_cloudinit($drive)) {
>                           die "Full clone feature is not supported for drive 
> '$opt'\n"
>                               if !PVE::Storage::volume_has_feature($storecfg, 
> 'copy', $drive->{file}, $snapname, $running);
>                           $fullclone->{$opt} = 1;
> -- 
> 2.11.0

_______________________________________________
pve-devel mailing list
[email protected]
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to