Skip to content

Commit

Permalink
Add ext driver for external VM machines
Browse files Browse the repository at this point in the history
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
  • Loading branch information
afbjorklund committed Nov 15, 2023
1 parent 32e6420 commit 64ec4ff
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/driverutil/driverutil.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package driverutil

import (
"github.com/lima-vm/lima/pkg/ext"

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Artifacts Darwin

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Integration tests

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Colima (v0.5.5)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (alpine.yaml)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (debian.yaml)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Unit tests (1.20.x)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (fedora.yaml)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Upgrade test (v0.15.1)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Upgrade test (v0.15.1)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Upgrade test (v0.15.1)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Unit tests (1.21.x)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (archlinux.yaml)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / VMNet test

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (opensuse.yaml)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / vz (experimental/vz.yaml)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (experimental/net-user-v2.yaml)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / vz (fedora.yaml)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:

Check failure on line 4 in pkg/driverutil/driverutil.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (docker.yaml)

no required module provides package github.com/lima-vm/lima/pkg/ext; to add it:
"github.com/lima-vm/lima/pkg/limayaml"
"github.com/lima-vm/lima/pkg/vz"
"github.com/lima-vm/lima/pkg/wsl2"
Expand All @@ -15,5 +16,8 @@ func Drivers() []string {
if wsl2.Enabled {
drivers = append(drivers, limayaml.WSL2)
}
if ext.Enabled {
drivers = append(drivers, limayaml.EXT)
}
return drivers
}
4 changes: 4 additions & 0 deletions pkg/driverutil/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package driverutil

import (
"github.com/lima-vm/lima/pkg/driver"
"github.com/lima-vm/lima/pkg/ext"
"github.com/lima-vm/lima/pkg/limayaml"
"github.com/lima-vm/lima/pkg/qemu"
"github.com/lima-vm/lima/pkg/vz"
Expand All @@ -16,5 +17,8 @@ func CreateTargetDriverInstance(base *driver.BaseDriver) driver.Driver {
if *limaDriver == limayaml.WSL2 {
return wsl2.New(base)
}
if *limaDriver == limayaml.EXT {
return ext.New(base)
}
return qemu.New(base)
}
2 changes: 2 additions & 0 deletions pkg/limayaml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,8 @@ func NewVMType(driver string) VMType {
return QEMU
case "wsl2":
return WSL2
case "ext":
return EXT
default:
logrus.Warnf("Unknown driver: %s", driver)
return driver
Expand Down
1 change: 1 addition & 0 deletions pkg/limayaml/limayaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const (
QEMU VMType = "qemu"
VZ VMType = "vz"
WSL2 VMType = "wsl2"
EXT VMType = "ext"
)

type Rosetta struct {
Expand Down
9 changes: 7 additions & 2 deletions pkg/limayaml/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ func Validate(y LimaYAML, warn bool) error {
if !IsNativeArch(*y.Arch) {
return fmt.Errorf("field `arch` must be %q for VZ; got %q", NewArch(runtime.GOARCH), *y.Arch)
}
case EXT:
// NOP
default:
return fmt.Errorf("field `vmType` must be %q, %q, %q; got %q", QEMU, VZ, WSL2, *y.VMType)
return fmt.Errorf("field `vmType` must be %q, %q, %q, %q; got %q", QEMU, VZ, WSL2, EXT, *y.VMType)
}

if len(y.Images) == 0 {
if len(y.Images) == 0 && *y.VMType != EXT {
return errors.New("field `images` must be set")
}
for i, f := range y.Images {
Expand Down Expand Up @@ -153,6 +155,9 @@ func Validate(y LimaYAML, warn bool) error {
}
}

if *y.SSH.Address == "127.0.0.1" && *y.VMType == EXT {
return errors.New("field `ssh.address` must be set, for ext")
}
if y.SSH.Address != nil {
if err := validateHost("ssh.address", *y.SSH.Address); err != nil {
return err
Expand Down
8 changes: 8 additions & 0 deletions pkg/store/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ func inspectStatusWithPIDFiles(instDir string, inst *Instance, y *limayaml.LimaY
inst.Status = StatusBroken
inst.Errors = append(inst.Errors, err)
}
if *y.VMType == limayaml.EXT {
if inst.HostAgentPID > 0 {
inst.Status = StatusRunning
} else if inst.HostAgentPID == 0 {
inst.Status = StatusStopped
}
return
}

if inst.Status == StatusUnknown {
if inst.HostAgentPID > 0 && inst.DriverPID > 0 {
Expand Down

0 comments on commit 64ec4ff

Please sign in to comment.