]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Move run_ssh() to run_qemu() 1745/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 6 Aug 2023 10:17:22 +0000 (12:17 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 6 Aug 2023 10:45:13 +0000 (12:45 +0200)
The ssh verb only works when the machine is booted with qemu so they
belong together.

mkosi/__init__.py
mkosi/qemu.py

index 39f51ee2f5cf507840e715406961f4456d3974d5..a959cc74396cab41f475b9adef6c7f19908d62be 100644 (file)
@@ -41,7 +41,7 @@ from mkosi.log import complete_step, die, log_step
 from mkosi.manifest import Manifest
 from mkosi.mounts import mount_overlay, mount_passwd, mount_tools
 from mkosi.pager import page
-from mkosi.qemu import copy_ephemeral, machine_cid, run_qemu
+from mkosi.qemu import copy_ephemeral, run_qemu, run_ssh
 from mkosi.run import become_root, bwrap, chroot_cmd, init_mount_namespace, run
 from mkosi.state import MkosiState
 from mkosi.tree import copy_tree, install_tree, move_tree, rmtree
@@ -1579,22 +1579,6 @@ def run_shell(args: MkosiArgs, config: MkosiConfig) -> None:
         run(cmdline, stdin=sys.stdin, stdout=sys.stdout, env=os.environ, log=False)
 
 
-def run_ssh(args: MkosiArgs, config: MkosiConfig) -> None:
-    cmd = [
-        "ssh",
-        # Silence known hosts file errors/warnings.
-        "-o", "UserKnownHostsFile=/dev/null",
-        "-o", "StrictHostKeyChecking=no",
-        "-o", "LogLevel=ERROR",
-        "-o", f"ProxyCommand=socat - VSOCK-CONNECT:{machine_cid(config)}:%p",
-        "root@mkosi",
-    ]
-
-    cmd += args.cmdline
-
-    run(cmd, stdin=sys.stdin, stdout=sys.stdout, env=os.environ, log=False)
-
-
 def run_serve(config: MkosiConfig) -> None:
     """Serve the output directory via a tiny embedded HTTP server"""
 
index a80aa2dd43df2c975c3294f3f644e206bf485774..1bae0e606a1255b66c436e64b48624bb12516a92 100644 (file)
@@ -316,3 +316,19 @@ def run_qemu(args: MkosiArgs, config: MkosiConfig) -> None:
 
     if status := int(notifications.get("EXIT_STATUS", 0)):
         raise subprocess.CalledProcessError(status, cmdline)
+
+
+def run_ssh(args: MkosiArgs, config: MkosiConfig) -> None:
+    cmd = [
+        "ssh",
+        # Silence known hosts file errors/warnings.
+        "-o", "UserKnownHostsFile=/dev/null",
+        "-o", "StrictHostKeyChecking=no",
+        "-o", "LogLevel=ERROR",
+        "-o", f"ProxyCommand=socat - VSOCK-CONNECT:{machine_cid(config)}:%p",
+        "root@mkosi",
+    ]
+
+    cmd += args.cmdline
+
+    run(cmd, stdin=sys.stdin, stdout=sys.stdout, env=os.environ, log=False)