This commit is contained in:
Artur Gurgul 2025-08-26 17:50:38 +02:00
parent 54d4dfcb33
commit 605cfd38f9
8 changed files with 130 additions and 6 deletions

View file

@ -91,20 +91,33 @@ module Qemu
defaults[:display] = DisplayMode.fullscreen
defaults[:display] = DisplayMode.window
defaults[:display] = DisplayMode.none
# defaults[:display] = DisplayMode.none
opts = defaults.merge(options)
puts options
puts opts
qemu = qemu_bin_for(arch)
args = []
if System::OS == :macos && arch == :arm64
# args += ["-bios", "/opt/homebrew/share/qemu/edk2-aarch64-code.fd"]
# cp /opt/homebrew/share/qemu/edk2-arm-vars.fd ~/edk2-arm-vars.fd
args += ["-drive", "if=pflash,format=raw,unit=0,readonly=on,file=/opt/homebrew/share/qemu/edk2-aarch64-code.fd"]
args += ["-drive", "if=pflash,format=raw,unit=1,file=/Users/agurgul/edk2-arm-vars.fd"]
unless File.exist?(opts[:vars_fd])
#System.qemu_paths
FileUtils.cp(System.qemu_vars_fd_path, opts[:vars_fd])
end
unless File.exist?(opts[:code_fd])
FileUtils.cp(System.qemu_code_fd_path, opts[:code_fd])
end
args += ["-drive", "if=pflash,format=raw,unit=0,readonly=on,file=#{opts[:code_fd]}"]
args += ["-drive", "if=pflash,format=raw,unit=1,file=#{opts[:vars_fd]}"]
if opts[:display] == DisplayMode::none
port = 2222
@ -181,6 +194,9 @@ module Qemu
# brew install swtpm
# swtpm socket --tpm2 --ctrl type=unixio,path=./tpm/tpm.sock --tpmstate dir=./tpm --daemon
["swtpm", "socket", "--tpm2", "--ctrl", "type=unixio,path=./tpm/tpm.sock", "--tpmstate", "dir=./tpm"]
# args += ["-chardev", "socket,id=chrtpm,path=/Users/agurgul/Downloads/tpm/tpm.sock"]
# args += ["-tpmdev", "emulator,id=tpm0,chardev=chrtpm"]
# args += ["-device", "tpm-crb-device,tpmdev=tpm0"]
@ -190,6 +206,9 @@ module Qemu
#args += ["-device", "tpm-tis,tpmdev=tpm0"]
args += ["-device", "tpm-tis-device,tpmdev=tpm0"]
# nic user,ipv6=off,model=rtl8139,mac=84:1b:77:c9:03:a6
# TODO: Shared network on macOS
# -netdev vmnet-shared,id=net0
end
# args += ["-device", "virtio-net,netdev=n0", "-netdev", "user,id=n0"] # user-mode NAT