Skip to content

Commit

Permalink
disable video display by default
Browse files Browse the repository at this point in the history
As of QEMU v5.2, enabling video display has negative impact due to macOS
App Nap: https://gitlab.com/qemu-project/qemu/-/issues/334

Close #29

Signed-off-by: Akihiro Suda <[email protected]>
  • Loading branch information
AkihiroSuda committed May 21, 2021
1 parent 9a2939f commit 41ae555
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ Host * !127.0.0.1
### "Hints for debugging other problems?"
- Inspect logs:
- `limactl --debug start`
- `$HOME/.lima/<INSTANCE>/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.
Expand Down
2 changes: 2 additions & 0 deletions docs/internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
7 changes: 7 additions & 0 deletions pkg/limayaml/default.TEMPLATE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 4 additions & 0 deletions pkg/limayaml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions pkg/limayaml/limayaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"`
}
20 changes: 19 additions & 1 deletion pkg/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41ae555

Please sign in to comment.