Add skiplock to do_import

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@proxmox.com>
This commit is contained in:
Dominic Jäger 2019-10-28 12:47:33 +01:00 committed by Thomas Lamprecht
parent b406ab6342
commit 7f384190de
2 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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