virtio: Plumb virtio-fs into the legacy filesystem code

Add compatibility function to support a single virtio-fs via the normal
'ls' and 'load' commands. Other commands are not supported for now.

Add a workaround for the fact that virtiofs does not use a block device.
The existing filesystem layer does not support non-block filesystems -
sandbox's hostfs mostly bypasses this code.

Make sure that sandbox does not try to mount a virtio-fs as this does
not work at present. It will require either a fake driver for virtio-fs
which connects to host files, or possibly something involving FUSE.

Series-to: concept
Cover-letter:
virtio: Support virtio-fs
This series introduces support for virtio-fs, a filesystem which
provides access to host files from within a QEMU guest OS.

A new filesystem driver is created with support for the three uclasses
(FS, DIR, FILE). A compatibility layer is added as well, so that the
existing cmdline work as expected.

Only listing directories and reading files are supported so far.

Since sandbox works by using a NULL blk_desc, a workaround is added for
now. Once we switch commands (and bootstd!) over to the new filesystem
approach, this will go away.

It is possible to test this using something like:

   ./scripts/build-qemu -a x86  -rs -D .

then within U-Boot:

   ls virtio 0
END

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-06-26 07:10:21 -06:00
parent ce5ca9b204
commit 5ab90a9307
7 changed files with 252 additions and 3 deletions

View File

@@ -482,7 +482,13 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
return 0;
}
#endif
if (IS_ENABLED(CONFIG_VIRTIO_FS) && !strcmp(ifname, "virtiofs")) {
strcpy((char *)info->type, BOOT_PART_TYPE);
strcpy((char *)info->name, "Virtio filesystem");
info->fs_type = FS_TYPE_VIRTIO;
return 0;
}
#if IS_ENABLED(CONFIG_CMD_UBIFS) && !IS_ENABLED(CONFIG_XPL_BUILD)
/*
* Special-case ubi, ubi goes through a mtd, rather than through