diff --git a/pkgs/clan-cli/clan_cli/vms/qemu.py b/pkgs/clan-cli/clan_cli/vms/qemu.py index f18f11e0f..0fd1108cc 100644 --- a/pkgs/clan-cli/clan_cli/vms/qemu.py +++ b/pkgs/clan-cli/clan_cli/vms/qemu.py @@ -151,6 +151,7 @@ def qemu_command( "-serial", "null", "-chardev", "file,id=char0,path=/dev/stdout", "-device", "virtconsole,chardev=char0,nr=0", + "-monitor", "none", ]) vsock_cid = None diff --git a/pkgs/clan-cli/clan_cli/vms/run.py b/pkgs/clan-cli/clan_cli/vms/run.py index a0cb3388c..18f48e89b 100644 --- a/pkgs/clan-cli/clan_cli/vms/run.py +++ b/pkgs/clan-cli/clan_cli/vms/run.py @@ -127,6 +127,7 @@ def start_vm( env = os.environ.copy() env.update(extra_env) cmd = nix_shell(packages, args) + log.debug(f"Starting VM with command: {cmd}") with subprocess.Popen( cmd, env=env, stdout=stdout, stderr=stderr, stdin=stdin ) as process: @@ -291,7 +292,12 @@ def spawn_vm( start_waypipe(qemu_cmd.vsock_cid, f"[{vm.machine_name}] "), start_virtiofsd(virtiofsd_socket), start_vm( - qemu_cmd.args, packages, extra_env, stdout=stdout, stderr=stderr + qemu_cmd.args, + packages, + extra_env, + stdout=stdout, + stderr=stderr, + stdin=stdin, ) as process, ): qemu_vm = QemuVm(machine, process, socketdir) diff --git a/pkgs/clan-cli/tests/test_vars_deployment.py b/pkgs/clan-cli/tests/test_vars_deployment.py index 62941e9d8..88229028f 100644 --- a/pkgs/clan-cli/tests/test_vars_deployment.py +++ b/pkgs/clan-cli/tests/test_vars_deployment.py @@ -1,4 +1,5 @@ import json +import subprocess from contextlib import ExitStack import pytest @@ -99,10 +100,13 @@ def test_vm_deployment( vm1_config = inspect_vm(machine=Machine("m1_machine", FlakeId(str(flake.path)))) vm2_config = inspect_vm(machine=Machine("m2_machine", FlakeId(str(flake.path)))) with ExitStack() as stack: - vm1 = stack.enter_context(spawn_vm(vm1_config)) - vm2 = stack.enter_context(spawn_vm(vm2_config)) + vm1 = stack.enter_context(spawn_vm(vm1_config, stdin=subprocess.DEVNULL)) + vm2 = stack.enter_context(spawn_vm(vm2_config, stdin=subprocess.DEVNULL)) qga_m1 = stack.enter_context(vm1.qga_connect()) qga_m2 = stack.enter_context(vm2.qga_connect()) + # run these always succesfull commands to make sure all vms have started before continuing + qga_m1.run(["echo"]) + qga_m2.run(["echo"]) # check my_secret is deployed result = qga_m1.run(["cat", "/run/secrets/vars/m1_generator/my_secret"]) assert result.stdout == "hello\n"