The size of this image is not fixed, it increased to 528k in more
recent build of OVMF and could increase further (not likely, but
possible).
Instead of changing the hardcoded value move to a more generic
approach and read the size from the base image at creation time.
Use the new convert_size method and generalise the assignment of
size and volid between the efidisk and the normal case, as a part of
this change.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
my $defformat = PVE::Storage::storage_default_format($storecfg, $storeid);
my $fmt = $disk->{format} || $defformat;
my $defformat = PVE::Storage::storage_default_format($storecfg, $storeid);
my $fmt = $disk->{format} || $defformat;
+ $size = PVE::Tools::convert_size($size, 'gb' => 'kb'); # vdisk_alloc uses kb
+
my $volid;
if ($ds eq 'efidisk0') {
# handle efidisk
my $ovmfvars = '/usr/share/kvm/OVMF_VARS-pure-efi.fd';
die "uefi vars image not found\n" if ! -f $ovmfvars;
my $volid;
if ($ds eq 'efidisk0') {
# handle efidisk
my $ovmfvars = '/usr/share/kvm/OVMF_VARS-pure-efi.fd';
die "uefi vars image not found\n" if ! -f $ovmfvars;
- $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid,
- $fmt, undef, 128);
- $disk->{file} = $volid;
- $disk->{size} = 128*1024;
+ $size = PVE::Tools::convert_size(-s $ovmfvars, 'b' => 'kb');
+ $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $fmt, undef, $size);
my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid);
my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
my $qemufmt = PVE::QemuServer::qemu_img_format($scfg, $volname);
my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid);
my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
my $qemufmt = PVE::QemuServer::qemu_img_format($scfg, $volname);
my $err = $@;
die "Copying of EFI Vars image failed: $err" if $err;
} else {
my $err = $@;
die "Copying of EFI Vars image failed: $err" if $err;
} else {
- $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid,
- $fmt, undef, $size*1024*1024);
- $disk->{file} = $volid;
- $disk->{size} = $size*1024*1024*1024;
+ $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $fmt, undef, $size);
}
push @$vollist, $volid;
}
push @$vollist, $volid;
+ $disk->{file} = $volid;
+ $disk->{size} = PVE::Tools::convert_size($size, 'kb' => 'b');
delete $disk->{format}; # no longer needed
$res->{$ds} = PVE::QemuServer::print_drive($vmid, $disk);
} else {
delete $disk->{format}; # no longer needed
$res->{$ds} = PVE::QemuServer::print_drive($vmid, $disk);
} else {