[pve-devel] [PATCH qemu-server 2/2] ovmf: deprecate old legay ovmf image and refactor

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Aug 25 15:23:00 CEST 2017


this was only kept for PVE 4.X where the switch to the newer OVMF
image with actual working persisten EFIVARS was made.

We do not ship this old image in PVE 5.0 anymore so remove this
legacy code as it can never trigger anyhow.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 PVE/QemuServer.pm | 38 ++++++++++----------------------------
 1 file changed, 10 insertions(+), 28 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 7d9987e..cce6aa0 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -39,7 +39,6 @@ use URI::Escape;
 
 my $OVMF_CODE = '/usr/share/kvm/OVMF_CODE-pure-efi.fd';
 my $OVMF_VARS = '/usr/share/kvm/OVMF_VARS-pure-efi.fd';
-my $OVMF_IMG = '/usr/share/kvm/OVMF-pure-efi.fd';
 
 my $qemu_snap_storage = {rbd => 1, sheepdog => 1};
 
@@ -2878,44 +2877,27 @@ sub config_to_command {
     }
 
     if ($conf->{bios} && $conf->{bios} eq 'ovmf') {
-	my $ovmfbase;
-
-	# prefer the OVMF_CODE variant
-	if (-f $OVMF_CODE) {
-	    $ovmfbase = $OVMF_CODE;
-	} elsif (-f $OVMF_IMG) {
-	    $ovmfbase = $OVMF_IMG;
-	}
+	my $ovmfbase = $OVMF_CODE;
 
 	die "no uefi base img found\n" if !$ovmfbase;
-	push @$cmd, '-drive', "if=pflash,unit=0,format=raw,readonly,file=$ovmfbase";
 
-	if (defined($conf->{efidisk0}) && ($ovmfbase eq $OVMF_CODE)) {
-	    my $d = PVE::JSONSchema::parse_property_string($efidisk_fmt, $conf->{efidisk0});
-	    my $format = $d->{format} // 'raw';
-	    my $path;
+	my $path;
+	if (my $efidisk = $conf->{efidisk0}) {
+	    my $d = PVE::JSONSchema::parse_property_string($efidisk_fmt, $efidisk);
 	    my ($storeid, $volname) = PVE::Storage::parse_volume_id($d->{file}, 1);
 	    if ($storeid) {
 		$path = PVE::Storage::path($storecfg, $d->{file});
-		my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
-		$format = qemu_img_format($scfg, $volname);
 	    } else {
 		$path = $d->{file};
-		$format = "raw";
 	    }
-	    push @$cmd, '-drive', "if=pflash,unit=1,id=drive-efidisk0,format=$format,file=$path";
-	} elsif ($ovmfbase eq $OVMF_CODE) {
-	    warn "using uefi without permanent efivars disk\n";
-	    my $ovmfvar_dst = "/tmp/$vmid-ovmf.fd";
-	    PVE::Tools::file_copy($OVMF_VARS, $ovmfvar_dst, 256*1024);
-	    push @$cmd, '-drive', "if=pflash,unit=1,format=raw,file=$ovmfvar_dst";
 	} else {
-	    # if the base img is not OVMF_CODE, we do not have to bother
-	    # to create/use a vars image, since it will not be used anyway
-	    # this can only happen if someone manually deletes the OVMF_CODE image
-	    # or has an old pve-qemu-kvm version installed.
-	    # both should not happen, but we ignore it here
+	    warn "using uefi without permanent efivars disk\n";
+	    $path = "/tmp/$vmid-ovmf.fd";
+	    PVE::Tools::file_copy($OVMF_VARS, $path, -s $OVMF_VARS);
 	}
+
+	push @$cmd, '-drive', "if=pflash,unit=0,format=raw,readonly,file=$ovmfbase";
+	push @$cmd, '-drive', "if=pflash,unit=1,id=drive-efidisk0,file=$path";
     }
 
 
-- 
2.11.0





More information about the pve-devel mailing list