[pve-devel] [PATCH qemu-server 6/7] Add skiplock to import

Dominic Jäger d.jaeger at proxmox.com
Fri Oct 25 11:24:06 CEST 2019


Functions like importovf can now use a parameter lock in the config.

Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
---
 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 a16033c..97f0f88 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;
     }});
@@ -639,7 +639,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
-- 
2.20.1




More information about the pve-devel mailing list