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.jae...@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
-- 
2.20.1

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to