Skip to content

Commit 6079a63

Browse files
feat: update lima to 2.0.3 (#844)
Signed-off-by: Swapnanil Gupta <swpnlg@amazon.com>
1 parent d4d4921 commit 6079a63

10 files changed

+138
-50
lines changed

.github/workflows/release.yaml renamed to .github/workflows/build-lima-and-qemu.yaml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: Build Lima & QEMU Bundle
22

33
# Runs every Tuesday at 9 am UTC
44
on:
@@ -9,7 +9,7 @@ on:
99
branches:
1010
- main
1111
paths:
12-
- .github/workflows/release.yaml
12+
- .github/workflows/build-lima-and-qemu.yaml
1313
- src/lima/**
1414
- deps/qemu.conf
1515
- bin/lima-and-qemu.py
@@ -68,13 +68,20 @@ jobs:
6868

6969
- name: Make and release deps
7070
run: |
71-
# (cd src/lima && git clean -f -d && git am ../patches/lima/*.patch)
7271
cd src/lima
72+
git clean -f -d
73+
git am ../patches/lima/*.patch
74+
7375
sudo make clean native install PREFIX=/opt/homebrew || exit 1
7476
echo "Installed limactl version: $(limactl --version)"
7577
7678
cd ../../
7779
python3 bin/lima-and-qemu.py
80+
if [ $? -ne 0 ]; then
81+
echo "Failed to create lima-and-qemu archive"
82+
exit 1
83+
fi
84+
7885
mv src/lima/lima-and-qemu.tar.gz src/lima/lima-and-qemu.macos-aarch64.tar.gz
7986
shell: zsh {0}
8087

@@ -150,13 +157,20 @@ jobs:
150157

151158
- name: Make and release deps
152159
run: |
153-
# (cd src/lima && git clean -f -d && git am ../patches/lima/*.patch)
154160
cd src/lima
155-
sudo make clean native install PREFIX=/opt/homebrew || exit 1
161+
git clean -f -d
162+
git am ../patches/lima/*.patch
163+
164+
sudo make clean native install PREFIX=/usr/local || exit 1
156165
echo "Installed limactl version: $(limactl --version)"
157166
158167
cd ../../
159168
python3 bin/lima-and-qemu.py
169+
if [ $? -ne 0 ]; then
170+
echo "Failed to create lima-and-qemu archive"
171+
exit 1
172+
fi
173+
160174
mv src/lima/lima-and-qemu.tar.gz src/lima/lima-and-qemu.macos-x86_64.tar.gz
161175
shell: zsh {0}
162176

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ Note that the vm instance is NOT expected to exist before running the tests, ple
4444

4545
### Maintaining QEMU Version
4646

47-
The version of QEMU that is shipped with finch is the same version that is installed on the GitHub action runners as part of the `release.yaml` workflow. The QEMU version that is installed (and therefore shipped) is configurable in the `deps/qemu.conf` file. We use homebrew to install QEMU on the runners and since homebrew updates its formula files in place, in order to pin a version of QEMU, we need to find a specific commit that corresponds to that version. To do that -
47+
The version of QEMU that is shipped with finch is the same version that is installed on the GitHub action runners as part of the `build-lima-and-qemu.yaml` workflow. The QEMU version that is installed (and therefore shipped) is configurable in the `deps/qemu.conf` file. We use homebrew to install QEMU on the runners and since homebrew updates its formula files in place, in order to pin a version of QEMU, we need to find a specific commit that corresponds to that version. To do that -
4848

4949
- Go to https://github.com/Homebrew/homebrew-core/commits/main/Formula/q/qemu.rb
5050
- Find the commit for the specific version. For example - `6dd3cf36c974c9a69df5d2b0e5d3f4de3df30e77` for version `10.1.0`.
5151
- Replace `QEMU_VERSION` and `QEMU_FORMULA_GH_COMMIT` with the appropriate values in the `deps/qemu.conf` file.
52-
- Trigger the `release.yaml` or `Build` workflow.
52+
- Trigger the `build-lima-and-qemu.yaml` or `Build` workflow.
5353

5454
**NOTE:** This version of QEMU is **not** the same as the version of QEMU that is installed inside the Finch VM. This is the QEMU version that will be used by Finch to launch the Finch VM when `vmType=qemu` is specified in `finch.yaml` configuration file.

bin/lima-and-qemu.py

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import shutil
77
import re
88
import tarfile
9+
import gzip
910
import json
1011
from enum import Enum
1112
from collections import defaultdict
@@ -33,6 +34,9 @@ def main():
3334

3435
qemu_version = get_installed_qemu_version()
3536
print("using qemu version: ", qemu_version)
37+
38+
lima_version = get_installed_lima_version()
39+
print("using lima version: ", lima_version)
3640

3741
print("recording initial deps...")
3842
deps = record_initial_deps(arch, install_dir, qemu_version)
@@ -64,15 +68,21 @@ def main():
6468
extract_and_export_package_versions(deps, arch, install_dir)
6569

6670
print("Packaging files and socket_vmnet...")
67-
package_files_and_socket_vmnet(deps, install_dir, dist_path)
71+
archive_path = package_files_and_socket_vmnet(deps, install_dir, dist_path)
72+
73+
print("adding lima version info to built archive...")
74+
add_lima_version_to_archive(archive_path, lima_version)
75+
76+
print("compressing archive...")
77+
compress_archive(archive_path)
6878

6979
print("Cleaning up...")
7080
cleanup()
7181

7282
print("Done")
7383

7484
def get_templates_from_args():
75-
default_templates = ["alpine", "default"]
85+
default_templates = ["fedora-42", "default"]
7686
return sys.argv[1:] if len(sys.argv) > 1 else default_templates
7787

7888
def get_system_arch():
@@ -84,6 +94,16 @@ def get_system_arch():
8494
def get_installation_dir(arch: Literal[Arch.X86_64, Arch.AARCH64]):
8595
return "/usr/local" if arch == Arch.X86_64 else "/opt/homebrew"
8696

97+
def get_installed_lima_version():
98+
try:
99+
res = subprocess.check_output("limactl --version", shell=True, text=True)
100+
lima_version = res.replace("limactl version", "").strip()
101+
if not lima_version:
102+
raise RuntimeError("failed to get installed lima version")
103+
return lima_version
104+
except Exception as ex:
105+
raise RuntimeError("failed to get installed lima version") from ex
106+
87107
def get_installed_qemu_version():
88108
try:
89109
res = subprocess.check_output("brew list --versions qemu", shell=True, text=True)
@@ -223,6 +243,35 @@ def resign(resign_files: Set[str]):
223243
except Exception as ex:
224244
raise RuntimeError(f"failed to resign {file_path}") from ex
225245

246+
def compress_archive(archive_path: str):
247+
if not os.path.exists(archive_path):
248+
raise RuntimeError("{archive_path} does not exist")
249+
250+
try:
251+
lima_repo_root = os.path.join(os.getcwd(), 'src', 'lima')
252+
compressed_tarball_path = f"{lima_repo_root}/lima-and-qemu.tar.gz"
253+
if os.path.exists(compressed_tarball_path):
254+
os.unlink(compressed_tarball_path)
255+
with open(archive_path, "rb") as f_in, gzip.open(compressed_tarball_path, "wb") as f_out:
256+
shutil.copyfileobj(f_in, f_out)
257+
except Exception as ex:
258+
raise RuntimeError("failed to compress archive {archive_path}") from ex
259+
260+
def add_lima_version_to_archive(archive_path: str, lima_version: str):
261+
try:
262+
if not os.path.exists(archive_path):
263+
raise RuntimeError(f"archive {archive_path} does not exist")
264+
265+
with open("LIMA_VERSION", "w") as f:
266+
f.write(lima_version)
267+
print(f"Created LIMA_VERSION file with content: {lima_version}")
268+
269+
with tarfile.open(archive_path, "a" ) as tar:
270+
tar.add("LIMA_VERSION", arcname="LIMA_VERSION")
271+
print(f"Added LIMA_VERSION file to archive {archive_path}")
272+
except Exception as ex:
273+
raise RuntimeError("failed to add LIMA_VERSION to archive") from ex
274+
226275
def package_files_and_socket_vmnet(deps: Dict[str, str], install_dir: str, dist_path: str):
227276
tar_files = [path.removeprefix(f"{install_dir}/") for path in deps.keys()]
228277

@@ -249,13 +298,14 @@ def package_files_and_socket_vmnet(deps: Dict[str, str], install_dir: str, dist_
249298

250299
try:
251300
lima_repo_root = os.path.join(os.getcwd(), 'src', 'lima')
252-
tarball_path = f"{lima_repo_root}/lima-and-qemu.tar.gz"
301+
tarball_path = f"{lima_repo_root}/lima-and-qemu.tar"
253302
if os.path.exists(tarball_path):
254303
os.unlink(tarball_path)
255-
with tarfile.open(tarball_path, "w:gz") as tar:
304+
with tarfile.open(tarball_path, "w") as tar:
256305
for file in tar_files:
257306
print(f"adding {dist_path}/{file} to tarball")
258307
tar.add(f"{dist_path}/{file}", arcname=file)
308+
return tarball_path
259309
except Exception as ex:
260310
raise RuntimeError("failed to package files") from ex
261311

bin/update-lima-bundles.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,23 @@ aarch64_deps=$(find_latest_object_match_from_s3 "${AARCH64_FILENAME_PATTERN}" "$
3636
# Need to pull the shasum of the artifact to store for later verification.
3737
aarch64_deps_shasum_url="${DEPENDENCY_CLOUDFRONT_URL}/${aarch64_deps}.sha512sum"
3838
aarch64_deps_shasum=$(curl -L --fail "${aarch64_deps_shasum_url}")
39-
4039
pull_artifact_and_verify_shasum "${DEPENDENCY_CLOUDFRONT_URL}/${aarch64_deps}" "${aarch64_deps_shasum}"
4140

4241
amd64_deps=$(find_latest_object_match_from_s3 "${AMD64_FILENAME_PATTERN}" "${dependency_bucket}/${X86_64}")
4342
[[ -z "$amd64_deps" ]] && { echo "Error: x86_64 dependency not found"; exit 1; }
4443

4544
amd64_deps_shasum_url="${DEPENDENCY_CLOUDFRONT_URL}/${amd64_deps}.sha512sum"
4645
amd64_deps_shasum=$(curl -L --fail "${amd64_deps_shasum_url}")
47-
4846
pull_artifact_and_verify_shasum "${DEPENDENCY_CLOUDFRONT_URL}/${amd64_deps}" "${amd64_deps_shasum}"
4947

48+
# make sure the lima version for both matches
49+
lima_version_aarch64=$(get_lima_version_from_deps "${DEPENDENCY_CLOUDFRONT_URL}/${aarch64_deps}")
50+
lima_version_amd64=$(get_lima_version_from_deps "${DEPENDENCY_CLOUDFRONT_URL}/${amd64_deps}")
51+
if [[ "$lima_version_aarch64" != "$lima_version_amd64" ]]; then
52+
echo "Error: lima versions do not match b/w two dependency archives: ${lima_version_aarch64} vs ${lima_version_amd64}"
53+
exit 1
54+
fi
55+
5056
# Update bundles file with latest artifacts and digests.
5157
BUNDLES_FILE="${PROJECT_ROOT}/deps/lima-bundles.conf"
5258
truncate -s 0 "${BUNDLES_FILE}"
@@ -60,4 +66,6 @@ truncate -s 0 "${BUNDLES_FILE}"
6066
echo "X86_64_ARTIFACT_PATHING=${X86_64}"
6167
echo "X86_64_ARTIFACT=$(basename "${amd64_deps}")"
6268
echo "X86_64_512_DIGEST=${amd64_deps_shasum}"
69+
echo ""
70+
echo "LIMA_VERSION=${lima_version_aarch64}"
6371
} >> "${BUNDLES_FILE}"

bin/utility.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,17 @@ pull_artifact_and_verify_shasum() {
3939
shasum --algorithm 512 "${artifact}" | cut -d ' ' -f 1 | grep -xq "^${expected_shasum}$" || \
4040
(echo "error: shasum verification failed for \"${artifact}\" dependency" && rm -f "${artifact}" && exit 1)
4141
}
42+
43+
# pulls articact, extracts and reads LIMA_VERSION file from the artifact
44+
#
45+
# @param artifact_url - URL to artifact
46+
# @return lima version number
47+
get_lima_version_from_deps() {
48+
local artifact_url="$1"
49+
artifact=$(basename "$artifact_url")
50+
curl -L --fail "${artifact_url}" > "${artifact}"
51+
tar -xzf "${artifact}" ./LIMA_VERSION
52+
lima_version="$(cat LIMA_VERSION | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
53+
rm -f "${artifact}" ./LIMA_VERSION
54+
echo "${lima_version}"
55+
}

deps-verification-arm64.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
/opt/homebrew/Cellar/libpng/1.6.50/lib/libpng16.dylib → libpng16.16.dylib
2929
/opt/homebrew/Cellar/libslirp/4.9.1/lib/libslirp.0.dylib [164K]
3030
/opt/homebrew/Cellar/libslirp/4.9.1/lib/libslirp.dylib → libslirp.0.dylib
31-
/opt/homebrew/Cellar/libssh/0.11.3/lib/libssh.4.10.3.dylib [469K]
32-
/opt/homebrew/Cellar/libssh/0.11.3/lib/libssh.4.dylib → libssh.4.10.3.dylib
33-
/opt/homebrew/Cellar/libssh/0.11.3/lib/libssh.dylib → libssh.4.dylib
31+
/opt/homebrew/Cellar/libssh/0.12.0/lib/libssh.4.11.0.dylib [469K]
32+
/opt/homebrew/Cellar/libssh/0.12.0/lib/libssh.4.dylib → libssh.4.11.0.dylib
33+
/opt/homebrew/Cellar/libssh/0.12.0/lib/libssh.dylib → libssh.4.dylib
3434
/opt/homebrew/Cellar/libtasn1/4.20.0/lib/libtasn1.6.dylib [106K]
3535
/opt/homebrew/Cellar/libtasn1/4.20.0/lib/libtasn1.dylib → libtasn1.6.dylib
3636
/opt/homebrew/Cellar/libunistring/1.3/lib/libunistring.5.dylib [1.9M]
@@ -109,6 +109,6 @@
109109
/opt/homebrew/opt/zstd → ../Cellar/zstd/1.5.7
110110
/opt/homebrew/share/lima/lima-guestagent.Linux-aarch64.gz [12M]
111111
/opt/homebrew/share/lima/templates/_default/mounts.yaml [104B]
112-
/opt/homebrew/share/lima/templates/_images/alpine.yaml [592B]
112+
/opt/homebrew/share/lima/templates/_images/fedora-42.yaml [592B]
113113
/opt/homebrew/share/lima/templates/_images/ubuntu.yaml [2.4K]
114114
/opt/homebrew/share/qemu → ../Cellar/qemu/10.1.0/share/qemu

deps-verification-x86.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
/usr/local/Cellar/libpng/1.6.50/lib/libpng16.dylib → libpng16.16.dylib
3030
/usr/local/Cellar/libslirp/4.9.1/lib/libslirp.0.dylib [146K]
3131
/usr/local/Cellar/libslirp/4.9.1/lib/libslirp.dylib → libslirp.0.dylib
32-
/usr/local/Cellar/libssh/0.11.3/lib/libssh.4.10.3.dylib [448K]
33-
/usr/local/Cellar/libssh/0.11.3/lib/libssh.4.dylib → libssh.4.10.3.dylib
34-
/usr/local/Cellar/libssh/0.11.3/lib/libssh.dylib → libssh.4.dylib
32+
/usr/local/Cellar/libssh/0.12.0/lib/libssh.4.11.0.dylib [483K]
33+
/usr/local/Cellar/libssh/0.12.0/lib/libssh.4.dylib → libssh.4.11.0.dylib
34+
/usr/local/Cellar/libssh/0.12.0/lib/libssh.dylib → libssh.4.dylib
3535
/usr/local/Cellar/libtasn1/4.20.0/lib/libtasn1.6.dylib [103K]
3636
/usr/local/Cellar/libtasn1/4.20.0/lib/libtasn1.dylib → libtasn1.6.dylib
3737
/usr/local/Cellar/libunistring/1.3/lib/libunistring.5.dylib [1.9M]
@@ -111,6 +111,6 @@
111111
/usr/local/opt/zstd → ../Cellar/zstd/1.5.7
112112
/usr/local/share/lima/lima-guestagent.Linux-x86_64.gz [13M]
113113
/usr/local/share/lima/templates/_default/mounts.yaml [104B]
114-
/usr/local/share/lima/templates/_images/alpine.yaml [592B]
114+
/usr/local/share/lima/templates/_images/fedora-42.yaml [592B]
115115
/usr/local/share/lima/templates/_images/ubuntu.yaml [2.4K]
116116
/usr/local/share/qemu → ../Cellar/qemu/10.1.0/share/qemu

deps/lima-bundles.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ AARCH64_512_DIGEST=b75d22b7f4d7d3443daf5ac4ebfa3b51f73c37854f4109150800ce11a3b99
77
X86_64_ARTIFACT_PATHING=x86-64
88
X86_64_ARTIFACT=lima-and-qemu.macos-x86_64.1770936353.tar.gz
99
X86_64_512_DIGEST=f26f68dc3d6dc7f8bc5577d63d611b1446ea8762d13b0962d3ab37bdf6839bc2a3b525c88628f2c2869ecffd636be10980aa6cbeb2bf1b367ee505fd82a75bd8
10+
11+
LIMA_VERSION=2.0.3
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From 21375c3df1144005159aff95f73b04cd0b455478 Mon Sep 17 00:00:00 2001
2+
From: Swapnanil Gupta <swpnlg@amazon.com>
3+
Date: Thu, 12 Feb 2026 18:20:26 +0000
4+
Subject: [PATCH] fix: make qemu convertToRaw handle symlinked dests
5+
6+
Signed-off-by: Swapnanil Gupta <swpnlg@amazon.com>
7+
---
8+
pkg/qemuimgutil/qemuimgutil.go | 8 ++++++++
9+
1 file changed, 8 insertions(+)
10+
11+
diff --git a/pkg/qemuimgutil/qemuimgutil.go b/pkg/qemuimgutil/qemuimgutil.go
12+
index 14ad4d47..9a5b085f 100644
13+
--- a/pkg/qemuimgutil/qemuimgutil.go
14+
+++ b/pkg/qemuimgutil/qemuimgutil.go
15+
@@ -120,6 +120,14 @@ func convertToRaw(ctx context.Context, source, dest string) error {
16+
return nil
17+
}
18+
19+
+ realDest, _ := os.Readlink(dest)
20+
+ if realDest != "" && realDest != dest {
21+
+ dest = realDest
22+
+ }
23+
+
24+
tempFile := dest + ".lima-qemu-convert.tmp"
25+
defer os.Remove(tempFile)
26+
27+
--
28+
2.47.3
29+

src/patches/lima/0001-fix-make-qemu-convertToRaw-to-handle-symlinks.patch

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)