basic questions
Hi,
(1) The howto document at <https://virtio-fs.gitlab.io/howto-qemu.html>
contains the following snippet:
Quoted 3 lines
force use of memory sharable with the fuse daemon.
-m 4G,maxmem=4G -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on -numa node,memdev=mem
Why is the "maxmem" property necessary? It's not larger than the (implicit) "size" property of "-m", and I don't think memory hotplug is relevant here.
(2) what is the "fuse daemon"? Is that a reference to "virtiofsd"?
(3) Why is a NUMA node necessary, with a memory backend file explicitly allocated under /dev/shm?
Will the virtio-fs device model exchange such references, over the socket, with virtiofsd, that point into shared memory?
(4) Couldn't we point mem-path to a normal (host disk based) directory?
Performance aside, that should put less pressure on host RAM, and otherwise work the same. Is that correct?
(5) Is the shared memory area necessary for the most basic virtio-fs usage?
(6) I seem to recall that virtio-fs allows guests to notice if files have changed since they last looked.
Is that functionality tied to "ireg" daemon, and to the "versiontable" property added in commit 8fb5b17bea63 ("virtio-fs: Allow mapping of meta data version table", 2019-08-23)?
(7) Are guests required to access the virtio-fs device at the PCI level -- such as an MMIO region -- in order to observe async file changes, or is this functionality available purely at the virtio communication level (i.e., transport-independently)?
It doesn't seem to be explained at
<https://stefanha.github.io/virtio/virtio-fs.html>.
Thanks!
Laszlo
Quoted 5 lines · Laszlo Ersek
Hi,
(1) The howto document at <https://virtio-fs.gitlab.io/howto-qemu.html>
contains the following snippet:
Quoted 7 lines
Quoted 3 lines
force use of memory sharable with the fuse daemon.
-m 4G,maxmem=4G -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on -numa node,memdev=mem
Why is the "maxmem" property necessary? It's not larger than the (implicit) "size" property of "-m", and I don't think memory hotplug is relevant here.
Right, maxmem is not necessary. I have updated the howto. It takes a few minutes for GitLab to regenerate the website, so you might not see the changes yet if you access it right away.
Quoted 2 lines
(2) what is the "fuse daemon"? Is that a reference to "virtiofsd"?
Yes, I have updated the howto to use "virtiofsd" instead.
Quoted 6 lines
(3) Why is a NUMA node necessary, with a memory backend file explicitly allocated under
/dev/shm?Will the virtio-fs device model exchange such references, over the socket, with virtiofsd, that point into shared memory?
The guest RAM file descriptor is sent by QEMU over the vhost-user UNIX domain socket to virtiofsd. virtiofsd must be able to mmap guest RAM with the MAP_SHARED flag.
Quoted 4 lines
(4) Couldn't we point mem-path to a normal (host disk based) directory?
Performance aside, that should put less pressure on host RAM, and otherwise work the same. Is that correct?
Yes, that should work too.
Quoted 2 lines
(5) Is the shared memory area necessary for the most basic virtio-fs usage?
Yes, it's required because shared memory access to guest RAM allows virtiofsd to process the virtqueues.
Quoted 6 lines
(6) I seem to recall that virtio-fs allows guests to notice if files have changed since they last looked.
Is that functionality tied to "ireg" daemon, and to the "versiontable" property added in commit
8fb5b17bea63("virtio-fs: Allow mapping of meta data version table", 2019-08-23)?
Currently only virtiofsd -o cache=none guarantees fresh metadata (at a performance cost). The ireg daemon is experimental and incomplete, but it will make coherent metadata cheaper in the future.
There is currently no inotify support in FUSE, so the guest does not receive notifications when the file system changes. Right now guests would have to poll for changes.
Quoted 7 lines
(7) Are guests required to access the virtio-fs device at the PCI level -- such as an MMIO region -- in order to observe async file changes, or is this functionality available purely at the virtio communication level (i.e., transport-independently)?
It doesn't seem to be explained at
<https://stefanha.github.io/virtio/virtio-fs.html>.
Coherent shared file system access is not supported yet (that's where the ireg daemon comes in and it's still under development). Today virtio-fs is good for the use case where the guest is the only one accessing the file system.
In terms of the VIRTIO spec, everything is done at the device model level. Even the DAX Window is a "shared memory region", which is a well-defined device model concept. The MMIO and PCI transports implement shared memory regions differently, though.
Stefan
Quoted 3 lines · Stefan Hajnoczi
Quoted 1 line · Laszlo Ersek
[...]
[...]
Thanks for the updates for / answers to my questions (1) through (5). In particular I hadn't realized that it's virtiofsd to process the virtqueues!
Quoted 7 lines
Quoted 6 lines
(6) I seem to recall that virtio-fs allows guests to notice if files have changed since they last looked.
Is that functionality tied to "ireg" daemon, and to the "versiontable" property added in commit
8fb5b17bea63("virtio-fs: Allow mapping of meta data version table", 2019-08-23)?
Quoted 7 lines
Currently only virtiofsd -o cache=none guarantees fresh metadata (at a performance cost). The ireg daemon is experimental and incomplete, but it will make coherent metadata cheaper in the future.
There is currently no inotify support in FUSE, so the guest does not receive notifications when the file system changes. Right now guests would have to poll for changes.
Sorry, I was unclear. It's fine for my use case if the guest has to ask actively about intermittent metadata changes. My interest is not in notifications.
E.g. assume the guest tries to read or write a file it has opened earlier. (With explicit FUSE_READ / FUSE_WRITE requests, wrapped into the usual virtio descriptor chains.) Can the guest ask, in the read or write request, "please reject this request of mine if the file has changed since I last looked"? [1]
Is the "ireg" daemon, or "-o cache=none", required for that?
Quoted 5 lines
Quoted 5 lines
(7) Are guests required to access the virtio-fs device at the PCI level -- such as an MMIO region -- in order to observe async file changes, or is this functionality available purely at the virtio communication level (i.e., transport-independently)?
Quoted 7 lines
Quoted 2 lines
It doesn't seem to be explained at
<https://stefanha.github.io/virtio/virtio-fs.html>.Coherent shared file system access is not supported yet (that's where the ireg daemon comes in and it's still under development). Today virtio-fs is good for the use case where the guest is the only one accessing the file system.
Understood, thanks!
Quoted 4 lines
In terms of the VIRTIO spec, everything is done at the device model level. Even the DAX Window is a "shared memory region", which is a well-defined device model concept. The MMIO and PCI transports implement shared memory regions differently, though.
Ah, that makes a lot of sense. I've now read the shared memory region sections at <https://stefanha.github.io/virtio/virtio-fs.html>. So this is a new generic virtio facility.
It looks like virtio-fs defines shmid#0 for the time being, namely for the DAX Window. The DAX window is not important for my use case (I plan to use FUSE_READ/FUSE_WRITE).
However: is another (different) shared memory region planned, for the kind of stale metadata detection that I describe above, at [1]?
Thank you!
Laszlo
Quoted 27 lines · Laszlo Ersek
Quoted 3 lines · Stefan Hajnoczi
Quoted 1 line · Laszlo Ersek
[...]
[...]
Thanks for the updates for / answers to my questions (1) through (5). In particular I hadn't realized that it's virtiofsd to process the virtqueues!
Quoted 7 lines
Quoted 6 lines
(6) I seem to recall that virtio-fs allows guests to notice if files have changed since they last looked.
Is that functionality tied to "ireg" daemon, and to the "versiontable" property added in commit
8fb5b17bea63("virtio-fs: Allow mapping of meta data version table", 2019-08-23)?Quoted 7 lines
Currently only virtiofsd -o cache=none guarantees fresh metadata (at a performance cost). The ireg daemon is experimental and incomplete, but it will make coherent metadata cheaper in the future.
There is currently no inotify support in FUSE, so the guest does not receive notifications when the file system changes. Right now guests would have to poll for changes.
Sorry, I was unclear. It's fine for my use case if the guest has to ask actively about intermittent metadata changes. My interest is not in notifications.
Quoted 5 lines
E.g. assume the guest tries to read or write a file it has opened earlier. (With explicit
FUSE_READ/FUSE_WRITErequests, wrapped into the usual virtio descriptor chains.) Can the guest ask, in the read or write request, "please reject this request of mine if the file has changed since I last looked"? [1]
No, FUSE_READ/FUSE_WRITE don't support that.
Quoted 1 line
Is the "ireg" daemon, or "-o cache=none", required for that?
No. Userspace applications that share access to a file with at least one writer need to synchronize via file locks or out-of-band communication. This is how existing applications work so even if virtio-fs offered Compare-and-Swap semantics or similar conditional I/O primitives, I think very few applications would use them.
Quoted 2 lines
However: is another (different) shared memory region planned, for the kind of stale metadata detection that I describe above, at [1]?
Yes, there will be a second region containing inode version numbers. This way FUSE clients can check if the inode was modified by another client without making a FUSE request to the server.
Stefan
Quoted 44 lines · Stefan Hajnoczi
Quoted 27 lines · Laszlo Ersek
Quoted 3 lines · Stefan Hajnoczi
Quoted 1 line · Laszlo Ersek
[...]
[...]
Thanks for the updates for / answers to my questions (1) through (5). In particular I hadn't realized that it's virtiofsd to process the virtqueues!
Quoted 7 lines
Quoted 6 lines
(6) I seem to recall that virtio-fs allows guests to notice if files have changed since they last looked.
Is that functionality tied to "ireg" daemon, and to the "versiontable" property added in commit
8fb5b17bea63("virtio-fs: Allow mapping of meta data version table", 2019-08-23)?Quoted 7 lines
Currently only virtiofsd -o cache=none guarantees fresh metadata (at a performance cost). The ireg daemon is experimental and incomplete, but it will make coherent metadata cheaper in the future.
There is currently no inotify support in FUSE, so the guest does not receive notifications when the file system changes. Right now guests would have to poll for changes.
Sorry, I was unclear. It's fine for my use case if the guest has to ask actively about intermittent metadata changes. My interest is not in notifications.
Quoted 5 lines
E.g. assume the guest tries to read or write a file it has opened earlier. (With explicit
FUSE_READ/FUSE_WRITErequests, wrapped into the usual virtio descriptor chains.) Can the guest ask, in the read or write request, "please reject this request of mine if the file has changed since I last looked"? [1]No, FUSE_READ/FUSE_WRITE don't support that.
Quoted 1 line
Is the "ireg" daemon, or "-o cache=none", required for that?
No. Userspace applications that share access to a file with at least one writer need to synchronize via file locks or out-of-band communication. This is how existing applications work so even if virtio-fs offered Compare-and-Swap semantics or similar conditional I/O primitives, I think very few applications would use them.
Quoted 6 lines
Quoted 2 lines
However: is another (different) shared memory region planned, for the kind of stale metadata detection that I describe above, at [1]?
Yes, there will be a second region containing inode version numbers. This way FUSE clients can check if the inode was modified by another client without making a FUSE request to the server.
I think I understand now:
* "inode version number has changed"
implies
"it makes sense to look at the file again"
* "inode version number has not changed"
does *not* imply
"my next FUSE_READ / FUSE_WRITE will apply to state I've seen"
--*--
Here's why I've raised this line of questions. In the UEFI-2.8 spec, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume() says,
[...] If the medium is changed while there are open file handles to the volume, all file handles to the volume will return EFI_MEDIA_CHANGED. To access the files on the new medium, the volume must be reopened with OpenVolume(). [...]
Additionally, in EFI_FILE_PROTOCOL.Open():
[...] If the medium of the device changes, all accesses (including the File handle) will result in EFI_MEDIA_CHANGED. To access the new medium, the volume must be reopened. [...]
And I've been wondering if the UEFI driver could check inode versions for returning EFI_MEDIA_CHANGED.
- For that however, extending our VIRTIO_DEVICE_PROTOCOL with shared memory region mapping facilities would be a pre-requisite. That would not be a trivial amount of work.
- And even if the UEFI driver checked the inode version before submitting a FUSE_READ / FUSE_WRITE, that would be a TOC/TOU race.
So I think we'll take EFI_MEDIA_CHANGED (and shared memory region mapping) off the table. Instead, we should document -- whenever we get there -- that with EFI_SIMPLE_FILE_SYSTEM_PROTOCOL abstracting a virtio-fs device, the file system could change asynchronously to the guest firmware.
--*--
I think this is good enough for the basic purposes that the firmware has for virtio-fs:
(1) booting (and maybe shutting down)
(2) interactive use (development / testing)
Case (1) in more detail:
- host prepares boot filesystem and possibly input files for tests
- QEMU launches, guest boots, possibly runs tests (meaning UEFI shell commands or other UEFI applications) and writes output files
- QEMU shuts down
- host possibly consumes test output files
In other words, the "barriers" are QEMU's startup and shutdown. I think this falls under the out-of-band communication that you mention.
Case (2) in more detail:
- The developer/tester is working with the UEFI shell and needs some (unplanned) additional data from the host side.
- The developer copies the file in place on the host side.
- The developer switches to the UEFI shell, and consumes the new file.
So in case (2) it's the interactive user that synchronizes accesses to the file(s). I seem to remember doing similar things with sshfs (using it for moving data between the local and the remote host, and working with the data on the remote host through normal ssh). This appears to be out-of-band communication again.
--*--
Should we ever need synchronization more flexible than (1) and (2), we could expose discretionary file locks to specific UEFI applications that cared:
EFI_FILE_PROTOCOL.GetInfo() and EFI_FILE_PROTOCOL.SetInfo() take a GUID that identifies the "type of information", plus a (Buffer, Size) pair. We can invent a new GUID with "uuidgen", for handling file locks.
(The SetInfo() and GetInfo() APIs were deliberately designed like this in UEFI. There are a few standardized GUIDs that all filesystems are expected to support -- EFI_FILE_INFO, EFI_FILE_SYSTEM_INFO, EFI_FILE_SYSTEM_VOLUME_LABEL --, but filesystem implementations are free to extend these interfaces with new GUIDs that they invent and document.)
Thanks!
Laszlo
Quoted 58 lines · Laszlo Ersek
Quoted 44 lines · Stefan Hajnoczi
Quoted 27 lines · Laszlo Ersek
Quoted 3 lines · Stefan Hajnoczi
Quoted 1 line · Laszlo Ersek
[...]
[...]
Thanks for the updates for / answers to my questions (1) through (5). In particular I hadn't realized that it's virtiofsd to process the virtqueues!
Quoted 7 lines
Quoted 6 lines
(6) I seem to recall that virtio-fs allows guests to notice if files have changed since they last looked.
Is that functionality tied to "ireg" daemon, and to the "versiontable" property added in commit
8fb5b17bea63("virtio-fs: Allow mapping of meta data version table", 2019-08-23)?Quoted 7 lines
Currently only virtiofsd -o cache=none guarantees fresh metadata (at a performance cost). The ireg daemon is experimental and incomplete, but it will make coherent metadata cheaper in the future.
There is currently no inotify support in FUSE, so the guest does not receive notifications when the file system changes. Right now guests would have to poll for changes.
Sorry, I was unclear. It's fine for my use case if the guest has to ask actively about intermittent metadata changes. My interest is not in notifications.
Quoted 5 lines
E.g. assume the guest tries to read or write a file it has opened earlier. (With explicit
FUSE_READ/FUSE_WRITErequests, wrapped into the usual virtio descriptor chains.) Can the guest ask, in the read or write request, "please reject this request of mine if the file has changed since I last looked"? [1]No, FUSE_READ/FUSE_WRITE don't support that.
Quoted 1 line
Is the "ireg" daemon, or "-o cache=none", required for that?
No. Userspace applications that share access to a file with at least one writer need to synchronize via file locks or out-of-band communication. This is how existing applications work so even if virtio-fs offered Compare-and-Swap semantics or similar conditional I/O primitives, I think very few applications would use them.
Quoted 6 lines
Quoted 2 lines
However: is another (different) shared memory region planned, for the kind of stale metadata detection that I describe above, at [1]?
Yes, there will be a second region containing inode version numbers. This way FUSE clients can check if the inode was modified by another client without making a FUSE request to the server.
I think I understand now:
* "inode version number has changed"
implies
Quoted 7 lines
"it makes sense to look at the file again"
* "inode version number has not changed"
does *not* imply
"my next
FUSE_READ/FUSE_WRITEwill apply to state I've seen"
Yes. The version number only relates to metadata, not data. There would be a race between checking the number and FUSE_READ/FUSE_WRITE anyway.
Quoted 23 lines
--*--
Here's why I've raised this line of questions. In the UEFI-2.8 spec,
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume()says,[...] If the medium is changed while there are open file handles to the volume, all file handles to the volume will return
EFI_MEDIA_CHANGED. To access the files on the new medium, the volume must be reopened withOpenVolume(). [...]Additionally, in
EFI_FILE_PROTOCOL.Open():[...] If the medium of the device changes, all accesses (including the File handle) will result in
EFI_MEDIA_CHANGED. To access the new medium, the volume must be reopened. [...]And I've been wondering if the UEFI driver could check inode versions for returning
EFI_MEDIA_CHANGED.- For that however, extending our
VIRTIO_DEVICE_PROTOCOLwith shared memory region mapping facilities would be a pre-requisite. That would not be a trivial amount of work.
Quoted 8 lines
- And even if the UEFI driver checked the inode version before submitting a
FUSE_READ/FUSE_WRITE, that would be a TOC/TOU race.So I think we'll take
EFI_MEDIA_CHANGED(and shared memory region mapping) off the table. Instead, we should document -- whenever we get there -- that withEFI_SIMPLE_FILE_SYSTEM_PROTOCOLabstracting a virtio-fs device, the file system could change asynchronously to the guest firmware.
Yes, I agree.
Quoted 8 lines
Should we ever need synchronization more flexible than (1) and (2), we could expose discretionary file locks to specific UEFI applications that cared:
EFI_FILE_PROTOCOL.GetInfo()andEFI_FILE_PROTOCOL.SetInfo()take a GUID that identifies the "type of information", plus a (Buffer, Size) pair. We can invent a new GUID with "uuidgen", for handling file locks.
Quoted 5 lines
(The
SetInfo()andGetInfo()APIs were deliberately designed like this in UEFI. There are a few standardized GUIDs that all filesystems are expected to support --EFI_FILE_INFO,EFI_FILE_SYSTEM_INFO,EFI_FILE_SYSTEM_VOLUME_LABEL--, but filesystem implementations are free to extend these interfaces with new GUIDs that they invent and document.)
Interesting. File locking support is being worked on in virtio-fs at the moment. The majority of UEFI use cases will probably be limited to booting though and won't need file locking.
Another topic:
Does UEFI have a standard interface for configuring and storing boot devices and information (e.g. kernel filename, initramfs, command-line)? This information is necessary when booting directly from virtio-fs.
Stefan
Quoted 3 lines · Stefan Hajnoczi
Another topic:
Does UEFI have a standard interface for configuring and storing boot devices and information
Yes; UEFI (the spec) defines the BootOrder and Boot#### UEFI variables.
For example, Boot0003 could point to the boot loader of an installed OS, Boot0004 could point to the boot loader of another installed OS, Boot0001 could point to a NIC (for PXE or HTTP(S) booting), and then BootOrder (an array of uint16_t objects) would collect these into an arbitrary sequence. (The numbers in the Boot#### variable names do not dictate ordering, they just make variable names unique.)
With OVMF, the question becomes tricky. Things revolve around QEMU's "bootorder" fw_cfg file, which contains OpenFirmware (OFW) device paths that identify boot devices. QEMU generates this fw_cfg file based on the "bootindex" device properties.
The OFW device paths in the "bootorder" fw_cfg file are not as expressive as UEFI boot options (not to mention the entirely different representation). OVMF has some quite complex platform code that does the following:
(a) It translates the entries in the "bootorder" fw_cfg file, from OFW notation, to UEFI device path notation. Importantly, such a translated UEFI device path cannot contain a filesystem pathname -- it unavoidably stops at the device granularity where the information content from the OFW entry ends.
(b) The translated UEFI device paths are used as *prefixes*, and OVMF connects all devices in the devpath *subtrees* that are rooted at the prefixes. (This roughly means that OVMF makes UEFI drivers bind such devices that are selected directly, or indirectly as a part of a sub-hierarchy, by the translated UEFI device path prefixes.)
(c) We now have a set of "bound" devices in the system. OVMF invokes some core edk2 code for auto-generating boot options for these devices. If a boot option (Boot#### variable) for such a device exists already, no new option is added. Otherwise, a new Boot#### variable (boot option) is created, and appended to the end of the UEFI boot order (= referenced from the end of the BootOrder variable). This may happen e.g. if you add the "bootindex" property to an otherwise bootable device (such as virtio-blk or virtio-net) which did not to have that property previously.
(d) Finally, OVMF filters and reorders the above augmented set of UEFI boot options, against the translated UEFI device path prefixes. For example, this step will erase the boot option for such a device that you have removed from the QEMU command line, or for which you removed the "bootindex" property (while some other devices still have the property). And reordering is useful e.g. if you have an installed UEFI image, but for once, you prioritize netboot for some reason.
(e) If no device has the bootindex property (because the "bootorder" fw_cfg file is nonexistent or empty), then OVMF doesn't touch the Boot#### / BootOrder variables.
(f) Universal (platform-independent) logic in edk2 takes control, for processing (booting) the UEFI boot order.
To give you an example (from "OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c"), an OFW device path in the "bootorder" fw_cfg file, for a virtio-scsi disk, might look like
// /pci@i0cf8/scsi@7[,3]/channel@0/disk@2,3
// ^ ^ ^ ^ ^
// | | | | LUN
// | | | target
// | | channel (unused, fixed 0)
// | PCI slot[, function] holding SCSI controller
// PCI root at system bus port, PIOand the translated UEFI device path prefix would be
// PciRoot(0x0)/Pci(0x7,0x0)/Scsi(0x2,0x3)
// -- if PCI function is 0 or absent
// PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3)
// -- if PCI function is present and nonzeroStep (c) would generate a UEFI boot option with just this UEFI device path, and append it to the end of the UEFI boot order (unless it already existed somewhere in the UEFI boot order).
Typically, following a UEFI guest installation to the same virtio-scsi disk, this auto-generated boot option would be *preceded* by another, namely of the form
PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3)/HD(1,GPT,7CFAA999-DFF7-441E-A73A-7C596A600DDF,0x800,0x40000)/\EFI\fedora\shimx64.efi
because this more specific UEFI device path -- including a filesystem pathname -- would have been established earlier by Anaconda / efibootmgr, with highest priority, at guest installation time. In that case, after step (d), the boot option
PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3)/HD(1,GPT,7CFAA999-DFF7-441E-A73A-7C596A600DDF,0x800,0x40000)/\EFI\fedora\shimx64.efi
would take priority over the auto-generated
PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3)
because the reordering in step (d) is "stable".
In the atypical case however, it's possible that you only have the auto-generated UEFI boot option for
PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3)
When processing that option, UEFI silently attempts to boot
PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3)/.../\EFI\BOOT\BOOTX64.EFI
(note the fallback filesystem pathname '\EFI\BOOT\BOOTX64.EFI').
This applies when:
- you are booting removable media (for example an installer ISO)
- you have an installed system but you lost the UEFI Boot#### / BootOrder variables for some reason, including the one pointing at "shimx64.efi".
What's furthermore relevant is that the last device path node, just before the filesystem pathname node (such as '\EFI\fedora\shimx64.efi' or '\EFI\BOOT\BOOTX64.EFI'), identifies a UEFI handle that carries an EFI_SIMPLE_FILE_SYSTEM_PROTOCOL instance. In the above case,
PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3)/HD(1,GPT,7CFAA999-DFF7-441E-A73A-7C596A600DDF,0x800,0x40000)
is a hard disk partition with a FAT filesystem, and so the handle underlying the HD() node carries an EFI_SIMPLE_FILE_SYSTEM_PROTOCOL instance.
When using virtio-fs with OVMF, the OFW device path in the "bootorder" fw_cfg file would be expected to look something like
/pci@i0cf8/virtio-fs@7[,3]
(The "driver-name" component in the OFW node would be "virtio-fs".)
The translated UEFI devpath prefix would simply be
PciRoot(0x0)/Pci(0x7,0x3)
in OVMF. OVMF's driver for virtio-fs would install EFI_SIMPLE_FILE_SYSTEM_PROTOCOL directly on the Pci() node -- no need for HD(), there are no partitions --, so ultimately the following would be the "full" device path examples:
PciRoot(0x0)/Pci(0x7,0x3)/\EFI\fedora\shimx64.efi [from Anaconda / efibootmgr]
PciRoot(0x0)/Pci(0x7,0x3)/\EFI\BOOT\BOOTX64.EFI [fallback, per spec]
In short, the filesystem exposed with virtio-fs to the OVMF guest, for the purposes of UEFI booting, should look like a bootable UEFI system partition -- namely, it should include an \EFI directory tree. In other words, the "only" thing that virtio-fs abstracted away, in this regard, would be the block device layer (such as IDE, AHCI, virtio-blk or virtio-scsi), from between the "PCI" and "filesystem" layers.
Quoted 2 lines
(e.g. kernel filename, initramfs, command-line)? This information is necessary when booting directly from virtio-fs.
In the described scenario, the kernel, initramfs, and kernel command line would be handled by the UEFI boot loader, namely grub2. (Grub2 itself would exist as part of the \EFI directory tree.)
Of course the question is what we *want* here. The above targets the case when a user specifically wants to access virtio-fs *from within* UEFI (including the UEFI boot manager, the UEFI shell, and UEFI applications, such as grub2-efi).
Other goals can be imagined. For example, the following goal is slightly
different: "I want a guest kernel running on virtio-fs, and that guest kernel should find a UEFI environment underneath itself". This use case should be covered right now, because OVMF supports kernel / initramfs / cmdline via fw_cfg already. You would launch OVMF from pflash (like always), and instruct QEMU to load the kernel / initramfs / cmdline into fw_cfg from files located within the virtio-fs directory tree. OVMF would fetch the kernel / initramfs / cmdline from fw_cfg -- note: *no* firmware-level access to virtio-fs --, OVMF would launch the kernel, and the kernel would use its own smart driver for talking to virtio-fs. The kernel would also find a UEFI environment.
This would eliminate shim/grub2 from the picture. For some cases, that could be seen as a benefit. For other cases, as a limitation; for example, if you needed Secure Boot with the Machine Owner Key management that shim implements.
Thanks
Laszlo
Quoted 1 line · Laszlo Ersek
On 09/02/19 12:21, Stefan Hajnoczi wrote:
Thank you for explaining!
Quoted 18 lines
Of course the question is what we *want* here. The above targets the case when a user specifically wants to access virtio-fs *from within* UEFI (including the UEFI boot manager, the UEFI shell, and UEFI applications, such as grub2-efi).
Other goals can be imagined. For example, the following goal is slightly
different: "I want a guest kernel running on virtio-fs, and that guest kernel should find a UEFI environment underneath itself". This use case should be covered right now, because OVMF supports kernel / initramfs / cmdline viafw_cfgalready. You would launch OVMF from pflash (like always), and instruct QEMU to load the kernel / initramfs / cmdline intofw_cfgfrom files located within the virtio-fs directory tree. OVMF would fetch the kernel / initramfs / cmdline fromfw_cfg-- note: *no* firmware-level access to virtio-fs --, OVMF would launch the kernel, and the kernel would use its own smart driver for talking to virtio-fs. The kernel would also find a UEFI environment.
Quoted 4 lines
This would eliminate shim/grub2 from the picture. For some cases, that could be seen as a benefit. For other cases, as a limitation; for example, if you needed Secure Boot with the Machine Owner Key management that shim implements.
I think the existing -kernel/-initrd/-append feature is enough for the time being and firmware virtio-fs support is not urgent. However, I can also imagine cases where end-users are unable to set QEMU command-line options because they don't have access to the virtualization management layer, but would still like to configure virtio-fs boot from within the VM.
Stefan