diff --git a/profiles/ch-runner.nix b/profiles/ch-runner.nix index f156705..b9e17cf 100644 --- a/profiles/ch-runner.nix +++ b/profiles/ch-runner.nix @@ -395,6 +395,9 @@ in kwargs["pass_fds"] = kwargs.get("pass_fds", ()) kwargs["env"] = kwargs.get("env", self.make_env()) kwargs["cwd"] = kwargs.get("cwd", self.prefix) + kwargs["stdin"] = kwargs.get("stdin", subprocess.DEVNULL) + kwargs["stdout"] = kwargs.get("stdout", subprocess.DEVNULL) + kwargs["stderr"] = kwargs.get("stderr", subprocess.DEVNULL) return subprocess.Popen( args, **kwargs, @@ -511,7 +514,7 @@ in shell=False, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, - pass_fds=(2,)) + pass_fds=()) try: p.wait(0.125) needs_cleanup = False @@ -529,6 +532,7 @@ in except: # noqa: E722 pass if p.returncode is None: + print("Terminating CH") p.terminate() # CH handles SIG{INT,TERM}? p.wait() unlink_paths = [ @@ -541,7 +545,7 @@ in os.remove(p) @contextmanager - def add_virtiofsd( + def start_virtiofsd( self, root_dir, tag, @@ -555,6 +559,7 @@ in # s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) # NOTE: Nope. Virtiofsd actually expects a blocking socket # s.setblocking(True) + # s.set_inheritable(True) def rm_sock(): if os.path.exists(sock_path): @@ -643,6 +648,15 @@ in ] with ExitStack() as cleanup: + + send_dir = PASSTHRU_ENV["HOME"] + f"/send/{args.vm}" + os.makedirs(send_dir, exist_ok=True) + vfsd, vfsd_path = cleanup.enter_context( + ps.start_virtiofsd( + send_dir, + tag="send", + )) + ch = cleanup.enter_context(ps.run_ch()) ps.exec(*ch_remote, "create", args.vm_config) ps.exec( @@ -650,13 +664,6 @@ in *ch_remote, "add-net", "id=wan,fd=3,mac=00:00:00:00:00:01") - send_dir = PASSTHRU_ENV["HOME"] + f"/send/{args.vm}" - os.makedirs(send_dir, exist_ok=True) - vfsd, vfsd_path = cleanup.enter_context( - ps.add_virtiofsd( - send_dir, - tag="send", - )) ps.exec(*ch_remote, "add-fs", f"tag=send,socket={vfsd_path},id=send") ps.exec(*ch_remote, "boot") ps.exec(*ch_remote, "info")