Skip to content

Commit 57664bb

Browse files
authored
Merge pull request #1703 from AkihiroSuda/workaround-1701
qemu: armv7l, aarch64: add pci-serial
2 parents d4c0da7 + 5bac4c5 commit 57664bb

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

docs/internal.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ VZ:
5151
- `vz-efi`: EFIVariable store file for a VM
5252

5353
Serial:
54-
- `serial.log`: legacy serial log (QEMU only), for debugging
55-
- `serial.sock`: legacy serial socket (QEMU only), for debugging (Usage: `socat -,echo=0,icanon=0 unix-connect:serial.sock`)
54+
- `serial.log`: default serial log (QEMU only), for debugging
55+
- `serial.sock`: default serial socket (QEMU only), for debugging (Usage: `socat -,echo=0,icanon=0 unix-connect:serial.sock`)
56+
- `serialp.log`: PCI serial log (QEMU (ARM) only), for debugging
57+
- `serialp.sock`: PCI serial socket (QEMU (ARM) only), for debugging (Usage: `socat -,echo=0,icanon=0 unix-connect:serialp.sock`)
5658
- `serialv.log`: virtio serial log, for debugging
5759
- `serialv.sock`: virtio serial socket (QEMU only), for debugging (Usage: `socat -,echo=0,icanon=0 unix-connect:serialv.sock`)
5860

examples/experimental/armv7l.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This example requires Lima v0.7.0 or later.
1+
# This example requires Lima v0.17.0 or later.
22

33
arch: "armv7l"
44
images:
@@ -15,6 +15,7 @@ mounts:
1515
- location: "~"
1616
- location: "/tmp/lima"
1717
writable: true
18+
mountType: "9p"
1819

1920
# We do not have arm-v7 binaries of containerd
2021
containerd:

pkg/qemu/qemu.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -789,24 +789,19 @@ func Cmdline(cfg Config) (string, []string, error) {
789789
args = append(args, "-device", "virtio-keyboard-pci")
790790
args = append(args, "-device", "virtio-mouse-pci")
791791
args = append(args, "-device", "qemu-xhci,id=usb-bus")
792-
case limayaml.AARCH64:
793-
// QEMU does not seem to support virtio-vga for aarch64
792+
case limayaml.AARCH64, limayaml.ARMV7L:
793+
// QEMU does not seem to support virtio-vga for aarch64 and arm
794794
args = append(args, "-vga", "none", "-device", "ramfb")
795795
args = append(args, "-device", "qemu-xhci,id=usb-bus")
796796
args = append(args, "-device", "usb-kbd,bus=usb-bus.0")
797797
args = append(args, "-device", "usb-mouse,bus=usb-bus.0")
798-
case limayaml.ARMV7L:
799-
// QEMU does not seem to support virtio-vga for arm
800-
args = append(args, "-vga", "cirrus", "-device", "cirrus-vga")
801-
args = append(args, "-device", "qemu-xhci,id=usb-bus")
802-
args = append(args, "-device", "usb-kbd,bus=usb-bus.0")
803-
args = append(args, "-device", "usb-mouse,bus=usb-bus.0")
804798
}
805799

806800
// Parallel
807801
args = append(args, "-parallel", "none")
808802

809-
// Serial (legacy)
803+
// Serial (default)
804+
// This is ttyS0 for Intel and RISC-V, ttyAMA0 for ARM.
810805
serialSock := filepath.Join(cfg.InstanceDir, filenames.SerialSock)
811806
if err := os.RemoveAll(serialSock); err != nil {
812807
return "", nil, err
@@ -819,6 +814,24 @@ func Cmdline(cfg Config) (string, []string, error) {
819814
args = append(args, "-chardev", fmt.Sprintf("socket,id=%s,path=%s,server=on,wait=off,logfile=%s", serialChardev, serialSock, serialLog))
820815
args = append(args, "-serial", "chardev:"+serialChardev)
821816

817+
// Serial (PCI, ARM only)
818+
// On ARM, the default serial is ttyAMA0, this PCI serial is ttyS0.
819+
// https://gitlab.com/qemu-project/qemu/-/issues/1801#note_1494720586
820+
switch *y.Arch {
821+
case limayaml.AARCH64, limayaml.ARMV7L:
822+
serialpSock := filepath.Join(cfg.InstanceDir, filenames.SerialPCISock)
823+
if err := os.RemoveAll(serialpSock); err != nil {
824+
return "", nil, err
825+
}
826+
serialpLog := filepath.Join(cfg.InstanceDir, filenames.SerialPCILog)
827+
if err := os.RemoveAll(serialpLog); err != nil {
828+
return "", nil, err
829+
}
830+
const serialpChardev = "char-serial-pci"
831+
args = append(args, "-chardev", fmt.Sprintf("socket,id=%s,path=%s,server=on,wait=off,logfile=%s", serialpChardev, serialpSock, serialpLog))
832+
args = append(args, "-device", "pci-serial,chardev="+serialpChardev)
833+
}
834+
822835
// Serial (virtio)
823836
serialvSock := filepath.Join(cfg.InstanceDir, filenames.SerialVirtioSock)
824837
if err := os.RemoveAll(serialvSock); err != nil {

pkg/store/filenames/filenames.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ const (
3434
KernelCmdline = "kernel.cmdline"
3535
Initrd = "initrd"
3636
QMPSock = "qmp.sock"
37-
SerialLog = "serial.log" // legacy
37+
SerialLog = "serial.log" // default serial (ttyS0, but ttyAMA0 on qemu-system-{arm,aarch64})
3838
SerialSock = "serial.sock"
39+
SerialPCILog = "serialp.log" // pci serial (ttyS0 on qemu-system-{arm,aarch64})
40+
SerialPCISock = "serialp.sock"
3941
SerialVirtioLog = "serialv.log" // virtio serial
4042
SerialVirtioSock = "serialv.sock"
4143
SSHSock = "ssh.sock"

0 commit comments

Comments
 (0)