mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-06-17 06:48:18 +00:00
Backport UEFI boot mode support for Qemu VMs
This commit is contained in:
@ -122,6 +122,7 @@ class QemuVM(BaseNode):
|
||||
self._kernel_image = ""
|
||||
self._kernel_command_line = ""
|
||||
self._tpm = False
|
||||
self._uefi = False
|
||||
self._legacy_networking = False
|
||||
self._replicate_network_connection_state = True
|
||||
self._create_config_disk = False
|
||||
@ -833,6 +834,30 @@ class QemuVM(BaseNode):
|
||||
log.info('QEMU VM "{name}" [{id}] has disabled the Trusted Platform Module (TPM)'.format(name=self._name, id=self._id))
|
||||
self._tpm = tpm
|
||||
|
||||
@property
|
||||
def uefi(self):
|
||||
"""
|
||||
Returns whether UEFI boot mode is activated for this QEMU VM.
|
||||
|
||||
:returns: boolean
|
||||
"""
|
||||
|
||||
return self._uefi
|
||||
|
||||
@uefi.setter
|
||||
def uefi(self, uefi):
|
||||
"""
|
||||
Sets whether UEFI boot mode is activated for this QEMU VM.
|
||||
|
||||
:param uefi: boolean
|
||||
"""
|
||||
|
||||
if uefi:
|
||||
log.info(f'QEMU VM "{self._name}" [{self._id}] has enabled the UEFI boot mode')
|
||||
else:
|
||||
log.info(f'QEMU VM "{self._name}" [{self._id}] has disabled the UEFI boot mode')
|
||||
self._uefi = uefi
|
||||
|
||||
@property
|
||||
def options(self):
|
||||
"""
|
||||
@ -1994,12 +2019,16 @@ class QemuVM(BaseNode):
|
||||
|
||||
options = []
|
||||
if self._bios_image:
|
||||
if self._uefi:
|
||||
raise QemuError("Cannot use a bios image and the UEFI boot mode at the same time")
|
||||
if not os.path.isfile(self._bios_image) or not os.path.exists(self._bios_image):
|
||||
if os.path.islink(self._bios_image):
|
||||
raise QemuError("bios image '{}' linked to '{}' is not accessible".format(self._bios_image, os.path.realpath(self._bios_image)))
|
||||
else:
|
||||
raise QemuError("bios image '{}' is not accessible".format(self._bios_image))
|
||||
options.extend(["-bios", self._bios_image.replace(",", ",,")])
|
||||
elif self._uefi:
|
||||
options.extend(["-bios", "OVMF.fd"]) # the OVMF bios image should be in the image directory
|
||||
return options
|
||||
|
||||
def _linux_boot_options(self):
|
||||
|
Reference in New Issue
Block a user