Skip to content

Commit

Permalink
Support for Virtualization.Framework driver
Browse files Browse the repository at this point in the history
added support for drivers to lima, migrated exiting qemu to drivers modal and support for apple virtualization.framework as new driver

Signed-off-by: Balaji Vijayakumar <[email protected]>
  • Loading branch information
balajiv113 committed Nov 15, 2022
1 parent 75f649c commit 2679326
Show file tree
Hide file tree
Showing 34 changed files with 1,913 additions and 235 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ binaries: clean \
_output/bin/lima \
_output/bin/lima$(bat) \
_output/bin/limactl$(exe) \
codesign \
_output/bin/nerdctl.lima \
_output/bin/apptainer.lima \
_output/bin/docker.lima \
Expand Down Expand Up @@ -163,3 +164,9 @@ artifacts-misc:
mkdir -p _artifacts
go mod vendor
$(TAR) -czf _artifacts/lima-$(VERSION_TRIMMED)-go-mod-vendor.tar.gz go.mod go.sum vendor

.PHONY: codesign
codesign:
ifeq ($(GOOS),darwin)
codesign --entitlements vz.entitlements -s - ./_output/bin/limactl
endif
6 changes: 3 additions & 3 deletions cmd/limactl/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func stopInstanceGracefully(inst *store.Instance) error {
logrus.Error(err)
}

logrus.Info("Waiting for the host agent and the qemu processes to shut down")
logrus.Info("Waiting for the host agent and the driver processes to shut down")
return waitForHostAgentTermination(context.TODO(), inst, begin)
}

Expand Down Expand Up @@ -105,12 +105,12 @@ func waitForHostAgentTermination(ctx context.Context, inst *store.Instance, begi

func stopInstanceForcibly(inst *store.Instance) {
if inst.QemuPID > 0 {
logrus.Infof("Sending SIGKILL to the QEMU process %d", inst.QemuPID)
logrus.Infof("Sending SIGKILL to the %s driver process %d", inst.VMType, inst.QemuPID)
if err := osutil.SysKill(inst.QemuPID, osutil.SigKill); err != nil {
logrus.Error(err)
}
} else {
logrus.Info("The QEMU process seems already stopped")
logrus.Infof("The %s driver process seems already stopped", inst.VMType)
}

for _, diskName := range inst.AdditionalDisks {
Expand Down
4 changes: 4 additions & 0 deletions docs/internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ QEMU:
- `serial.log`: QEMU serial log, for debugging
- `serial.sock`: QEMU serial socket, for debugging (Usage: `socat -,echo=0,icanon=0 unix-connect:serial.sock`)

VZ:
- `vz-identifier`: Unique machine identifier file for a VM
- `vz-efi`: EFIVariable store file for a VM

SSH:
- `ssh.sock`: SSH control master socket

Expand Down
17 changes: 17 additions & 0 deletions docs/mount.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,20 @@ The "9p" mount type requires Lima v0.10.0 or later.

#### Caveats
- The "9p" mount type is known to be incompatible with CentOS, Rocky Linux, and AlmaLinux as their kernel do not support `CONFIG_NET_9P_VIRTIO`.

### virtiofs
The "virtiofs" mount type is implemented by using apple Virtualization.Framework shared directory (uses virtio-fs) device.
Linux guest kernel must enable the CONFIG_VIRTIO_FS support for this support.

An example configuration:
```yaml
vmType: "vz"
mountType: "virtiofs"
mounts:
- location: "~"
```

The "vz" mount type requires Lima v0.14.0 or later.

#### Caveats
- The "virtiofs" mount type is supported only on macOS 13 or above with `vmType: vz` config.
35 changes: 35 additions & 0 deletions docs/vmtype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# vmType

Lima supports two ways of running guest machines:
- [qemu](#qemu)
- [vz](#vz)

## QEMU
"qemu" option makes use of QEMU to run guest operating system.
This option is used by default if "vmType" is not set.

## VZ
"vz" option makes use of native virtualization support provided by macOS Virtualization.Framework.

An example configuration:
```yaml
# Example to run ubuntu using vmType: vz instead of qemu (Default)
vmType: "vz"
images:
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-arm64.img"
arch: "aarch64"
mounts:
- location: "~"
mountType: "virtiofs"
```
### Caveats
- "vz" option is only supported on macOS 13 or above
- Virtualization.framework doesn't support running "intel guest on arm" and vice versa
### Known Issues
- "vz" doesn't support `legacyBoot: true` option, so guest machine like centos-stream, archlinux, oraclelinux will not work
- Host to guest networking (`networks` section in lima yaml) is not supported
- When running lima using "vz", `${LIMA_HOME}/<INSTANCE>/serial.log` will not contain kernel boot logs
13 changes: 13 additions & 0 deletions examples/experimental/vz.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Example to run ubuntu using vmType: vz instead of qemu (Default)
vmType: "vz"
images:
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-arm64.img"
arch: "aarch64"

mounts:
- location: "~"
- location: "/tmp/lima"
writable: true
mountType: "virtiofs"
13 changes: 12 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ go 1.19

require (
github.com/AlecAivazis/survey/v2 v2.3.6
github.com/Code-Hex/vz/v3 v3.0.0
github.com/alessio/shellescape v1.4.1
github.com/cheggaaa/pb/v3 v3.1.0
github.com/containerd/containerd v1.6.10
github.com/containerd/continuity v0.3.0
github.com/containers/gvisor-tap-vsock v0.4.1-0.20220920072955-5b1aff8ba743
github.com/coreos/go-semver v0.3.0
github.com/cyphar/filepath-securejoin v0.2.3
github.com/digitalocean/go-qemu v0.0.0-20210326154740-ac9e0b687001
Expand All @@ -31,40 +33,49 @@ require (
github.com/spf13/cobra v1.6.1
github.com/xorcare/pointer v1.2.2
github.com/yalue/native_endian v1.0.2
golang.org/x/sync v0.1.0
golang.org/x/sys v0.2.0
gotest.tools/v3 v3.4.0
)

require (
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/VividCortex/ewma v1.1.1 // indirect
github.com/apparentlymart/go-cidr v1.1.0 // indirect
github.com/digitalocean/go-libvirt v0.0.0-20201209184759-e2a69bcd5bd1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/insomniacslk/dhcp v0.0.0-20220504074936-1ca156eafb9f // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-runewidth v0.0.12 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/sftp v1.13.4 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/u-root/uio v0.0.0-20210528114334-82958018845c // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/term v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/tools v0.2.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/djherbis/times.v1 v1.2.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gvisor.dev/gvisor v0.0.0-20220908032458-edc830a43ba6 // indirect
inet.af/tcpproxy v0.0.0-20220326234310-be3ee21c9fa0 // indirect
)
Loading

0 comments on commit 2679326

Please sign in to comment.