1
0
forked from clan/clan-core

add: serial option

This commit is contained in:
a-kenji 2023-12-14 15:35:14 +01:00
parent 7b5fffdaf4
commit 80c70873ad
3 changed files with 43 additions and 22 deletions

View File

@ -7,11 +7,11 @@
]
},
"locked": {
"lastModified": 1700927249,
"narHash": "sha256-iqmIWiEng890/ru7ZBf4nUezFPyRm2fjRTvuwwxqk2o=",
"lastModified": 1702563877,
"narHash": "sha256-7x2vXhN8HeKsTK8fhoeZgSXRMlMx1GjQvh7ittgXHOo=",
"owner": "nix-community",
"repo": "disko",
"rev": "3cb78c93e6a02f494aaf6aeb37481c27a2e2ee22",
"rev": "4c4634bbcb299248efe300b37d1624649fd59477",
"type": "github"
},
"original": {
@ -83,11 +83,11 @@
]
},
"locked": {
"lastModified": 1696058303,
"narHash": "sha256-eNqKWpF5zG0SrgbbtljFOrRgFgRzCc4++TMFADBMLnc=",
"lastModified": 1701689616,
"narHash": "sha256-ewnfgvRy73HoP5KnYmy1Rcr4m4yShvsb6TCCaKoW8pc=",
"owner": "nix-community",
"repo": "nixos-generators",
"rev": "150f38bd1e09e20987feacb1b0d5991357532fb5",
"rev": "246219bc21b943c6f6812bb7744218ba0df08600",
"type": "github"
},
"original": {
@ -98,11 +98,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1701609850,
"narHash": "sha256-6oxM84kaQT0H/+aurIcj2ON+asWYQ96zlMUIsfhKpFE=",
"lastModified": 1702483393,
"narHash": "sha256-xdZ+69I2z5ywVtJHW3+BQ99rKFDPkyaPNznstw+gfS8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0b62f5adfd6635f8013d800ceb0cf39411a8216f",
"rev": "224b3a5ad9a960e4a6e3cd59233c1616164c5ef5",
"type": "github"
},
"original": {
@ -148,11 +148,11 @@
"nixpkgs-stable": []
},
"locked": {
"lastModified": 1701572436,
"narHash": "sha256-0anfOQqDend6kSuF8CmOSAZsiAS1nwOsin5VQukh6Q4=",
"lastModified": 1702177193,
"narHash": "sha256-J2409SyXROoUHYXVy9h4Pj0VU8ReLuy/mzBc9iK4DBg=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "8bca48cb9a12bbd8766f359ad00336924e91b7f7",
"rev": "d806e546f96c88cd9f7d91c1c19ebc99ba6277d9",
"type": "github"
},
"original": {
@ -168,11 +168,11 @@
]
},
"locked": {
"lastModified": 1699786194,
"narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=",
"lastModified": 1702461037,
"narHash": "sha256-ssyGxfGHRuuLHuMex+vV6RMOt7nAo07nwufg9L5GkLg=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1",
"rev": "d06b70e5163a903f19009c3f97770014787a080f",
"type": "github"
},
"original": {

View File

@ -19,6 +19,7 @@ class VmConfig:
memory_size: int
graphics: bool
wayland: bool = False
serial: bool = False
def inspect_vm(flake_url: str | Path, flake_attr: str) -> VmConfig:

View File

@ -33,7 +33,6 @@ def graphics_options(vm: VmConfig) -> list[str]:
"-audiodev", "spice,id=audio0",
"-device", "intel-hda",
"-device", "hda-duplex,audiodev=audio0",
"-vga", "none",
"-display", "gtk,gl=on",
"-device", "virtio-gpu-gl",
"-display", "spice-app,gl=on",
@ -66,10 +65,16 @@ def qemu_command(
(Path(nixos_config["toplevel"]) / "kernel-params").read_text(),
f'init={nixos_config["toplevel"]}/init',
f'regInfo={nixos_config["regInfo"]}/registration',
"console=ttyS0,115200n8",
# "console=hvc0,115200n8",
# "console=ttyS0,115200n8", # serial
# console=hvc0
]
if not wayland:
kernel_cmdline.append("console=tty0")
if vm.serial:
kernel_cmdline.append("console=hvc0,115200n8")
print("HUUUI")
exit()
# if not wayland:
# kernel_cmdline.append("console=tty0")
# fmt: off
command = [
"qemu-kvm",
@ -96,8 +101,22 @@ def qemu_command(
if vm.graphics:
command.extend(graphics_options(vm))
else:
command.append("-nographic")
if vm.serial:
# command.append("-nographic") # weglassen?? kommt auf modus drauf an
command.extend([
"-serial", "null",
"-device", "virtio-serial",
"-chardev", "stdio,mux=on,id=char0,signal=off",
"-mon", "chardev=char0,mode=readline",
]) # weglassen?? kommt auf modus drauf an
#-serial null \
# -device virtio-serial \
# -chardev stdio,mux=on,id=char0,signal=off \
# -mon chardev=char0,mode=readline \
# terminal heisst dann anders
# console=hvc0
# statt ttyS0
return command
@ -256,7 +275,7 @@ def run_vm(
packages = ["nixpkgs#qemu"]
env = os.environ.copy()
if vm.graphics and not vm.wayland:
if vm.graphics and not (vm.wayland or vm.serial):
packages.append("nixpkgs#virt-viewer")
remote_viewer_mimetypes = module_root() / "vms" / "mimetypes"
env[
@ -305,4 +324,5 @@ def register_run_parser(parser: argparse.ArgumentParser) -> None:
parser.add_argument("machine", type=str, help="machine in the flake to run")
parser.add_argument("--flake-url", type=str, help="flake url")
parser.add_argument("--wayland", action="store_true", help="use wayland")
parser.add_argument("--serial", action="store_true", help="use serial")
parser.set_defaults(func=run_command)