add a flag to start qemu non-interactive

This commit is contained in:
Jörg Thalheim
2024-10-08 15:03:39 +02:00
committed by Mic92
parent c729840f09
commit 53bde4f9f7

View File

@@ -93,6 +93,7 @@ def qemu_command(
qmp_socket_file: Path, qmp_socket_file: Path,
qga_socket_file: Path, qga_socket_file: Path,
portmap: list[tuple[int, int]] | None = None, portmap: list[tuple[int, int]] | None = None,
interactive: bool = False,
) -> QemuCommand: ) -> QemuCommand:
if portmap is None: if portmap is None:
portmap = [] portmap = []
@@ -137,12 +138,20 @@ def qemu_command(
"-chardev", f"socket,path={qga_socket_file},server=on,wait=off,id=qga0", "-chardev", f"socket,path={qga_socket_file},server=on,wait=off,id=qga0",
"-device", "virtio-serial", "-device", "virtio-serial",
"-device", "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0", "-device", "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0",
] # fmt: on
if interactive:
command.extend([
"-serial", "null", "-serial", "null",
"-chardev", "stdio,mux=on,id=char0,signal=off", "-chardev", "stdio,mux=on,id=char0,signal=off",
"-mon", "chardev=char0,mode=readline", "-mon", "chardev=char0,mode=readline",
"-device", "virtconsole,chardev=char0,nr=0", "-device", "virtconsole,chardev=char0,nr=0",
] # fmt: on ])
else:
command.extend([
"-serial", "null",
"-chardev", "file,id=char0,path=/dev/stdout",
"-device", "virtconsole,chardev=char0,nr=0",
])
vsock_cid = None vsock_cid = None
if vm.graphics: if vm.graphics: