aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2017-10-25 17:10:22 +0100
committerWill Deacon <will.deacon@arm.com>2017-10-25 17:10:22 +0100
commit5857730ceee5980e482807afc922e758cbeaa921 (patch)
tree65abb2c64dca98c79e0db5c2f5afe9c8d402e9f7
parent83042d1e6ce625d2fb80c3d2059e29c3d3c608fe (diff)
downloadkvmtool-5857730ceee5980e482807afc922e758cbeaa921.tar.gz
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: Will Deacon <will.deacon@arm.com>
-rw-r--r--builtin-run.c20
-rw-r--r--x86/kvm.c4
2 files changed, 21 insertions, 3 deletions
diff --git a/builtin-run.c b/builtin-run.c
index 72b878dc..7f3872dd 100644
--- a/builtin-run.c
+++ b/builtin-run.c
@@ -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)
kvm->cfg.network = DEFAULT_NETWORK;
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) {
+ case CONSOLE_HV:
+ /* Fallthrough */
+ case CONSOLE_VIRTIO:
+ strcat(real_cmdline, "console=hvc0");
+ break;
+ case CONSOLE_8250:
+ strcat(real_cmdline, "console=ttyS0");
+ break;
+ }
+ }
if (!kvm->cfg.guest_name) {
if (kvm->cfg.custom_rootfs) {
diff --git a/x86/kvm.c b/x86/kvm.c
index bfa04b81..d8751e9a 100644
--- a/x86/kvm.c
+++ b/x86/kvm.c
@@ -124,9 +124,9 @@ void kvm__arch_set_cmdline(char *cmdline, bool video)
strcpy(cmdline, "noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 "
"i8042.dumbkbd=1 i8042.nopnp=1");
if (video)
- strcat(cmdline, " video=vesafb console=tty0");
+ strcat(cmdline, " video=vesafb");
else
- strcat(cmdline, " console=ttyS0 earlyprintk=serial i8042.noaux=1");
+ strcat(cmdline, " earlyprintk=serial i8042.noaux=1");
}
/* Architecture-specific KVM init */