Add support for network block device (NBD)#690
Open
yibozhuang wants to merge 1 commit intoapple:mainfrom
Open
Conversation
5507fb0 to
351c727
Compare
This change adds support for attaching network block device (NBD) to both LinuxContainer and LinuxPod. For LinuxContainer, whether to use the underlying VZNetworkBlockDeviceStorageDeviceAttachment is determined by the URL of the container Mount source. For LinuxPod, adds additional API to support pod-level volumes that can be mounted into multiple containers. The PodVolume type provides enum to support multiple type of volume source. ContainerConfiguration for LinuxPod adds additional volumeMounts type which are container mounts where the source comes from a pod-level volume. This will allow the NBD to be attached to the pod at the VM level and then bind-mounted into a container. For integration tests, added a lightweight NBD server implementation in swift that speaks the NBD protocol to ensure there is sufficient coverage for the changes introduced.
dcantah
reviewed
Apr 20, 2026
| throw error | ||
| } | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
Can we have LinuxContainer tests?
Contributor
Author
There was a problem hiding this comment.
dcantah
reviewed
Apr 20, 2026
| /// forwarding and zombie reaping. | ||
| public var useInit: Bool = false | ||
| /// The container mounts that references pod-level attached volumes. | ||
| public var volumeMounts: [VolumeMount] = [] |
Member
There was a problem hiding this comment.
I'm not super happy with this in particular but I can't put my finger on it. This almost seems like a UX win really right? There's nothing they couldn't emulate by just asking for the same mount in every container in the pod?
Member
There was a problem hiding this comment.
I think if we were to keep this I'd prefer sharedMounts or something.
Contributor
Author
There was a problem hiding this comment.
@dcantah How about this
- remove the
volumeMountsfromContainerConfiguration - Introduce a new
Mount.sharedMount()constructor to indicate that this is a shared mount - Add a
.sharedRuntimeOptions to indicate that this is a shared mount between containers PodContainercan doconfig.mounts.append(Mount.sharedMount(name: "shared-data", destination: "/data", options: ["ro"]))to add a shared mount to its configuration, no additional API surface needed
Does this work better?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds support for attaching network block device (NBD) to both LinuxContainer and LinuxPod.
For
LinuxContainer, whether to use the underlyingVZNetworkBlockDeviceStorageDeviceAttachmentis determined by the URL of the container Mount source.For
LinuxPod, adds additional API to support pod-level volumes that can be mounted into multiple containers. ThePodVolumetype provides enum to support multiple type of volume source.ContainerConfigurationfor LinuxPod adds additional volumeMounts type which are container mounts where the source comes from a pod-level volume. This will allow the NBD to be attached to the pod at the VM level and then bind-mounted into a container.For integration tests, added a lightweight NBD server implementation in swift that speaks the NBD protocol to ensure there is sufficient coverage for the changes introduced.
Apple Virtualization NBD support documentation:
https://developer.apple.com/documentation/virtualization/vznetworkblockdevicestoragedeviceattachment