Commit 5857730c authored by Will Deacon's avatar Will Deacon
Browse files

builtin-run: Pass console= parameter based on active console

x86 already does this in the backend, but doing it in the generic code
means that it is possible to boot a defconfig arm64 kernel under kvmtool
without having to specify any additional parameters at all.

Signed-off-by: default avatarWill Deacon <>
parent 83042d1e
......@@ -454,6 +454,7 @@ static struct kvm *kvm_cmd_run_init(int argc, const char **argv)
static char real_cmdline[2048], default_name[20];
unsigned int nr_online_cpus;
struct kvm *kvm = kvm__new();
bool video;
if (IS_ERR(kvm))
return kvm;
......@@ -536,6 +537,8 @@ static struct kvm *kvm_cmd_run_init(int argc, const char **argv)
if (!kvm->cfg.console)
kvm->cfg.console = DEFAULT_CONSOLE;
video = kvm->cfg.vnc || kvm->cfg.sdl || kvm->cfg.gtk;
if (!strncmp(kvm->cfg.console, "virtio", 6))
kvm->cfg.active_console = CONSOLE_VIRTIO;
else if (!strncmp(kvm->cfg.console, "serial", 6))
......@@ -564,7 +567,22 @@ static struct kvm *kvm_cmd_run_init(int argc, const char **argv)
memset(real_cmdline, 0, sizeof(real_cmdline));
kvm__arch_set_cmdline(real_cmdline, kvm->cfg.vnc || kvm->cfg.sdl || kvm->cfg.gtk);
kvm__arch_set_cmdline(real_cmdline, video);
if (video) {
strcat(real_cmdline, "console=tty0");
} else {
switch (kvm->cfg.active_console) {
/* Fallthrough */
strcat(real_cmdline, "console=hvc0");
case CONSOLE_8250:
strcat(real_cmdline, "console=ttyS0");
if (!kvm->cfg.guest_name) {
if (kvm->cfg.custom_rootfs) {
......@@ -124,9 +124,9 @@ void kvm__arch_set_cmdline(char *cmdline, bool video)
strcpy(cmdline, "noapic noacpi pci=conf1 reboot=k panic=1 "
"i8042.dumbkbd=1 i8042.nopnp=1");
if (video)
strcat(cmdline, " video=vesafb console=tty0");
strcat(cmdline, " video=vesafb");
strcat(cmdline, " console=ttyS0 earlyprintk=serial i8042.noaux=1");
strcat(cmdline, " earlyprintk=serial i8042.noaux=1");
/* Architecture-specific KVM init */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment