Merge pull request #3051 from GNS3/arm64-qemu-support

Enhance aarch64 support with UEFI and improved console options
This commit is contained in:
Jeremy Grossmann authored and GitHub committed 2026-11-05 14:06:29 +01:00
commit 94077b4884
3 files changed
+40 -28

No files matched your search

+29 -20
View File
@@ -2070,16 +2070,12 @@ class QemuVM(KernelDatapathMixin, BaseNode):
if external_console_port:
return ["-serial", f"telnet:127.0.0.1:{internal_console_port},server,nowait"]
else:
return []
def _vnc_options(self, port):
if port:
vnc_port = port - 5900 # subtract by 5900 to get the display number
return ["-vnc", f"{self._manager.port_manager.console_host}:{vnc_port}"]
else:
return []
return ["-vnc", f"{self._manager.port_manager.console_host}:{vnc_port}", "-device", "virtio-gpu-pci"]
def _spice_options(self, port):
@@ -2094,9 +2090,7 @@ class QemuVM(KernelDatapathMixin, BaseNode):
console_host = "::"
except OSError as e:
raise QemuError(f"Could not check if IPv6 is enabled: {e}")
return ["-spice", f"addr={console_host},port={port},disable-ticketing=on", "-vga", "qxl"]
else:
return []
return ["-spice", f"addr={console_host},port={port},disable-ticketing=on", "-device", "virtio-gpu-pci"]
def _spice_with_agent_options(self, port):
@@ -2124,17 +2118,29 @@ class QemuVM(KernelDatapathMixin, BaseNode):
def _console_options(self):
console_options = []
if self._console_type in ("telnet", "ssh") and self._wrap_console:
return self._serial_options(self._internal_console_port, self.console)
console_options = self._serial_options(self._internal_console_port, self.console)
elif self._console_type == "vnc":
return self._vnc_options(self.console)
console_options = self._vnc_options(self.console)
elif self._console_type == "spice":
return self._spice_options(self.console)
console_options = self._spice_options(self.console)
elif self._console_type == "spice+agent":
return self._spice_with_agent_options(self.console)
console_options = self._spice_with_agent_options(self.console)
elif self._console_type != "none":
raise QemuError(f"Console type {self._console_type} is unknown")
return []
if self._console_type in ("vnc", "spice"):
if self.platform == "aarch64":
# add a USB controller with a keyboard and mouse
console_options.extend(
["-device", "qemu-xhci,id=usb", "-device", "usb-kbd,bus=usb.0", "-device", "usb-tablet,bus=usb.0"]
)
else:
# avoiding mouse offset (see https://github.com/GNS3/gns3-server/issues/2335)
console_options.extend(["-machine", "usb=on", "-device", "usb-tablet"])
return console_options
def _aux_options(self):
@@ -2569,8 +2575,8 @@ class QemuVM(KernelDatapathMixin, BaseNode):
raise QemuError(f"Cannot copy {vars_name} file to the node working directory: {e}")
log.debug(f"Configuring UEFI boot mode using firmware file: '{firmware_path}'")
options.extend(["-drive", f"if=pflash,format=raw,readonly,file={firmware_path}"])
options.extend(["-drive", f"if=pflash,format=raw,file={vars_node_path}"])
options.extend(["-drive", f"file={firmware_path},if=pflash,unit=0,format=raw,readonly=on"])
options.extend(["-drive", f"file={vars_node_path},if=pflash,unit=1,format=raw"])
# edk2 firmware requires a Random Number Generator (RNG) device in order to turn network adapters on
options.extend(["-object", "rng-random,filename=/dev/urandom,id=rng0"])
@@ -2745,7 +2751,7 @@ class QemuVM(KernelDatapathMixin, BaseNode):
Disable graphics for Qemu if no graphics options are specified.
"""
if any(opt in self._options for opt in ["-display", "-nographic", "-curses", "-sdl-spice", "-vnc"]):
if any(opt in self._options for opt in ["-display", "-nographic", "-curses", "-sdl-spice", "-vnc", "-spice"]):
return []
return ["-display", "none"]
@@ -2925,6 +2931,13 @@ class QemuVM(KernelDatapathMixin, BaseNode):
if await self._run_with_hardware_acceleration(self.qemu_path, self._options):
command.extend(["-machine", "accel=kvm"])
kvm_enabled = True
else:
self.project.emit(
"log.warning",
{
"message": f'QEMU VM "{self._name}": KVM hardware acceleration is not available, performance will be reduced'
},
)
command.extend(["-boot", f"order={self._boot_priority}"])
command.extend(self._cdrom_option())
command.extend(await self._disk_options())
@@ -2966,10 +2979,6 @@ class QemuVM(KernelDatapathMixin, BaseNode):
)
command.extend(self._kvmclock_off_options(additional_opt_list))
command.extend(additional_opt_list)
# avoiding mouse offset (see https://github.com/GNS3/gns3-server/issues/2335)
if self._console_type == "vnc":
command.extend(["-machine", "usb=on", "-device", "usb-tablet"])
return command
def asdict(self):
@@ -95,7 +95,10 @@ class QemuTemplate(TemplateBase):
False, description="Automatically create a config disk on HDD disk interface (secondary slave)"
)
tpm: Optional[bool] = Field(False, description="Enable Trusted Platform Module (TPM)")
uefi: Optional[bool] = Field(False, description="Enable UEFI boot mode")
uefi: Optional[bool] = Field(
default_factory=lambda data: data.get("platform") == QemuPlatform.aarch64,
description="Enable UEFI boot mode",
)
on_close: Optional[QemuOnCloseAction] = Field(
QemuOnCloseAction.power_off, description="Action to execute on the VM is closed"
)