Allow direct access to windows disks on hyper-V as well as virtiofsd, DAX

Goal

Feature request to

  • Investigate the possibility on windows-host QEMU of being able to do this (access block devices) on recent builds of windows-10 (>21H1)
  • Implement the feature on windows-host QEMU to allow a guest to access the host's mounted native filesystems, physical drives (\.\PhysicalDrive#s) and Virtual-Disks (VHDX) using the windows-10 hooks, in a manner that is faster than the usual IP-network-Samba/CIFS.
  • Port/Compile virtiofsd.exe which is currently present only on linux/KVM
  • Let windows-host QEMU provide DAX shared-memory virtfs access by guests

This feature request has 3 cases (A) with HyperV enabled and (B) without HyperV enabled but instead using a nonnative hypervisor like using haxm (C) without hardware based hypervisor acceleration

Technical details

Some recent changes in the windows-10 features may allow the possibility of this feature on recent windows builds. There is evolving WSL2 documentation. WSL2 code, at least in the guest VM side, is opensource/GPL.

  • wsl2 was first introduced in Windows 10 version 1903 (or higher), with Build 18362 or higher, for x64 systems, and Version 2004 or higher, with Build 19041 or higher, for ARM64 systems.
  • The in-VM linux/windows guest-side filesystem access may be opensource via WSL2 drivers. Feature may need implementing of the corresponding windows-host QEMU host-side functionality.
  • full-disk passthrough is a whole different setup https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn803924(v=ws.11) Full disk passthrough is not always possible as the host may have some mounted partitions from it.
  • As of now, on windows-host QEMU, one an pass \.\PhysicalDrive and partitions to the guest OS. https://qemu.weilnetz.de/doc/6.0/system/images.html#windows . Unless the whole disk is passthrough, HyperV prefers to take charge of the physical disks. In linux/kvm, both qemu and virtualbox supports Full-device-type-vmdk as well as Partitioned-Device-type-vmdk. Linux/kvm/qemu can additionally pass a block device directly.
  • The windows-10 HyperV literature as well as sysadmin experience do not recommend partitioning large disks for this purpose. The purported advantage of partitioning was that it avoided one more disk translation layer allowing for faster access. But, the partitioning and giving the guest direct partition access has the following disadvantages
    • Partitioning fragments the free space amongst the partitions causing wastage/under-utilization of free space.
    • Guest cannot optimize the disk access performance read or write as long as disk is shared with host.
    • Virtual-machine configuration/deployment becomes entangled/coupled with the physical machine.
    • Ownership issues wherein partition level changes made by guest are unbeknownst to the host and result in unexpected changes to host owned disks and filesystems.
  • The windows-10 HyperV literature seems to suggest that the path forward is for the guest to run a virtfs driver with shared memory and let the host do the IO caching. It is recommended to use a simple large filesystem like Exfat and place VHDX virtualdisks in it.
  • Features such as DAX/virtiofd facilitate this IO acceleration. https://man.archlinux.org/man/extra/qemu-headless/virtiofsd.1.en
  • Windows Hypervisor Platform (WHPX, Hyper-V hypervisor) being a Microsoft technology, will likely become unavoidably ubiquitous. As Microsoft adds more features that require HyperV, such as wsl2, sandbox, android-emulator, etc, so much so that though it is optional, it will become necessary to enable HyperV. It may become like KVM is to Linux, which one accepts as the default native hypervisor. Both qemu-6 and Virtualbox 6 can now use HyperV (WHPX).
  • wsl1 was able to mount windows filesystems use a 9P server and qemu actually has a v9fs backend. I wonder if this is the same mechanism for wsl2. https://devblogs.microsoft.com/commandline/a-deep-dive-into-how-wsl-allows-windows-to-access-linux-files/
  • wsl2 will be able to mount non-windows (Linux) disks/partitions/filesystems, passthrough disks (Windows 10 Build 20211) (Windows 11 Build 22000). https://devblogs.microsoft.com/commandline/access-linux-filesystems-in-windows-and-wsl-2/ https://docs.microsoft.com/en-us/windows/wsl/wsl2-mount-disk
  • Now recent versions of QEMU do support hyperX and VHDX virtual-disks
  • It would be most beneficial for qemu windows users to allow this mode of direct filesystem access on mounted drives. Virtual-disks (VHDX) access being already there.

Additional information

Depends on, first needs fixing of, Issue #346 (closed) / Issue #430 (closed) , Essentially accel=whpx is not working/is broken/has regression.

J:\>E:\scoopg\shims\qemu-system-x86_64.exe --version
QEMU emulator version 6.1.0 (v6.1.0-11882-g7deea770bf-dirty)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers

References

Edited by GK