[pve-devel] applied: [PATCH qemu-server v2 2/4] efidisk: do not hard code efivar base image size

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Sep 11 11:24:58 CEST 2017


applied whole qemu-server patch series

On Mon, Sep 11, 2017 at 08:40:27AM +0200, Thomas Lamprecht wrote:
> 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 at proxmox.com>
> ---
> 
>  PVE/API2/Qemu.pm | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 747172e..8434018 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -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 {
> -- 
> 2.11.0




More information about the pve-devel mailing list