diff --git a/examples/docker.yml b/examples/docker.yml index 5e742c74a..ba6831e1d 100644 --- a/examples/docker.yml +++ b/examples/docker.yml @@ -1,6 +1,6 @@ kernel: image: linuxkit/kernel:4.9.40 - cmdline: "console=tty0 console=ttyS0" + cmdline: "console=tty0 console=ttyS0 console=ttyAMA0" init: - linuxkit/init:906e174b3f2e07f97d6fd693a2e8518e98dafa58 - linuxkit/runc:90e45f13e1d0a0983f36ef854621e3eac91cf541 diff --git a/examples/getty.yml b/examples/getty.yml index 42202ca84..6d1ead4ca 100644 --- a/examples/getty.yml +++ b/examples/getty.yml @@ -1,6 +1,6 @@ kernel: image: linuxkit/kernel:4.9.40 - cmdline: "console=tty0 console=ttyS0" + cmdline: "console=tty0 console=ttyS0 console=ttyAMA0" init: - linuxkit/init:906e174b3f2e07f97d6fd693a2e8518e98dafa58 - linuxkit/runc:90e45f13e1d0a0983f36ef854621e3eac91cf541 diff --git a/examples/minimal.yml b/examples/minimal.yml index ecad47b9c..cb8dbeaff 100644 --- a/examples/minimal.yml +++ b/examples/minimal.yml @@ -1,6 +1,6 @@ kernel: image: linuxkit/kernel:4.9.40 - cmdline: "console=tty0 console=ttyS0" + cmdline: "console=tty0 console=ttyS0 console=ttyAMA0" init: - linuxkit/init:906e174b3f2e07f97d6fd693a2e8518e98dafa58 - linuxkit/runc:90e45f13e1d0a0983f36ef854621e3eac91cf541 diff --git a/examples/redis-os.yml b/examples/redis-os.yml index c30cf772f..84dcb7708 100644 --- a/examples/redis-os.yml +++ b/examples/redis-os.yml @@ -2,7 +2,7 @@ # connect: nc localhost 6379 kernel: image: linuxkit/kernel:4.9.40 - cmdline: "console=tty0 console=ttyS0" + cmdline: "console=tty0 console=ttyS0 console=ttyAMA0" init: - linuxkit/init:906e174b3f2e07f97d6fd693a2e8518e98dafa58 - linuxkit/runc:90e45f13e1d0a0983f36ef854621e3eac91cf541 diff --git a/examples/sshd.yml b/examples/sshd.yml index ac94573a2..3219f60f7 100644 --- a/examples/sshd.yml +++ b/examples/sshd.yml @@ -1,6 +1,6 @@ kernel: image: linuxkit/kernel:4.9.40 - cmdline: "console=tty0 console=ttyS0" + cmdline: "console=tty0 console=ttyS0 console=ttyAMA0" init: - linuxkit/init:906e174b3f2e07f97d6fd693a2e8518e98dafa58 - linuxkit/runc:90e45f13e1d0a0983f36ef854621e3eac91cf541 diff --git a/examples/swap.yml b/examples/swap.yml index 973793d89..fb31ae47b 100644 --- a/examples/swap.yml +++ b/examples/swap.yml @@ -1,6 +1,6 @@ kernel: image: linuxkit/kernel:4.9.40 - cmdline: "console=tty0 console=ttyS0" + cmdline: "console=tty0 console=ttyS0 console=ttyAMA0" init: - linuxkit/init:906e174b3f2e07f97d6fd693a2e8518e98dafa58 - linuxkit/runc:90e45f13e1d0a0983f36ef854621e3eac91cf541 diff --git a/linuxkit.yml b/linuxkit.yml index 60ae3b40b..7dcf9e53c 100644 --- a/linuxkit.yml +++ b/linuxkit.yml @@ -1,6 +1,6 @@ kernel: image: linuxkit/kernel:4.9.40 - cmdline: "console=tty0 console=ttyS0" + cmdline: "console=tty0 console=ttyS0 console=ttyAMA0" init: - linuxkit/init:906e174b3f2e07f97d6fd693a2e8518e98dafa58 - linuxkit/runc:90e45f13e1d0a0983f36ef854621e3eac91cf541 diff --git a/src/cmd/linuxkit/run_qemu.go b/src/cmd/linuxkit/run_qemu.go index 26a08155d..0c4625570 100644 --- a/src/cmd/linuxkit/run_qemu.go +++ b/src/cmd/linuxkit/run_qemu.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strconv" "strings" @@ -54,6 +55,19 @@ const ( qemuNetworkingDefault = qemuNetworkingUser ) +var ( + defaultArch string +) + +func init() { + switch runtime.GOARCH { + case "arm64": + defaultArch = "aarch64" + case "amd64": + defaultArch = "x86_64" + } +} + func haveKVM() bool { _, err := os.Stat("/dev/kvm") return !os.IsNotExist(err) @@ -123,7 +137,7 @@ func runQemu(args []string) { // VM configuration enableKVM := flags.Bool("kvm", haveKVM(), "Enable KVM acceleration") - arch := flags.String("arch", "x86_64", "Type of architecture to use, e.g. x86_64, aarch64") + arch := flags.String("arch", defaultArch, "Type of architecture to use, e.g. x86_64, aarch64") cpus := flags.String("cpus", "1", "Number of CPUs") mem := flags.String("mem", "1024", "Amount of memory in MB") @@ -459,7 +473,11 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) { // Need to specify the vcpu type when running qemu on arm64 platform, for security reason, // the vcpu should be "host" instead of other names such as "cortex-a53"... if config.Arch == "aarch64" { - qemuArgs = append(qemuArgs, "-cpu", "host") + if runtime.GOARCH == "arm64" { + qemuArgs = append(qemuArgs, "-cpu", "host") + } else { + qemuArgs = append(qemuArgs, "-cpu", "cortex-a57") + } } if config.KVM {