Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added PXE boot support on QEMU Q35 #727

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
26 changes: 23 additions & 3 deletions Platforms/QemuQ35Pkg/Plugins/QemuRunner/QemuRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import shutil
from pathlib import Path
from edk2toolext.environment import plugin_manager
from edk2toolext.environment import shell_environment
from edk2toolext.environment.plugintypes import uefi_helper_plugin
from edk2toollib import utility_functions
from edk2toollib.uefi.edk2.parsers.dsc_parser import DscParser
Expand Down Expand Up @@ -75,6 +76,24 @@ def Runner(env):
else:
smm_enabled = "off"

pxe_boot = env.GetValue("PXE_BOOT")
if pxe_boot is not None and pxe_boot.upper() == "TRUE":
# Prepare PXE folder and boot file, default to Shell.efi from build directory
pxe_path = env.GetValue("PXE_FOLDER_PATH")
pxe_file = env.GetValue("PXE_BOOT_FILE")
if pxe_path is None or pxe_file is None:
pxe_path = os.path.join(env.GetValue("BUILD_OUTPUT_BASE"), "X64")
pxe_file = "Shell.efi"

# Enable e1000 as nic and setup the TFTP server for pxe boot
args += f" -netdev user,id=net0,tftp={pxe_path},bootfile={pxe_file} "\
f"-device e1000,netdev=net0 "

# Tips: To use your own option rom, add the following to the above line
kuqin12 marked this conversation as resolved.
Show resolved Hide resolved
# ",romfile=<path_to_your_8086100e.efirom> "\
# To dump the network traffic to a file, add the following to the above line
# "-object filter-dump,id=f1,netdev=net0,file=dump.dat"

accel = ""
if env.GetValue("QEMU_ACCEL") is not None:
if env.GetValue("QEMU_ACCEL").lower() == "kvm":
Expand All @@ -87,9 +106,6 @@ def Runner(env):
args += " -machine q35,smm=" + smm_enabled + accel
path_to_os = env.GetValue("PATH_TO_OS")
if path_to_os is not None:
# Potentially dealing with big daddy, give it more juice...
args += " -m 8192"

file_extension = Path(path_to_os).suffix.lower().replace('"', '')

storage_format = {
Expand All @@ -102,6 +118,10 @@ def Runner(env):

args += f" -drive file=\"{path_to_os}\",format={storage_format},if=none,id=os_nvme"
args += " -device nvme,serial=nvme-1,drive=os_nvme"

if (path_to_os is not None) or (pxe_boot is not None and pxe_boot.upper() == "TRUE"):
# Potentially dealing with big daddy, give it more juice...
args += " -m 8192"
else:
args += " -m 2048"

Expand Down
Loading