Skip to content

Commit 702261b

Browse files
authored
Merge pull request #1147 from balajiv113/driver
Support for Virtualization.Framework for macOS 13
2 parents 75f649c + 2679326 commit 702261b

34 files changed

+1913
-235
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ binaries: clean \
3030
_output/bin/lima \
3131
_output/bin/lima$(bat) \
3232
_output/bin/limactl$(exe) \
33+
codesign \
3334
_output/bin/nerdctl.lima \
3435
_output/bin/apptainer.lima \
3536
_output/bin/docker.lima \
@@ -163,3 +164,9 @@ artifacts-misc:
163164
mkdir -p _artifacts
164165
go mod vendor
165166
$(TAR) -czf _artifacts/lima-$(VERSION_TRIMMED)-go-mod-vendor.tar.gz go.mod go.sum vendor
167+
168+
.PHONY: codesign
169+
codesign:
170+
ifeq ($(GOOS),darwin)
171+
codesign --entitlements vz.entitlements -s - ./_output/bin/limactl
172+
endif

cmd/limactl/stop.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func stopInstanceGracefully(inst *store.Instance) error {
6969
logrus.Error(err)
7070
}
7171

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

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

106106
func stopInstanceForcibly(inst *store.Instance) {
107107
if inst.QemuPID > 0 {
108-
logrus.Infof("Sending SIGKILL to the QEMU process %d", inst.QemuPID)
108+
logrus.Infof("Sending SIGKILL to the %s driver process %d", inst.VMType, inst.QemuPID)
109109
if err := osutil.SysKill(inst.QemuPID, osutil.SigKill); err != nil {
110110
logrus.Error(err)
111111
}
112112
} else {
113-
logrus.Info("The QEMU process seems already stopped")
113+
logrus.Infof("The %s driver process seems already stopped", inst.VMType)
114114
}
115115

116116
for _, diskName := range inst.AdditionalDisks {

docs/internal.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ QEMU:
4747
- `serial.log`: QEMU serial log, for debugging
4848
- `serial.sock`: QEMU serial socket, for debugging (Usage: `socat -,echo=0,icanon=0 unix-connect:serial.sock`)
4949

50+
VZ:
51+
- `vz-identifier`: Unique machine identifier file for a VM
52+
- `vz-efi`: EFIVariable store file for a VM
53+
5054
SSH:
5155
- `ssh.sock`: SSH control master socket
5256

docs/mount.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,20 @@ The "9p" mount type requires Lima v0.10.0 or later.
7979

8080
#### Caveats
8181
- 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`.
82+
83+
### virtiofs
84+
The "virtiofs" mount type is implemented by using apple Virtualization.Framework shared directory (uses virtio-fs) device.
85+
Linux guest kernel must enable the CONFIG_VIRTIO_FS support for this support.
86+
87+
An example configuration:
88+
```yaml
89+
vmType: "vz"
90+
mountType: "virtiofs"
91+
mounts:
92+
- location: "~"
93+
```
94+
95+
The "vz" mount type requires Lima v0.14.0 or later.
96+
97+
#### Caveats
98+
- The "virtiofs" mount type is supported only on macOS 13 or above with `vmType: vz` config.

docs/vmtype.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# vmType
2+
3+
Lima supports two ways of running guest machines:
4+
- [qemu](#qemu)
5+
- [vz](#vz)
6+
7+
## QEMU
8+
"qemu" option makes use of QEMU to run guest operating system.
9+
This option is used by default if "vmType" is not set.
10+
11+
## VZ
12+
"vz" option makes use of native virtualization support provided by macOS Virtualization.Framework.
13+
14+
An example configuration:
15+
```yaml
16+
# Example to run ubuntu using vmType: vz instead of qemu (Default)
17+
vmType: "vz"
18+
images:
19+
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img"
20+
arch: "x86_64"
21+
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-arm64.img"
22+
arch: "aarch64"
23+
mounts:
24+
- location: "~"
25+
mountType: "virtiofs"
26+
```
27+
28+
### Caveats
29+
- "vz" option is only supported on macOS 13 or above
30+
- Virtualization.framework doesn't support running "intel guest on arm" and vice versa
31+
32+
### Known Issues
33+
- "vz" doesn't support `legacyBoot: true` option, so guest machine like centos-stream, archlinux, oraclelinux will not work
34+
- Host to guest networking (`networks` section in lima yaml) is not supported
35+
- When running lima using "vz", `${LIMA_HOME}/<INSTANCE>/serial.log` will not contain kernel boot logs

examples/experimental/vz.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Example to run ubuntu using vmType: vz instead of qemu (Default)
2+
vmType: "vz"
3+
images:
4+
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img"
5+
arch: "x86_64"
6+
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-arm64.img"
7+
arch: "aarch64"
8+
9+
mounts:
10+
- location: "~"
11+
- location: "/tmp/lima"
12+
writable: true
13+
mountType: "virtiofs"

go.mod

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ go 1.19
44

55
require (
66
github.com/AlecAivazis/survey/v2 v2.3.6
7+
github.com/Code-Hex/vz/v3 v3.0.0
78
github.com/alessio/shellescape v1.4.1
89
github.com/cheggaaa/pb/v3 v3.1.0
910
github.com/containerd/containerd v1.6.10
1011
github.com/containerd/continuity v0.3.0
12+
github.com/containers/gvisor-tap-vsock v0.4.1-0.20220920072955-5b1aff8ba743
1113
github.com/coreos/go-semver v0.3.0
1214
github.com/cyphar/filepath-securejoin v0.2.3
1315
github.com/digitalocean/go-qemu v0.0.0-20210326154740-ac9e0b687001
@@ -31,40 +33,49 @@ require (
3133
github.com/spf13/cobra v1.6.1
3234
github.com/xorcare/pointer v1.2.2
3335
github.com/yalue/native_endian v1.0.2
36+
golang.org/x/sync v0.1.0
3437
golang.org/x/sys v0.2.0
3538
gotest.tools/v3 v3.4.0
3639
)
3740

3841
require (
3942
github.com/Microsoft/go-winio v0.5.2 // indirect
4043
github.com/VividCortex/ewma v1.1.1 // indirect
44+
github.com/apparentlymart/go-cidr v1.1.0 // indirect
4145
github.com/digitalocean/go-libvirt v0.0.0-20201209184759-e2a69bcd5bd1 // indirect
4246
github.com/fatih/color v1.13.0 // indirect
4347
github.com/fsnotify/fsnotify v1.5.1 // indirect
4448
github.com/golang/protobuf v1.5.2 // indirect
49+
github.com/google/btree v1.0.1 // indirect
50+
github.com/google/gopacket v1.1.19 // indirect
4551
github.com/hashicorp/errwrap v1.1.0 // indirect
4652
github.com/inconshreveable/mousetrap v1.0.1 // indirect
53+
github.com/insomniacslk/dhcp v0.0.0-20220504074936-1ca156eafb9f // indirect
4754
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
4855
github.com/kr/fs v0.1.0 // indirect
4956
github.com/mattn/go-colorable v0.1.12 // indirect
5057
github.com/mattn/go-runewidth v0.0.12 // indirect
5158
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
59+
github.com/pkg/errors v0.9.1 // indirect
5260
github.com/pkg/sftp v1.13.4 // indirect
5361
github.com/rivo/uniseg v0.2.0 // indirect
5462
github.com/spf13/pflag v1.0.5 // indirect
63+
github.com/u-root/uio v0.0.0-20210528114334-82958018845c // indirect
5564
go.uber.org/atomic v1.7.0 // indirect
5665
go.uber.org/multierr v1.7.0 // indirect
5766
golang.org/x/crypto v0.1.0 // indirect
5867
golang.org/x/mod v0.6.0 // indirect
5968
golang.org/x/net v0.1.0 // indirect
60-
golang.org/x/sync v0.1.0 // indirect
6169
golang.org/x/term v0.1.0 // indirect
6270
golang.org/x/text v0.4.0 // indirect
71+
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
6372
golang.org/x/tools v0.2.0 // indirect
6473
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
6574
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
6675
google.golang.org/grpc v1.47.0 // indirect
6776
google.golang.org/protobuf v1.28.0 // indirect
6877
gopkg.in/djherbis/times.v1 v1.2.0 // indirect
6978
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
79+
gvisor.dev/gvisor v0.0.0-20220908032458-edc830a43ba6 // indirect
80+
inet.af/tcpproxy v0.0.0-20220326234310-be3ee21c9fa0 // indirect
7081
)

0 commit comments

Comments
 (0)