[pve-devel] [PATCH] add ovmf uefi roms support

Alexandre Derumier aderumier at odiso.com
Tue Nov 17 17:39:52 CET 2015


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer.pm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 81a1c84..87b7d20 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -30,6 +30,7 @@ use PVE::ProcFSTools;
 use PVE::QMPClient;
 use PVE::RPCEnvironment;
 use Time::HiRes qw(gettimeofday);
+use File::Copy qw(copy);
 
 my $qemu_snap_storage = {rbd => 1, sheepdog => 1};
 
@@ -390,6 +391,12 @@ EODESCR
 	description => "Sets the protection flag of the VM. This will prevent the remove operation.",
 	default => 0,
     },
+    ovmf => {
+	optional => 1,
+	type => 'boolean',
+	description => "Enable ovmf uefi roms.",
+	default => 0,
+    },
 };
 
 # what about other qemu settings ?
@@ -2683,6 +2690,15 @@ sub config_to_command {
 	push @$cmd, '-smbios', "type=1,$conf->{smbios1}";
     }
 
+    if ($conf->{ovmf}) {
+	my $ovmfvar = "OVMF_VARS-pure-efi.fd";
+	my $ovmfvar_src = "/usr/share/kvm/$ovmfvar";
+	my $ovmfvar_dst = "/tmp/$vmid-$ovmfvar";
+	copy $ovmfvar_src,$ovmfvar_dst if !(-e $ovmfvar_dst);
+	push @$cmd, '-drive', "if=pflash,format=raw,readonly,file=/usr/share/kvm/OVMF_CODE-pure-efi.fd";
+	push @$cmd, '-drive', "if=pflash,format=raw,file=$ovmfvar_dst";
+    }
+
     if ($q35) {
 	# the q35 chipset support native usb2, so we enable usb controller
 	# by default for this machine type
-- 
2.1.4



More information about the pve-devel mailing list