Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement feature toggle for GA forwarding mode in QEMU #3255

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/hostagent/hostagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ func New(instName string, stdout io.Writer, signalCh chan os.Signal, opts ...Opt
}
vSockPort = port
} else if *inst.Config.VMType == limayaml.QEMU {
// virtserialport doesn't seem to work reliably: https://github.com/lima-vm/lima/issues/2064
virtioPort = "" // filenames.VirtioPort
if *inst.Config.VMOpts.QEMU.VirtioGA {
virtioPort = filenames.VirtioPort
}
}

if err := cidata.GenerateCloudConfig(inst.Dir, instName, inst.Config); err != nil {
Expand Down
11 changes: 11 additions & 0 deletions pkg/limayaml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,17 @@ func FillDefault(y, d, o *LimaYAML, filePath string, warn bool) {
caCerts := unique(append(append(d.CACertificates.Certs, y.CACertificates.Certs...), o.CACertificates.Certs...))
y.CACertificates.Certs = caCerts

if y.VMOpts.QEMU.VirtioGA == nil {
y.VMOpts.QEMU.VirtioGA = d.VMOpts.QEMU.VirtioGA
}
if o.VMOpts.QEMU.VirtioGA != nil {
y.VMOpts.QEMU.VirtioGA = o.VMOpts.QEMU.VirtioGA
}
if y.VMOpts.QEMU.VirtioGA == nil {
// virtserialport doesn't seem to work reliably, so, default to false: https://github.com/lima-vm/lima/issues/2064
y.VMOpts.QEMU.VirtioGA = ptr.Of(false)
}

if runtime.GOOS == "darwin" && IsNativeArch(AARCH64) {
if y.Rosetta.Enabled == nil {
y.Rosetta.Enabled = d.Rosetta.Enabled
Expand Down
1 change: 1 addition & 0 deletions pkg/limayaml/limayaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type VMOpts struct {

type QEMUOpts struct {
MinimumVersion *string `yaml:"minimumVersion,omitempty" json:"minimumVersion,omitempty" jsonschema:"nullable"`
VirtioGA *bool `yaml:"virtioGA,omitempty" json:"virtioGA,omitempty" jsonschema:"nullable"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be guestAgentTransportType *string ?
Also, this may potentially apply to non-QEMU VM drivers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! I will check if this could be applicable for other platforms. Having it as typed option instead of boolean flag feels like a better design.

}

type Rosetta struct {
Expand Down
13 changes: 8 additions & 5 deletions pkg/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Config struct {
InstanceDir string
LimaYAML *limayaml.LimaYAML
SSHLocalPort int
VirtioGA bool
}

// MinimumQemuVersion is the minimum supported QEMU version.
Expand Down Expand Up @@ -920,11 +921,13 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
args = append(args, "-chardev", fmt.Sprintf("socket,id=%s,path=%s,server=on,wait=off", qmpChardev, qmpSock))
args = append(args, "-qmp", "chardev:"+qmpChardev)

// Guest agent via serialport
guestSock := filepath.Join(cfg.InstanceDir, filenames.GuestAgentSock)
args = append(args, "-chardev", fmt.Sprintf("socket,path=%s,server=on,wait=off,id=qga0", guestSock))
args = append(args, "-device", "virtio-serial")
args = append(args, "-device", "virtserialport,chardev=qga0,name="+filenames.VirtioPort)
if cfg.VirtioGA {
// Guest agent via serialport
guestSock := filepath.Join(cfg.InstanceDir, filenames.GuestAgentSock)
args = append(args, "-chardev", fmt.Sprintf("socket,path=%s,server=on,wait=off,id=qga0", guestSock))
args = append(args, "-device", "virtio-serial")
args = append(args, "-device", "virtserialport,chardev=qga0,name="+filenames.VirtioPort)
}

// QEMU process
args = append(args, "-name", "lima-"+cfg.Name)
Expand Down
1 change: 1 addition & 0 deletions pkg/qemu/qemu_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func (l *LimaQemuDriver) Start(ctx context.Context) (chan error, error) {
InstanceDir: l.Instance.Dir,
LimaYAML: l.Instance.Config,
SSHLocalPort: l.SSHLocalPort,
VirtioGA: *l.Instance.Config.VMOpts.QEMU.VirtioGA,
}
qExe, qArgs, err := Cmdline(ctx, qCfg)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions templates/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@
# Will be ignored if the vmType is not "qemu"
# 🟢 Builtin default: not set
minimumVersion: null
# Enable virtio port for GA. If disabled then will forward GA via SSH.
# Will be ignored if the vmType is not "qemu"
# 🟢 Builtin default: false
virtioGA : null

Check failure on line 310 in templates/default.yaml

View workflow job for this annotation

GitHub Actions / Lints

310:13 [colons] too many spaces before colon

# OS: "Linux".
# 🟢 Builtin default: "Linux"
Expand Down
Loading