libkrun icon indicating copy to clipboard operation
libkrun copied to clipboard

Flush operations and block devices

Open nohajc opened this issue 9 months ago • 0 comments

When I configure a disk backed by macOS block device and try to use it in read/write mode, I end up with the following error:

[2025-03-28T23:29:45Z ERROR devices::virtio::block::worker] error processing request: FlushingToDisk(Os { code: 25, kind: Uncategorized, message: "Inappropriate ioctl for device" })

It seems to come from here:

VIRTIO_BLK_T_FLUSH => match self.disk.cache_type() {
    CacheType::Writeback => {
        let diskfile = self.disk.file();
        diskfile.flush().map_err(RequestError::FlushingToDisk)?;
        diskfile.sync().map_err(RequestError::FlushingToDisk)?;
        Ok(0)
    }
    CacheType::Unsafe => Ok(0),
},

It happens with both /dev/rdisk* and /dev/disk* files.

I am able to make it work if I set CacheType to Unsafe but this is not exposed in the C API. Do you think it would be a good idea to do so, or is there any other way to address this?

Thank you.

nohajc avatar Mar 29 '25 00:03 nohajc