vms/run: make portmap a dict to fix serializer

This commit is contained in:
Jörg Thalheim
2024-10-08 19:24:33 +02:00
committed by Mic92
parent 1ed04fb51e
commit adbdae449d
2 changed files with 7 additions and 7 deletions

View File

@@ -92,11 +92,11 @@ def qemu_command(
virtiofsd_socket: Path,
qmp_socket_file: Path,
qga_socket_file: Path,
portmap: list[tuple[int, int]] | None = None,
portmap: dict[int, int] | None = None,
interactive: bool = False,
) -> QemuCommand:
if portmap is None:
portmap = []
portmap = {}
kernel_cmdline = [
(Path(nixos_config["toplevel"]) / "kernel-params").read_text(),
f'init={nixos_config["toplevel"]}/init',
@@ -105,7 +105,7 @@ def qemu_command(
]
if not vm.waypipe:
kernel_cmdline.append("console=tty0")
hostfwd = ",".join(f"hostfwd=tcp::{h}-:{g}" for h, g in portmap)
hostfwd = ",".join(f"hostfwd=tcp::{h}-:{g}" for h, g in portmap.items())
# fmt: off
command = [
"qemu-kvm",

View File

@@ -203,13 +203,13 @@ def spawn_vm(
cachedir: Path | None = None,
socketdir: Path | None = None,
nix_options: list[str] | None = None,
portmap: list[tuple[int, int]] | None = None,
portmap: dict[int, int] | None = None,
stdout: int | None = None,
stderr: int | None = None,
stdin: int | None = None,
) -> Iterator[QemuVm]:
if portmap is None:
portmap = []
portmap = {}
if nix_options is None:
nix_options = []
with ExitStack() as stack:
@@ -314,7 +314,7 @@ class RuntimeConfig:
cachedir: Path | None = None
socketdir: Path | None = None
nix_options: list[str] | None = None
portmap: list[tuple[int, int]] | None = None
portmap: dict[int, int] | None = None
command: list[str] | None = None
no_block: bool = False
@@ -373,7 +373,7 @@ def run_command(
vm: VmConfig = inspect_vm(machine=machine_obj)
portmap = [p.split(":") for p in args.publish]
portmap = dict(p.split(":") for p in args.publish)
runtime_config = RuntimeConfig(
nix_options=args.option,