mirror of
https://github.com/systemd/systemd.git
synced 2026-07-25 08:45:56 +00:00
vmspawn: Switch to virtconsole for headless console
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.
This commit is contained in:
@@ -22,16 +22,6 @@
|
||||
# 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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user