You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable VirtIO block to access hostOS /dev/ block devices
The user may not always have a disk image but might have a /dev/x block
device, such as a USB drive that they want to share with the guest OS.
So, allowing this type of virtio-blk source is intuitive. To support
this, ioctl is used to retrieve the actual size of the /dev/x block
device. This implementation supports both Apple and Linux platforms.
On Apple platforms, mmap() on block devices appears to be unsupported
with various flag combinations. To address this, a fallback mechanism is
added and used when mmap() fails, using malloc() along with pread(),
pwrite() and fsync() on the block device fd to emulate the behavior of
mmap().
Additionally, the initial fallback was incomplete, as it only allocated
heap memory without loading the block device's content into memory. This
commit resolves the issue by properly reading the device contents into
the allocated buffer.
Since there may be asynchronous exits, a new rv_fsync_device() function
is introduced to ensure the block device is properly synchronized during
such exits.
To fully support this fallback, disk_fd and disk_size are now stored in
the vblk state during its initialization.
Close#544
0 commit comments