forked from Mirror/pmbootstrap
qemu: fix config usage (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
a7f8623ad8
commit
84bced2110
1 changed files with 10 additions and 7 deletions
|
@ -3,6 +3,7 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
from pmb.core.arch import Arch
|
from pmb.core.arch import Arch
|
||||||
|
from pmb.core.config import Config
|
||||||
from pmb.core.context import get_context
|
from pmb.core.context import get_context
|
||||||
from pmb.helpers import logging
|
from pmb.helpers import logging
|
||||||
import os
|
import os
|
||||||
|
@ -88,10 +89,11 @@ def create_gdk_loader_cache(args: PmbArgs) -> Path:
|
||||||
return chroot_native / custom_cache_path
|
return chroot_native / custom_cache_path
|
||||||
|
|
||||||
|
|
||||||
def command_qemu(args: PmbArgs, device: str, arch: Arch, img_path, img_path_2nd=None):
|
def command_qemu(args: PmbArgs, config: Config, arch: Arch, img_path, img_path_2nd=None):
|
||||||
"""
|
"""
|
||||||
Generate the full qemu command with arguments to run postmarketOS
|
Generate the full qemu command with arguments to run postmarketOS
|
||||||
"""
|
"""
|
||||||
|
device = config.device
|
||||||
cmdline = pmb.parse.deviceinfo().kernel_cmdline or ""
|
cmdline = pmb.parse.deviceinfo().kernel_cmdline or ""
|
||||||
if args.cmdline:
|
if args.cmdline:
|
||||||
cmdline = args.cmdline
|
cmdline = args.cmdline
|
||||||
|
@ -186,7 +188,7 @@ def command_qemu(args: PmbArgs, device: str, arch: Arch, img_path, img_path_2nd=
|
||||||
command += ["-m", str(args.memory)]
|
command += ["-m", str(args.memory)]
|
||||||
|
|
||||||
command += ["-serial"]
|
command += ["-serial"]
|
||||||
if args.qemu_redir_stdio:
|
if config.qemu_redir_stdio:
|
||||||
command += ["mon:stdio"]
|
command += ["mon:stdio"]
|
||||||
else:
|
else:
|
||||||
command += ["stdio"]
|
command += ["stdio"]
|
||||||
|
@ -333,7 +335,8 @@ def run(args: PmbArgs):
|
||||||
"""
|
"""
|
||||||
Run a postmarketOS image in qemu
|
Run a postmarketOS image in qemu
|
||||||
"""
|
"""
|
||||||
device = get_context().config.device
|
config = get_context().config
|
||||||
|
device = config.device
|
||||||
if not device.startswith("qemu-"):
|
if not device.startswith("qemu-"):
|
||||||
raise RuntimeError("'pmbootstrap qemu' can be only used with one of "
|
raise RuntimeError("'pmbootstrap qemu' can be only used with one of "
|
||||||
"the QEMU device packages. Run 'pmbootstrap init' "
|
"the QEMU device packages. Run 'pmbootstrap init' "
|
||||||
|
@ -349,7 +352,7 @@ def run(args: PmbArgs):
|
||||||
install_depends(args, arch)
|
install_depends(args, arch)
|
||||||
logging.info("Running postmarketOS in QEMU VM (" + arch.qemu() + ")")
|
logging.info("Running postmarketOS in QEMU VM (" + arch.qemu() + ")")
|
||||||
|
|
||||||
qemu, env = command_qemu(args, device, arch, img_path, img_path_2nd)
|
qemu, env = command_qemu(args, config, arch, img_path, img_path_2nd)
|
||||||
|
|
||||||
# Workaround: QEMU runs as local user and needs write permissions in the
|
# Workaround: QEMU runs as local user and needs write permissions in the
|
||||||
# rootfs, which is owned by root
|
# rootfs, which is owned by root
|
||||||
|
@ -365,16 +368,16 @@ def run(args: PmbArgs):
|
||||||
|
|
||||||
# SSH/serial/network hints
|
# SSH/serial/network hints
|
||||||
logging.info("Connect to the VM:")
|
logging.info("Connect to the VM:")
|
||||||
logging.info("* (ssh) ssh -p {port} {user}@localhost".format(**vars(args)))
|
logging.info(f"* (ssh) ssh -p {args.port} {config.user}@localhost")
|
||||||
logging.info("* (serial) in this console (stdout/stdin)")
|
logging.info("* (serial) in this console (stdout/stdin)")
|
||||||
|
|
||||||
if args.qemu_redir_stdio:
|
if config.qemu_redir_stdio:
|
||||||
logging.info("NOTE: Ctrl+C is redirected to the VM! To disable this, "
|
logging.info("NOTE: Ctrl+C is redirected to the VM! To disable this, "
|
||||||
"run: pmbootstrap config qemu_redir_stdio False")
|
"run: pmbootstrap config qemu_redir_stdio False")
|
||||||
logging.info("NOTE: To quit QEMU with this option you can use "
|
logging.info("NOTE: To quit QEMU with this option you can use "
|
||||||
"Ctrl-A, X.")
|
"Ctrl-A, X.")
|
||||||
|
|
||||||
if args.ui == "none":
|
if config.ui == "none":
|
||||||
logging.warning("WARNING: With UI=none network doesn't work"
|
logging.warning("WARNING: With UI=none network doesn't work"
|
||||||
" automatically: https://postmarketos.org/qemu-network")
|
" automatically: https://postmarketos.org/qemu-network")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue