diff --git a/README.md b/README.md index de1fa0b97dd..908262db034 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,7 @@ Host * !127.0.0.1 ### "Hints for debugging other problems?" - Inspect logs: - `limactl --debug start` + - `$HOME/.lima//serial.log` - `/var/log/cloud-init-output.log` (inside the guest) - `/var/log/cloud-init.log` (inside the guest) - Make sure that you aren't mixing up tabs and spaces in the YAML. diff --git a/docs/internal.md b/docs/internal.md index 4f5e138eb1d..f8d903511b0 100644 --- a/docs/internal.md +++ b/docs/internal.md @@ -11,3 +11,5 @@ An instance directory contains the following files: - `qemu-pid`: PID of the QEMU - `ssh.sock`: SSH control master socket - `ga.sock`: Forwarded to `/run/user/$UID/lima-guestagent.sock` +- `serial.log`: QEMU serial log, for debugging +- `serial.sock`: QEMU serial socket, for debugging (Usage: `socat -,echo=0,icanon=0 unix-connect:serial.sock`) diff --git a/pkg/limayaml/default.TEMPLATE.yaml b/pkg/limayaml/default.TEMPLATE.yaml index ae6932d7d40..d7121cf92ab 100644 --- a/pkg/limayaml/default.TEMPLATE.yaml +++ b/pkg/limayaml/default.TEMPLATE.yaml @@ -51,6 +51,13 @@ firmware: # Default: false legacyBIOS: false +video: + # QEMU display, e.g., "none", "cocoa", "sdl". + # As of QEMU v5.2, enabling this is known to have negative impact + # on performance on macOS hosts: https://gitlab.com/qemu-project/qemu/-/issues/334 + # Default: "none" + display: "none" + #UNIMPLEMENTED| provision: #UNIMPLEMENTED| # `system` is executed with the root privilege #UNIMPLEMENTED| system: | diff --git a/pkg/limayaml/defaults.go b/pkg/limayaml/defaults.go index 65aee20655d..898e51daa1b 100644 --- a/pkg/limayaml/defaults.go +++ b/pkg/limayaml/defaults.go @@ -19,6 +19,10 @@ func FillDefault(y *LimaYAML) { if y.Disk == "" { y.Disk = "100GiB" } + + if y.Video.Display == "" { + y.Video.Display = "none" + } } func resolveArch(s string) Arch { diff --git a/pkg/limayaml/limayaml.go b/pkg/limayaml/limayaml.go index b6c7db88f4a..e13781f7f2f 100644 --- a/pkg/limayaml/limayaml.go +++ b/pkg/limayaml/limayaml.go @@ -9,6 +9,7 @@ type LimaYAML struct { Mounts []Mount `yaml:"mounts,omitempty"` SSH SSH `yaml:"ssh,omitempty"` // REQUIRED (FIXME) Firmware Firmware `yaml:"firmware,omitempty"` + Video Video `yaml:"video,omitempty"` } type Arch = string @@ -37,3 +38,8 @@ type Firmware struct { // LegacyBIOS is ignored for aarch64. LegacyBIOS bool `yaml:"legacyBIOS,omitempty"` } + +type Video struct { + // Display is a QEMU display string + Display string `yaml:"display,omitempty"` +} diff --git a/pkg/qemu/qemu.go b/pkg/qemu/qemu.go index d7c96eaf39f..c13268073f1 100644 --- a/pkg/qemu/qemu.go +++ b/pkg/qemu/qemu.go @@ -144,7 +144,10 @@ func Cmdline(cfg Config) (string, []string, error) { // virtio-rng-pci acceralates starting up the OS, according to https://wiki.gentoo.org/wiki/QEMU/Options args = append(args, "-device", "virtio-rng-pci") - // Misc devices + // Graphics + if y.Video.Display != "" { + args = append(args, "-display", y.Video.Display) + } switch y.Arch { case limayaml.X8664: args = append(args, "-device", "virtio-vga") @@ -157,8 +160,23 @@ func Cmdline(cfg Config) (string, []string, error) { args = append(args, "-device", "usb-kbd") args = append(args, "-device", "usb-mouse") } + + // Parallel args = append(args, "-parallel", "none") + // Serial + serialSock := filepath.Join(cfg.InstanceDir, "serial.sock") + if err := os.RemoveAll(serialSock); err != nil { + return "", nil, err + } + serialLog := filepath.Join(cfg.InstanceDir, "serial.log") + if err := os.RemoveAll(serialLog); err != nil { + return "", nil, err + } + const serialChardev = "char-serial" + args = append(args, "-chardev", fmt.Sprintf("socket,id=%s,path=%s,server,nowait,logfile=%s", serialChardev, serialSock, serialLog)) + args = append(args, "-serial", "chardev:"+serialChardev) + // We also want to enable vsock and virtfs here, but QEMU does not support vsock and virtfs for macOS hosts // QEMU process diff --git a/pkg/start/start.go b/pkg/start/start.go index 396082a0c88..b018e0d7d86 100644 --- a/pkg/start/start.go +++ b/pkg/start/start.go @@ -35,7 +35,7 @@ func Start(ctx context.Context, instName, instDir string, y *limayaml.LimaYAML) qCmd := exec.CommandContext(ctx, qExe, qArgs...) qCmd.Stdout = os.Stdout qCmd.Stderr = os.Stderr - logrus.Info("Starting QEMU") + logrus.Infof("Starting QEMU (hint: to watch the boot progress, see %q)", filepath.Join(instDir, "serial.log")) logrus.Debugf("qCmd.Args: %v", qCmd.Args) if err := qCmd.Start(); err != nil { return err