From 7f384190defcee3a74c04cb009ce25998856a065 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Dominic=20J=C3=A4ger?= Date: Mon, 28 Oct 2019 12:47:33 +0100 Subject: [PATCH] Add skiplock to do_import MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Functions like qm importovf can now set the "lock" property in a config file before calling do_import. Signed-off-by: Dominic Jäger --- 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 235f6135..b599baea 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 5d391e69..9cae4614 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 -- 2.39.5