[pve-devel] applied: [PATCH qemu-server v2 2/3] Add skiplock to do_import

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Oct 29 19:16:44 CET 2019


On 10/28/19 12:47 PM, Dominic Jäger wrote:
> Functions like qm importovf can now set the "lock" property in a config file
> before calling do_import.
> 
> Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
> ---
> v1->v2: Edited only the commit message ("parameter lock" -> "lock property")
> 
>  PVE/CLI/qm.pm                | 4 ++--
>  PVE/QemuServer/ImportDisk.pm | 6 ++++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
> index acafdc0..3bf5f97 100755
> --- a/PVE/CLI/qm.pm
> +++ b/PVE/CLI/qm.pm
> @@ -488,7 +488,7 @@ __PACKAGE__->register_method ({
>  	die "storage $storeid does not support vm images\n"
>  	    if !$target_storage_config->{content}->{images};
>  
> -	PVE::QemuServer::ImportDisk::do_import($source, $vmid, $storeid, { format => $format });
> +	PVE::QemuServer::ImportDisk::do_import($source, $vmid, $storeid, 0, { format => $format });
>  
>  	return undef;
>      }});
> @@ -640,7 +640,7 @@ __PACKAGE__->register_method ({
>  		foreach my $disk (@{ $parsed->{disks} }) {
>  		    my ($file, $drive) = ($disk->{backing_file}, $disk->{disk_address});
>  		    PVE::QemuServer::ImportDisk::do_import($file, $vmid, $storeid,
> -			{ drive_name => $drive, format => $format });
> +			0, { drive_name => $drive, format => $format });
>  		}
>  
>  		# reload after disks entries have been created
> diff --git a/PVE/QemuServer/ImportDisk.pm b/PVE/QemuServer/ImportDisk.pm
> index 5d391e6..9cae461 100755
> --- a/PVE/QemuServer/ImportDisk.pm
> +++ b/PVE/QemuServer/ImportDisk.pm
> @@ -12,7 +12,7 @@ use PVE::Tools qw(run_command extract_param);
>  # $optional->{drive_name} may be used to specify ide0, scsi1, etc ...
>  # $optional->{format} may be used to specify qcow2, raw, etc ...
>  sub do_import {
> -    my ($src_path, $vmid, $storage_id, $optional) = @_;
> +    my ($src_path, $vmid, $storage_id, $skiplock, $optional) = @_;
>  
>      my $drive_name = extract_param($optional, 'drive_name');
>      my $format = extract_param($optional, 'format');
> @@ -41,7 +41,9 @@ sub do_import {
>  
>      my $create_drive = sub {
>  	my $vm_conf = PVE::QemuConfig->load_config($vmid);
> -	PVE::QemuConfig->check_lock($vm_conf);
> +	if (!$skiplock) {
> +	    PVE::QemuConfig->check_lock($vm_conf);
> +	}
>  
>  	if ($drive_name) {
>  		# should never happen as setting $drive_name is not exposed to public interface
> 

applied, but I added a followup which completely changed how "skiplock" is
passed. Namely, I renamed the do_import "$optional" parameter to, well,
"$params" and added it as hash entry there.
This allows to easily just omit it, and gives it clear semantics if it's
used, i.e.:
do_import($source, $vmid, $storeid, 1, { format => $format });
vs:
do_import($source, $vmid, $storeid, { format => $format, skiplock => 1 });

Sorry, I should have seen this already on my first review...





More information about the pve-devel mailing list