qemu: Use Alpine's QEMU rather than host system QEMU
Use --host-qemu to use QEMU that is installed on the host system.
This commit is contained in:
parent
ae12236a34
commit
c650354fc3
|
@ -124,6 +124,10 @@ def arguments_qemu(subparser):
|
|||
display.add_argument("--display", dest="qemu_display", const="sdl,gl=on",
|
||||
help="Qemu's display parameter (default: sdl,gl=on)",
|
||||
default="sdl,gl=on", nargs="?")
|
||||
|
||||
ret.add_argument("--host-qemu", dest="host_qemu", action='store_true',
|
||||
help="Use the host system's qemu")
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
|
|
|
@ -102,7 +102,6 @@ def command_qemu(args, arch, device, img_path, spice_enabled):
|
|||
"""
|
||||
Generate the full qemu command with arguments to run postmarketOS
|
||||
"""
|
||||
qemu_bin = which_qemu(args, arch)
|
||||
deviceinfo = pmb.parse.deviceinfo(args, device=device)
|
||||
cmdline = deviceinfo["kernel_cmdline"]
|
||||
if args.cmdline:
|
||||
|
@ -118,7 +117,24 @@ def command_qemu(args, arch, device, img_path, spice_enabled):
|
|||
flavor = args.flavor
|
||||
else:
|
||||
flavor = pmb.chroot.other.kernel_flavors_installed(args, suffix)[0]
|
||||
command = [qemu_bin]
|
||||
|
||||
if args.host_qemu:
|
||||
qemu_bin = which_qemu(args, arch)
|
||||
env = {}
|
||||
command = [qemu_bin]
|
||||
else:
|
||||
rootfs_native = args.work + "/chroot_native"
|
||||
env = {"QEMU_MODULE_PATH": rootfs_native + "/usr/lib/qemu",
|
||||
"GBM_DRIVERS_PATH": rootfs_native + "/usr/lib/xorg/modules/dri",
|
||||
"LIBGL_DRIVERS_PATH": rootfs_native + "/usr/lib/xorg/modules/dri"}
|
||||
|
||||
command = [rootfs_native + "/lib/ld-musl-" +
|
||||
args.arch_native + ".so.1"]
|
||||
command += ["--library-path=" + rootfs_native + "/lib:" +
|
||||
rootfs_native + "/usr/lib"]
|
||||
command += [rootfs_native + "/usr/bin/qemu-system-" + arch]
|
||||
command += ["-L", rootfs_native + "/usr/share/qemu/"]
|
||||
|
||||
command += ["-kernel", rootfs + "/boot/vmlinuz-" + flavor]
|
||||
command += ["-initrd", rootfs + "/boot/initramfs-" + flavor]
|
||||
command += ["-append", '"' + cmdline + '"']
|
||||
|
@ -182,7 +198,7 @@ def command_qemu(args, arch, device, img_path, spice_enabled):
|
|||
command += ["-vga", "virtio"]
|
||||
command += ["-display", args.qemu_display]
|
||||
|
||||
return command
|
||||
return (command, env)
|
||||
|
||||
|
||||
def resize_image(args, img_size_new, img_path):
|
||||
|
@ -227,6 +243,17 @@ def sigterm_handler(number, frame):
|
|||
" and killed the Qemu VM it was running.")
|
||||
|
||||
|
||||
def install_depends(args, arch):
|
||||
"""
|
||||
Install any necessary qemu dependencies in native chroot
|
||||
"""
|
||||
depends = ["qemu", "qemu-system-" + arch, "qemu-ui-sdl", "qemu-ui-gtk",
|
||||
"mesa-gl", "mesa-egl", "mesa-dri-ati", "mesa-dri-freedreno",
|
||||
"mesa-dri-intel", "mesa-dri-nouveau", "mesa-dri-swrast",
|
||||
"mesa-dri-virtio", "mesa-dri-vmwgfx"]
|
||||
pmb.chroot.apk.install(args, depends)
|
||||
|
||||
|
||||
def run(args):
|
||||
"""
|
||||
Run a postmarketOS image in qemu
|
||||
|
@ -237,12 +264,13 @@ def run(args):
|
|||
arch = pmb.parse.arch.uname_to_qemu(args.arch)
|
||||
device = pmb.parse.arch.qemu_to_pmos_device(arch)
|
||||
img_path = system_image(args, device)
|
||||
install_depends(args, arch)
|
||||
logging.info("Running postmarketOS in QEMU VM (" + arch + ")")
|
||||
|
||||
# Get the Qemu and spice commands
|
||||
spice = command_spice(args)
|
||||
spice_enabled = True if spice else False
|
||||
qemu = command_qemu(args, arch, device, img_path, spice_enabled)
|
||||
qemu, env = command_qemu(args, arch, device, img_path, spice_enabled)
|
||||
|
||||
# Workaround: Qemu runs as local user and needs write permissions in the
|
||||
# system image, which is owned by root
|
||||
|
@ -266,9 +294,10 @@ def run(args):
|
|||
process = None
|
||||
try:
|
||||
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||
process = pmb.helpers.run.user(args, qemu, background=spice_enabled)
|
||||
process = pmb.helpers.run.user(args, qemu,
|
||||
background=spice_enabled, env=env)
|
||||
if spice:
|
||||
pmb.helpers.run.user(args, spice)
|
||||
pmb.helpers.run.user(args, spice, env=env)
|
||||
except KeyboardInterrupt:
|
||||
# Don't show a trace when pressing ^C
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue