Commit Graph
380 Commits
Author SHA1 Message Date
Danny Canter cb3493b507 vminitd: Add ability to set log level (#531)
This adds a small flag named --log-level to be able to set the log level
of vminitd and the pause command. I imagine this won't be the last time
we'll have to add flags to vminitd so I went ahead and converted vminitd
to be a Argument Parser based binary as well.
2026-02-14 13:33:21 -08:00
Danny Canter c1183767cb CI: Add signed commits check (#530)
We should fail CI if commits aren't signed so it's more obvious to
contributors.
2026-02-13 12:47:32 -08:00
Anthony 9bce347f50 Add releaseNetwork method to ContainerManager (#527)
I've extracted the network cleanup step from `delete` into a new public
`releaseNetwork` method. This mirrors the existing `release` on
`VmnetNetwork` and enables stop-and-restart workflows where the network
allocation needs to be freed without removing the container's rootfs.

## Changes

- Add `ContainerManager.release(_:)` — frees network resources for a
container after it has stopped
- Refactor `delete(_:)` to call `releaseNetwork(_:)` before removing
files, preserving existing behavior

## Motivation

Currently the only way to free a container's network allocation is
`delete`, which also removes its files. This makes it impossible to stop
a container (freeing the network so the ID can be re-allocated) and
later restart it with its filesystem intact. The new `releaseNetwork `
method fills this gap.
2026-02-12 12:11:29 -08:00
Dmitry Kovba 7c7ed05e10 Add a public method to wait for the relay to complete (#529)
- Adds a public method to wait for the relay to complete when both
directions close
- Improves error handling
- Moves `UnixSocketRelayManager` into a separate file
- Renames `SocketRelay` to `UnixSocketRelay`
- Adds logs at the info level after converting other logs to the debug
level previously
2026-02-11 23:44:22 -08:00
Anthony 71a0b4577f Add LocalizedError conformance to ContainerizationError (#528)
Without `LocalizedError` conformance, calling `localizedDescription` on
a `ContainerizationError` falls back to the default representation
(e.g., "ContainerizationError.ContainerizationError error 1.") instead
of returning the actual error message. This makes it difficult to show
meaningful errors in a UI, where `localizedDescription` is the standard
way to get a user-facing string.
2026-02-11 15:42:08 -08:00
Manoj Mahapatra 98391937da Guard against if ipv4Gateway is nil, removed fore unwrap (#524)
- Guarded against ipv4Gateway if nil and throw
`ContainerizationError(.invalidState, ...)` instead of force unwraping
- Added a unit test
`ContainerManagerTests.testCreateThrowsWhenGatewayMissing`
2026-02-10 22:20:03 -08:00
Dmitry Kovba 3f9dcf60e6 Improvements to the process and network management commands (#381)
Improves the process and network management commands.
2026-02-09 13:19:54 -08:00
Dmitry Kovba a8b830550a Do not remove a socket file created by another service (#520)
- Fixes a bug where a socket file created by another service could be
removed
- Fixes log levels
- Improves access level
2026-02-09 13:19:33 -08:00
J Logan 3cfd54cb8a Disable automatic resolution for builds. (#526)
- Improves build reproducibility by using only the pinned dependencies
in Package.resolved.
- Closes #299.
2026-02-09 13:05:40 -08:00
Danny Canter 39aeac3f19 LinuxContainer/LinuxPod: Support duplicate virtiofs mounts (#522)
If we have the same source we should dedupe these. Previously
virt.framework would yell at us for a duplicate tag because we derive
the tag from hashing the mount source.
2026-02-09 11:06:53 -08:00
Dmitry Kovba 69bc038b30 Refactor a bidirectional relay and fix bugs (#516)
Changes:
- Refactors a bidirectional relay into a new class
- Makes the unique identifier for a socket configuration public

Bug fixes:
- Fixes a bug where partial writes didn't advance the pointer
- Fixes a buffer memory leak
- Fixes error messages
- Fixes log messages
- Fixes log levels
2026-02-05 16:50:45 -08:00
Saehej Kang 3f4eee7d2a [keychain]: add list function + update variable/parameter names (#502)
- Add a `list` function that is needed for the `container registry list`
command
- Updates to `KeychainHelper` and `KeychainQuery` variable/parameter
names
- Updates to test cases
2026-02-04 18:15:30 -08:00
Anthony df5f0f336a Fix usage of "clean up" as verb (#507)
"clean up" is a verb, and "cleanup" is a noun. There are several
examples of the incorrect usage of "cleanup" as a verb in this
repository, including one in the public API (`cleanupOrphanedBlobs`).
For this public method, I've added a deprecation notice to the name with
the incorrect usage.
2026-02-04 09:14:25 -08:00
J Logan c3fe889a2f Fix for decompressing zstd with localpath URL. (#512)
- InputSource(url:) rejects URLs with nil scheme, which was what was
passed when running the `container system kernel set` integration test
with a local kernel archive path.
2026-02-02 20:32:07 -08:00
J Logan 258ad89d51 Disable pod single file mount test. (#511) 2026-02-02 16:23:57 -08:00
J Logan 3f36cba3bf Align kernel build version with Kata used in container. (#510)
- Also temporarily disable single file integration tests until they're
reliable.
2026-02-02 15:34:58 -08:00
Danny Canter b2f8351668 vmexec: Add missing rlimits (#506)
We were missing:

RLIMIT_LOCKS, RLIMIT_MSGQUEUE, RLIMIT_NICE, RLIMIT_RTPRIO,
RLIMIT_RTTIME, and RLIMIT_SIGPENDING
2026-02-02 13:53:15 -08:00
J LoganandAditya Ramani 1b50c817b6 Adds zstd decompression for layer content blobs. (#508)
- Closes apple/container#988.
- macOS libarchive is not built with zstd support, so the workaround in
ArchiveReader is to attempt to decompress every archive as zstd. If
decompression fails, we pass the original archive to libarchive. If it
succeeds, we pass the uncompressed archive.
- Adds blob media type recognition for zstd to EXT4Unpacker. Tested zstd
blob unpack using `image pull tonistiigi/hello-world:zstd-docker`.

Co-authored-by: Aditya Ramani <a_ramani@apple.com>
2026-02-02 13:10:22 -08:00
Danny Canter 92b02fc497 LinuxRLimit.Kind: Add string constructor (#504)
The OCI representation (just strings of the enum names) should be able
to be passed for convenience.
2026-01-30 17:09:36 -08:00
Danny Canter dd60ac3ab7 Add LinuxRLimit type (#499)
I was not a huge fan of how rlimits were specified using the OCI type as
it just takes in strings for the type which isn't super ergonomic. This
adds a new type for rlimits that we can convert to oci type like we
already do for capabilities.
2026-01-29 14:10:39 -08:00
Danny Canter d37f90048b vminitd: Set nofile rlimit to max (#498)
No reason to default to 65k
2026-01-28 16:45:25 -08:00
Danny Canter a8758a6ab3 LinuxPod: Add back top-level dns/hosts (#501)
Upon further thought, we should probably support this at the pod level
and allow per container overrides. I've changed my mind on how tedious
it is to specify it on a per-container basis.
2026-01-28 14:23:19 -08:00
Stuart LangandClaude Opus 4.5 c8ddc8a826 Make EXT4.Inode properties public (#500)
## Summary

The `EXT4.Inode` struct is public but its properties were internal,
preventing external consumers from reading inode metadata. This change
makes the properties public to enable use cases like reading file
metadata (mode, uid, gid, timestamps) from ext4 filesystems.

Motivating use case: https://github.com/socktainer/socktainer/pull/169

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 13:53:20 -08:00
Aditya Ramani 3a0b79d7fb Check for wildcard when determining if proxy should be bypassed (#497)
The `shouldBypassProxy` method from `ProxyUtils.swift` did not account
for `NO_PROXY` entries of the form `*.host.com`
This PR adds an additional check to determine if the proxy should be
bypassed for a given host.
2026-01-28 09:55:45 -08:00
Danny Canter db113ffec9 LinuxPod: Support per container dns/hosts (#496)
This shouldn't have been pod level, and we had no way to set hosts today
either. This just exposes hosts and the dns configs per container now.
2026-01-27 10:11:32 -05:00
jwhur fd62f311b4 Shutdown VM gracefully from created state (#495)
This PR enables gracefully shutting down VM even when the
`LinuxContainer` is in `created` state.
2026-01-26 15:56:24 -08:00
J Logan 7d4bd80fc8 Move setTime debug message to trace level. (#493)
- Closes #492.
2026-01-26 10:25:18 -08:00
1a017417bc LinuxContainer/LinuxPod: Single file support (#487)
Fixes #79

This adds support for single file (virtiofs based) mounts to the two
main container types. This is transparent, and doesn't need to be setup
by a user, so there is no visible API change. Virtiofs does not support
single file mounts today, and it would be less than ideal from a
security standpoint to just expose the parent directory of the file to
the vm and then bind mount in the file, so we chose the following:

1. Create a temp directory the container types will manage.
2. Hardlink in the file we want.
3. Share that tempdir into the vm.
4. Finally bind mount in the file into the container.

The main goal I wanted for this is to leave the logic out of the
`VirtualMachineInstance`. I really want this to just be a little dance
the container types do, and leave the vm out of it. Because of that,
most of the logic is shoved in a new `FileMountContext` type that does
the dirty tricks of rewriting what the user asked for to be a bind mount
from a temporary holding spot we'll use in the guest for these temp
directories.

One of the downsides to this is today the tempdirs are solely on the
main volume, so cross volume will need to copy the file to the tempdir,
so writes won't get written back.

Co-authored-by: Dean Coulstock <d_coulstock@apple.com>
Co-authored-by: Jaewon Hur <hurjaewon@snu.ac.kr>
2026-01-22 20:57:58 -08:00
Dmitry Kovba 1d9140cc8a Add a route when a gateway is outside a subnet (#488)
When we set a gateway outside a subnet in Linux, this fails with:
```
ip-route-add-default: netlink response indicates error, rc = -101 
```

To resolve the error, we should first add a route to the gateway outside
the subnet, which this PR does.
2026-01-22 18:57:46 -08:00
Danny Canter db277344b4 Mount: Support single file bind mount (#486)
Add in a small bit to create an empty file if we're asking for a single
file bind mount. This also resolves a bug with us using the wrong target
path in one of the mount variants.
2026-01-22 13:49:00 -08:00
J Logan 8da5f2306d Move Bindable to ContainerizationExtras, fix binding bugs. (#481)
- Bindable is generally useful, so it makes sense to move it out of the
netlink library. Removed Equatable conformance from Bindable as this
isn't generally necessary (it's only used for unit tests in netlink).
- Fix some offset checks in a couple data binding functions and improve
the unit tests.
2026-01-21 15:34:10 -08:00
Danny Canter c4f1263594 cctl: Make networking macOS 26 only (#437)
There's no sane way to do networking in this tool on < 26, you have to
guess the bridge subnet.
2026-01-21 15:29:45 -08:00
J Logan dadfdcefae Adds opt-in precommit hook to check formatting. (#483) 2026-01-21 11:34:16 -08:00
J Logan ce0963f693 Devcontainer for vminitd development. (#482) 2026-01-21 01:51:56 -08:00
J Logan d40650f1fb Update workflow label to select macOS 26 builder. (#485) 2026-01-21 00:38:54 -08:00
Danny Canter 863380c5e1 Interface: Support custom mtu (#484)
We started the legwork awhile ago, but never exposed it to be
configurable by the container types.
2026-01-20 17:32:28 -08:00
Saehej Kang 53017de9c2 [docs]: Updates to contribution guidelines (#426)
## Type of Change
- [ ] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [x] Documentation update

## Motivation and Context

- Added an index to the doc for easily accessing important sections
- Added two new main sections to help first time contributors with tips
on how to get started with issues, how to ask for help, and who to ask
for help.
- Made all headings sentence case for consistency

Closes https://github.com/apple/container/issues/880, as it was
preferred to not add a `CODEOWNERS` file, but instead add notes to where
contributors can find a list of maintainers to ping.

## Testing
- [ ] Tested locally
- [ ] Added/updated tests
- [x] Added/updated docs
2026-01-20 10:08:26 -08:00
Danny Canter 552d4ce759 Integration: Add simple test filtering (#479)
Just does simple string contains logic
2026-01-17 20:15:54 -08:00
Danny Canter 26f3dcc796 LinuxProcess: Start stdin relay after process start (#478)
Fixes #477

Because we start piping stdin before process launch we can fill up the
guest pipe buffer before the process even starts. We'd need some
backpressure mechanism to handle this and slow consumers (register the
other end with epoll and buffer some data etc.), but we should probably
just start piping after the process is up and running. This change does
exactly that, as well as stops holding the process mutex while draining
stdin in the guest for `CloseStdin()`.

This fixes issues where we try and write > pipe_buf bytes through stdin.
Today this hangs.
2026-01-16 14:14:08 -08:00
Danny Canter 0e91de6124 vmexec: Use FoundationEssentials (#475)
Start the journey to try and remove the 30MiB ICU blob in this binary...
2026-01-16 10:11:45 -08:00
J Logan f570b8734e Fix formatting. (#476) 2026-01-15 11:29:34 -08:00
J Logan 3e93416b9a Merge commit from fork
* Admit only valid OCI layout files when loading image.

- Adds `AdmissionMapper` protocol for validating archive
  member paths and normalizing them to relative paths
  under the extraction root directory.
- Renames `Reader.swift` to `ArchiveReader.swift` to
  match type name.
- Rework `TempDir` to address `NSString.utf8String`
  deprecation warning in Swift 6.2.3.
- Rework `ArchiveReader.extractContent()` to use an
  `AdmissionMapper` to validate and remap archive
   members before extracting.
- Adds `IdentityAdmissionWrapper` for naive extraction.
- Adds `NoSymlinkAdmissionWrapper` that only extracts
  regular files and directories under the extraction root.
- Adds `OCIImageAdmissionWrapper` that only extracts
  valid OCI image layout paths.
- Use `OCIImageAdmissionWrapper` for `cctl image load`
  and print rejected paths.

* PR feedback.

* Adds public init() for TrustedAdmissionMapper.

* Replace AdmissionMapper with more secure extraction.

- Adds FileDescriptor.mkdirSecure() to prevent
  root escapes on member pathnames, and to prevent
  symlink traversal.
- Adds FileDescriptor.unlinkRecursive() to
  facilitate overwrites when there are multiple
  archive entries with the same member path.
- Adds FileDescriptor.validateSymlinkTargetInRoot()
  to validate that extracted symlink targets do
  not escape the root.
- Rewrite ArchiveReader.extractContents() to use
  secure path functions.

* Remove unneeded symlink check, rename files.

* Simplify the lexical normalizer workaround.

* Reject member paths containing parent traversal components.

* Remove unused lexical normalization workaround.

* Fix leaking fds, extract absolute members as relative.
2026-01-15 12:52:02 -06:00
Danny Canter bbe4159649 LinuxContainer: Give a bit of overhead memory (#472)
The guest agent isn't free, and today we were sizing the VMs memory
allotment and the containers cgroup to the same value. This change gives
some overhead memory to the VM (50MB for now) for the guest agent.
2026-01-14 13:31:34 -08:00
Danny Canter 8446f895ee Allow filtering container statistics (#471)
It's possible a user doesn't want the full stats list, and only wants
cpu/mem etc. This plumbs through the ability to filter to only what is
requested. This, while we're already here, adds in memory.event output
to the stats list. For that specifically, I think eventually we may want
a streaming variant of this so you can get alerted of changes in the
file immediately instead of polling/one off reads, but this is useful
for now.
2026-01-13 13:35:00 -08:00
박성근 cbc03d7040 Fix: resolve relative executable paths against workingDirectory in vmexec (#473)
- Fixes the root cause for apple/container#962.

Signed-off-by: ParkSeongGeun <phd0801@naver.com>
2026-01-11 18:15:18 -08:00
Danny Canter fc5399e77e vmexec: Remove the logger setup (#469)
We can't write to stderr because it may be the containers stderr, so
this is mostly dead code. We should think about how to do logging from
here as there's a couple spots it'd be nice.
2026-01-05 13:48:43 -08:00
Kathryn Baldauf ec2ee3e94d Update license header on all files to include the current year (#470)
Related to https://github.com/apple/container/pull/1024

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-01-05 13:08:48 -08:00
J Logan 452f354bac Adds MACAddress type. (#468)
- Simplifies processing and validation of MAC addresses for
apple/container#1005, where we need to create MAC addresses and
corresponding link local IPv6 addresses.
- Adds Codable for IPAddress and CIDR for apple/container#1006, so we
can parse and relay IP addresses regardless of address family for port
forwards.
2026-01-05 11:31:23 -08:00
Danny Canter 2f55d75fec Support read only rootfs (#461) 2026-01-02 13:28:44 -08:00
Danny Canter 44ecb87f8d Agent: Add single file copying (#463)
Add a streaming rpc to copy single files in and out. This can easily be
extended to support copying directories, but we need the guest agent to
be able to tar/untar, and we'll need to figure out what that model is.
2026-01-02 08:57:40 -08:00