]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
vmspawn: Switch to virtconsole for headless console 35836/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 3 Jan 2025 10:14:44 +0000 (11:14 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 3 Jan 2025 10:16:16 +0000 (11:16 +0100)
virtconsole is the modern way to set up a headless serial connection
to a virtual machine so let's make use of it instead of -serial. This
also allows us to get rid of the per architecture serial console device
names and makes vmspawn more consistent with mkosi qemu which already uses
virtconsole.

src/vmspawn/vmspawn-util.h
src/vmspawn/vmspawn.c

index 76969abcf118bdbc7b7d4e9203c7185e46208586..66c1397ceb5310a6ea8680434e16ff474519dce8 100644 (file)
 #  define ARCHITECTURE_SUPPORTS_SMM 0
 #endif
 
-#if defined(__arm__) || defined(__aarch64__)
-#  define DEFAULT_SERIAL_TTY "ttyAMA0"
-#elif defined(__s390__) || defined(__s390x__)
-#  define DEFAULT_SERIAL_TTY "ttysclp0"
-#elif defined(__powerpc__) || defined(__powerpc64__)
-#  define DEFAULT_SERIAL_TTY "hvc0"
-#else
-#  define DEFAULT_SERIAL_TTY "ttyS0"
-#endif
-
 #if defined(__x86_64__) || defined(__i386__)
 #  define QEMU_MACHINE_TYPE "q35"
 #elif defined(__arm__) || defined(__aarch64__) || defined(__riscv) || defined(__loongarch64)
index 47c9093741f2be8ce16b5457b9269f6b7c6a73dd..00e040d963158b4751fb97fe554029d43a61782e 100644 (file)
@@ -1643,6 +1643,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
                                 &cmdline,
                                 "-nographic",
                                 "-nodefaults",
+                                "-device", "virtio-serial-pci,id=vmspawn-virtio-serial-pci",
                                 "-chardev") < 0)
                         return log_oom();
 
@@ -1652,7 +1653,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
 
                 r = strv_extend_many(
                                 &cmdline,
-                                "-serial", "chardev:console");
+                                "-device", "virtconsole,chardev=console");
                 break;
         }
 
@@ -1669,7 +1670,8 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
                                 "-nographic",
                                 "-nodefaults",
                                 "-chardev", "stdio,mux=on,id=console,signal=off",
-                                "-serial", "chardev:console",
+                                "-device", "virtio-serial-pci,id=vmspawn-virtio-serial-pci",
+                                "-device", "virtconsole,chardev=console",
                                 "-mon", "console");
                 break;
 
@@ -1821,7 +1823,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
                         return log_oom();
         }
 
-        r = strv_prepend(&arg_kernel_cmdline_extra, "console=" DEFAULT_SERIAL_TTY);
+        r = strv_prepend(&arg_kernel_cmdline_extra, "console=hvc0");
         if (r < 0)
                 return log_oom();