clone disk: pass in efi vars size rather than config

It's confusing that the config associated to the destination is
actually a reference to the source config for both existing callers.

Also, disk import will need to base the calculation on the passed-in
drive parameters and not just the current config, so this change is in
preparation for that too.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2022-03-09 11:09:08 +01:00 committed by Fabian Grünbichler
parent 1196086ff1
commit 7344af7bf8
2 changed files with 8 additions and 4 deletions

View File

@ -3227,11 +3227,13 @@ __PACKAGE__->register_method({
my $dest_info = {
vmid => $newid,
conf => $oldconf, # because it's a clone
storage => $storage,
format => $format,
};
$dest_info->{efisize} = PVE::QemuServer::get_efivars_size($oldconf)
if $opt eq 'efidisk0';
my $newdrive = PVE::QemuServer::clone_disk(
$storecfg,
$source_info,
@ -3486,11 +3488,13 @@ __PACKAGE__->register_method({
my $dest_info = {
vmid => $vmid,
conf => $conf,
storage => $storeid,
format => $format,
};
$dest_info->{efisize} = PVE::QemuServer::get_efivars_size($conf)
if $disk eq 'efidisk0';
my $newdrive = PVE::QemuServer::clone_disk(
$storecfg,
$source_info,

View File

@ -7576,7 +7576,7 @@ sub clone_disk {
my ($vmid, $running) = $source->@{qw(vmid running)};
my ($drivename, $drive, $snapname) = $source->@{qw(drivename drive snapname)};
my ($newvmid, $conf) = $dest->@{qw(vmid conf)};
my ($newvmid, $efisize) = $dest->@{qw(vmid efisize)};
my ($storage, $format) = $dest->@{qw(storage format)};
my $newvolid;
@ -7604,7 +7604,7 @@ sub clone_disk {
$snapname = undef;
$size = PVE::QemuServer::Cloudinit::CLOUDINIT_DISK_SIZE;
} elsif ($drivename eq 'efidisk0') {
$size = get_efivars_size($conf);
$size = $efisize or die "internal error - need to specify EFI disk size\n";
} elsif ($drivename eq 'tpmstate0') {
$dst_format = 'raw';
$size = PVE::QemuServer::Drive::TPMSTATE_DISK_SIZE;