mirror of
git://git.proxmox.com/git/qemu-server.git
synced 2025-01-10 01:18:01 +03:00
efidisk: do not hard code efivar base image size
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>
This commit is contained in:
parent
c2327320a8
commit
a1d8c038c5
@ -140,15 +140,15 @@ my $create_disks = sub {
|
||||
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;
|
||||
$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);
|
||||
@ -163,12 +163,11 @@ my $create_disks = sub {
|
||||
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;
|
||||
$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 {
|
||||
|
Loading…
Reference in New Issue
Block a user