Skip to content

Support attaching a host block device to a guest - #871

Open
MayCXC wants to merge 1 commit into
apple:mainfrom
MayCXC:block-device-attachment
Open

Support attaching a host block device to a guest#871
MayCXC wants to merge 1 commit into
apple:mainfrom
MayCXC:block-device-attachment

Conversation

@MayCXC

@MayCXC MayCXC commented Aug 27, 2026

Copy link
Copy Markdown

Summary

Virtualization offers three storage attachments and the mount path reached two of them, so a block device of the host's had no way through to a guest. One now goes as the device it is, from an extension alongside the disk image and network block device ones, picked by asking the source what it is rather than by a naming convention the caller has to keep.

This lets whatever backs the device on the host back it in the guest, which a disk image has no way to say: a partition, a whole disk, or a device the host holds in memory.

Motivation and Context

The gap was in the mount path rather than in the framework: VZDiskBlockDeviceStorageDeviceAttachment exists, and the two neighbouring attachment kinds were already reachable, so a caller with a block device had to convert it to an image first, which loses exactly the property that made it a block device.

Deciding by asking the source what it is, rather than by a prefix or suffix on the path, means the caller does not carry a convention and a device that is not a device cannot be mistaken for one.

No issue filed, as this adds a third case to an existing enumeration rather than changing behaviour for anything that works today. Happy to open one if the project prefers it discussed first.

Testing

  • swift build and make check clean.
  • swift test: 595 tests in 82 suites passed, on current main.
  • Integration: PodVolumeTests attaches a host block device to a pod volume and reads it back from inside the guest.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Virtualization offers three storage attachments and the mount path
reached two of them, so a block device of the host's had no way through
to a guest. One now goes as the device it is, from an extension
alongside the disk image and network block device ones, picked by asking
the source what it is rather than by a naming convention the caller has
to keep.

This lets whatever backs the device on the host back it in the guest,
which a disk image has no way to say: a partition, a whole disk, or a
device the host holds in memory, whose pages it compresses and pages out
under contention as it would any others.

Integration coverage attaches an ext4 image as a block device, writes to
it from the guest, and reads what landed back out of the image once the
host has it again. The read only case confirms the write is refused, and
a memory backed device carries a raw write with no filesystem in the way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant