virtio-win / kvm-guest-drivers-windows

Windows paravirtualized drivers for QEMU\KVM
https://www.linux-kvm.org/page/WindowsGuestDrivers
BSD 3-Clause "New" or "Revised" License
2.03k stars 387 forks source link

VirtFS / 9p support for Windows #126

Closed ildar closed 2 years ago

ildar commented 7 years ago

https://github.com/virtio-win/kvm-guest-drivers-windows/issues/60 notes that "Gal is working on it". I didn't find his repo. So let's track progress here! @hammerg , @YanVugenfirer invited ;)

bingzhangdai commented 4 years ago

I see. It seems that they are just two different implementations by using the same protocol called 9p. Here we are using one of them.

I think the qemu's doc should clarify this. https://qemu.readthedocs.io/en/latest/tools/virtiofsd.html and https://wiki.qemu.org/Documentation/9psetup use different device for 9p and people can easily get confused.

Thanks very much :)

idarlund commented 4 years ago

@idarlund Seems like you may have a duplicate issue to our friend just above here. -virtfs flag appears to be a sort of alias to the 9p-pci device rather than the device the driver is expecting vhost-user-fs-pci. If you're still having that issue, may want to try reviewing the above.

yeah, seems like it! will check out the guide!

r7l commented 4 years ago

Great to see Win10 drivers now but i am also supporting requests for Win7. Would be awesome!

daiaji commented 4 years ago

I don't seem to be able to write to the file.

rokups commented 4 years ago

I have stress tested this driver and i must say it's very unstable. I constantly get "qemu-system-x86_64: Failed to read from slave." on the command line. When this happens, only a reboot can bring back the drive in Windows. Please have a look! Edit: I saw that virtiofsd crashes with "Bad system call"

Can confirm. I actually got it to work once for a brief moment, then after subsequent restarts i always get Failed to read from slave. even though nothing changed in the setup.

kevinoid commented 4 years ago

This is great! Thanks for implementing it!

It appears that virtiofs.exe uses the UID/GID from the active console session when the process is started, so if it is run as a service with start=auto as in https://github.com/virtio-win/kvm-guest-drivers-windows/issues/126#issuecomment-667432487 (which is still very helpful!) it will require elevation to access (e.g. "You do not currently have permission to access this folder" from Explorer).

To work around this, I'm currently running virtiofs.exe from a scheduled task with logon trigger:

$action = New-ScheduledTaskAction -Execute "C:\Path\To\virtiofs.exe"
$trigger = New-ScheduledTaskTrigger -AtLogon
$principal = New-ScheduledTaskPrincipal 'NT AUTHORITY\SYSTEM'
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -ExecutionTimeLimit 0
$task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger -Settings $settings
Register-ScheduledTask Virtio-FS -InputObject $task

Unfortunately, I don't think this handles user switching correctly (since the process is not stopped on logout) or concurrent sessions by different users (not sure how this should be supported).

I also noticed that virtiofs.exe can be executed by users not in the Administrators group, who are then able to modify files on the host. Is this the expected behavior, or have I mis-configured permissions somehow?

fangying commented 4 years ago

Attention: I tried to make 9p running on a Windows host, NOT on a Windows guest!

The biggest obstacle is that the variants of open(root-directory,directory in this root-directory) is needed for security. The "normal" Win32 API can't do this, but the ntdll API can luckily archive this. Is a bit of pain because of conversions and the functions need to be called by getProcAddress, but it is doable. I'll search for my test code this evening. It can open a directory, but has e.g. stack corruption problems.

Hi @mifritscher

You have done a remarkable work ;) I'm very interesting in your work, and hope to support folder share between windows host and linux guest based on it, i noticed that you sent out a series "[Qemu-devel] Make 9pfs buildable for Windows" in 2017 year, but after that, i can't find next version of this series, I'd like to know if you have updated this series or not, and if it is possible, i can help to continue this work until it is been accepted in qemu upstream, looking forward to your reply ;)

Thanks.

r7l commented 4 years ago

Finally tried VirtFS on Win10. Somehow i am not able to copy large files from host to Windows guest. It works perfectly with small files but every larger file fails with an error about permissions. I don't really think it's permissions as i can copy small files into the same directory and i can also copy any file of any size from the guest system itself.

It works perfectly in with Linux guests and it also works perfectly to copy any file of any size from Windows guest to host.

Anyone else had this issue?

ttimpe commented 4 years ago

So VirtFS only creates a network device instead of a virtual removable drive?

DocMAX commented 4 years ago

No, the latest version of virtiofsd.exe can create a vistual physical drive, too!

ttimpe commented 4 years ago

No, the latest version of virtiofsd.exe can create a vistual physical drive, too!

How would I configure that? My current Proxmox KVM uses the following args: -virtfs local,path=/tank/storage,mount_tag=host0,security_model=passthrough,id=host0

I tried using the virtiofs drivers from the latest ISO but the device won't intialize.

hammerg commented 4 years ago

No, the latest version of virtiofsd.exe can create a vistual physical drive, too!

How would I configure that? My current Proxmox KVM uses the following args: -virtfs local,path=/tank/storage,mount_tag=host0,security_model=passthrough,id=host0

"-virtfs" is the another folder sharing based on 9P protocol. It doesn't have a Windows driver at the moment.

I tried using the virtiofs drivers from the latest ISO but the device won't intialize.

Look at https://virtio-fs.gitlab.io on how to configure QEMU.

muelli commented 4 years ago

ouf, the situation is quite confusing.

anthr76 commented 4 years ago

image Is anyone getting some ambiguous errors on Windows? This is creating a blank text file on the Windows Guest

InfinityGhost commented 4 years ago

image Is anyone getting some ambiguous errors on Windows? This is creating a blank text file on the Windows Guest

Getting this exact problem myself.

idarlund commented 4 years ago

image Is anyone getting some ambiguous errors on Windows? This is creating a blank text file on the Windows Guest

Getting this exact problem myself.

Can you add some more context? Such as how did you create the shared drive in qemu/libvirt, debug log from qemu, etc.

DocMAX commented 3 years ago

Anyone tested this with a NFS directory? It has unstable behavior. Deleting files result in ".nfs0000000..." files.

YanVugenfirer commented 3 years ago

Tried it out on Windows 10 LTSC 1803. Can confirm that there are some problems with larger files. Trying to copy any file with size over 2 megabytes from shared folder to VM disk results in permission errors. Opening those files directly somewhat works, depending on application (several GB archives can be successfully extracted with 7-zip, but opening PNGs in Windows Photo Viewer results in them being cut off from top). Did not reproduce the blank file bug mentioned above, it successfully created.

There is an issue for large files copy: #527

If you experience different issues, please open a new issue with a description.

menli820 commented 3 years ago

Can reproduce the issue if try to test with a NFS directory (rw)

  1. Try to create a folder on guest side, hit 'File Too Large' error described above.
  2. Try to delete a file , deleting files result in ".nfs0000000..." files.

pkg: qemu-kvm-5.2.0-14.module+el8.4.0+10425+ad586fa5.x86_64 kernel-4.18.0-287.el8.dt4.x86_64 seabios-1.13.0-2.module+el8.3.0+7353+9de0a3cc.x86_64 virtio-win-1.9.16-2.el8.iso

@hammerg is it a RFE if share a NFS? Should we file a bug to track this issue?

xiagao commented 3 years ago

Can reproduce the issue if try to test with a NFS directory (rw)

  1. Try to create a folder on guest side, hit 'File Too Large' error described above.
  2. Try to delete a file , deleting files result in ".nfs0000000..." files.

pkg: qemu-kvm-5.2.0-14.module+el8.4.0+10425+ad586fa5.x86_64 kernel-4.18.0-287.el8.dt4.x86_64 seabios-1.13.0-2.module+el8.3.0+7353+9de0a3cc.x86_64 virtio-win-1.9.16-2.el8.iso

@hammerg is it a RFE if share a NFS? Should we file a bug to track this issue?

This issue is tracked in downstream as well, will update here if there is process.

DocMAX commented 3 years ago

Please remove the need of WinFSP and create a full virtual volume in Windows.

Marietto2008 commented 2 years ago

Hello.

I've virtualized Windows 11 with bhyve on FreeBSD 13R and It seems to me that the virtio-9p and or the virtio-fs driver does not work. I don't see the folder "mnt" mounted on the root folder of Windows 11. Below you can see which parameters I've used :

bhyve -S -c 4 -m 8G -w -H \
-s 0,hostbridge \
-s 1,ahci-cd,/home/marietto/Downloads/virtio/virtio-win-0.1.208.iso \
-s 2,ahci-hd,/mnt/da0p1/Backups/OS/bhyve/Windows/win11.img \
-s 3,fbuf,tcp=0.0.0.0:5900,w=1440,h=900,wait \
-s 8,virtio-net,tap0 \
----> -s 9,virtio-9p,sharename=/mnt \
-s 30,xhci,tablet \
-s 31,lpc \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
vm0

Reading from this tutorial :

https://virtio-fs.gitlab.io/howto-windows.html

I've realized that there could be some kind of problem with the Win-Fsp- Windows File System Proxy and or with the virtio-fs PCI device driver because I'm not able to enable the virtio-fs service with the command used on the tutorial :

C:> sc start VirtioFsSvc

it gives the error : "the dependency service does not exist or it has been marked for the elimination.

I've attached some screenshots to help you to understand what's happening.

https://ibb.co/m5vm1hd https://ibb.co/Qd6TS5d https://ibb.co/3018SGd

xiagao commented 2 years ago

Hello.

I've virtualized Windows 11 with bhyve on FreeBSD 13R and It seems to me that the virtio-9p and or the virtio-fs driver does not work. I don't see the folder "mnt" mounted on the root folder of Windows 11. Below you can see which parameters I've used :

bhyve -S -c 4 -m 8G -w -H \
-s 0,hostbridge \
-s 1,ahci-cd,/home/marietto/Downloads/virtio/virtio-win-0.1.208.iso \
-s 2,ahci-hd,/mnt/da0p1/Backups/OS/bhyve/Windows/win11.img \
-s 3,fbuf,tcp=0.0.0.0:5900,w=1440,h=900,wait \
-s 8,virtio-net,tap0 \
----> -s 9,virtio-9p,sharename=/mnt \
-s 30,xhci,tablet \
-s 31,lpc \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
vm0

Reading from this tutorial :

https://virtio-fs.gitlab.io/howto-windows.html

I've realized that there could be some kind of problem with the Win-Fsp- Windows File System Proxy and or with the virtio-fs PCI device driver because I'm not able to enable the virtio-fs service with the command used on the tutorial :

C:> sc start VirtioFsSvc

it gives the error : "the dependency service does not exist or it has been marked for the elimination.

I've attached some screenshots to help you to understand what's happening.

https://ibb.co/m5vm1hd https://ibb.co/Qd6TS5d https://ibb.co/3018SGd

Hi, If you are using virtiofs,you must install Winfsp first.And you also need to add depend="WinFsp.Launcher/VirtioFsDrv" to the service creation command line.

If you still failed, you could try to start virtiofs.exe without registering virtiofs as a service such as cd xxxxxx/VioFS virtiofs.exe -d -1 -D -

Thanks, Xiaoling

Marietto2008 commented 2 years ago

Thanks. Unfortunately there are no virtio-9p drivers for Windows. Please use virtio-fs. Unfortunately for the 2 times,but bhyve does not support virtio-fs.

Il giorno mer 1 dic 2021 alle ore 03:24 Xiaoling_Gao < @.***> ha scritto:

Hello.

I've virtualized Windows 11 with bhyve on FreeBSD 13R and It seems to me that the virtio-9p and or the virtio-fs driver does not work. I don't see the folder "mnt" mounted on the root folder of Windows 11. Below you can see which parameters I've used :

bhyve -S -c 4 -m 8G -w -H \ -s 0,hostbridge \ -s 1,ahci-cd,/home/marietto/Downloads/virtio/virtio-win-0.1.208.iso \ -s 2,ahci-hd,/mnt/da0p1/Backups/OS/bhyve/Windows/win11.img \ -s 3,fbuf,tcp=0.0.0.0:5900,w=1440,h=900,wait \ -s 8,virtio-net,tap0 \ ----> -s 9,virtio-9p,sharename=/mnt \ -s 30,xhci,tablet \ -s 31,lpc \ -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \ vm0

Reading from this tutorial :

https://virtio-fs.gitlab.io/howto-windows.html

I've realized that there could be some kind of problem with the Win-Fsp- Windows File System Proxy and or with the virtio-fs PCI device driver because I'm not able to enable the virtio-fs service with the command used on the tutorial :

C:> sc start VirtioFsSvc

it gives the error : "the dependency service does not exist or it has been marked for the elimination.

I've attached some screenshots to help you to understand what's happening.

https://ibb.co/m5vm1hd https://ibb.co/Qd6TS5d https://ibb.co/3018SGd

Hi, If you are using virtiofs,you must install Winfsp first.And you also need to add depend="WinFsp.Launcher/VirtioFsDrv" to the service creation command line.

If you still failed, you could try to start virtiofs.exe without registering virtiofs as a service such as cd xxxxxx/VioFS virtiofs.exe -d -1 -D -

Thanks, Xiaoling

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/virtio-win/kvm-guest-drivers-windows/issues/126#issuecomment-983222999, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFYNC4I2RAPBFIT32L3LHLUOWBMVANCNFSM4DHR2XOQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Mario.

YanVugenfirer commented 2 years ago

Hello All,

Please help us understanding you use cases for using virtio-fs, and thus make us virtio-fs support better. Please participate in the discussion and add your use cases: https://github.com/virtio-win/kvm-guest-drivers-windows/discussions/726

Thanks a lot, Yan.

lbmeng commented 2 years ago

Note there is a recent patch series to support 9P on Windows on the QEMU side, see https://lore.kernel.org/qemu-devel/20220425142705.2099270-1-bmeng.cn@gmail.com/

Marietto2008 commented 2 years ago

Hello.

excuse me for my little knowledge,but I don't understand what to do to apply all the patches to add the 9P support to Windows. I'm talking about these patches :

@.***/

I would like to try if it works or not,but literally I don't know what to do. Can someone write a tutorial step by step ? thanks.

Il giorno ven 15 lug 2022 alle ore 04:22 Bin Meng @.***> ha scritto:

Note there is a recent patch series to support 9P on Windows on the QEMU side, see @.***/

— Reply to this email directly, view it on GitHub https://github.com/virtio-win/kvm-guest-drivers-windows/issues/126#issuecomment-1185101288, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFYNC7FCOP7QVV5BNPUQVTVUDDPDANCNFSM4DHR2XOQ . You are receiving this because you commented.Message ID: @.***>

-- Mario.

YanVugenfirer commented 2 years ago

@Marietto2008 Just to be clear - those are the patches that are enabling 9p support when QEMU runs on Windows host. This is not enablement of 9p support in Windows guest.

To apply patches, clone qemu repository, save patches from the mailbox, and use "git am" command to apply the patch series.

Marietto2008 commented 2 years ago

What happens if I emulate WIndows on Freebsd with bhyve,then I run qemu on Windows and qemu on Freebsd ? can I create a tunnel between the two qemus applying the patches on qemu for Windows and on qemu for FreeBSD ? Those patches can be applied also on the qemu which run on FreeBSD ? It seems to me that there is not need to run KVM in Windows,right ? Because this is the only thing I can't do,since bhyve does not support the nesting of the vms.

YanVugenfirer commented 2 years ago

I don't understand the scenario. What's the final goal? Is it to get virtio-fs in Windows guest (VM)? I don't think it will help. The patches are for QEMU when it runs on Windows (Windows acts as a host). So the virtiofsd, that allows the sharing on the host side will work on Windows.

YanVugenfirer commented 2 years ago

virtio-fs driver is part of the repository. virtio-9p support is not planned, but if you want to contribute (btw: you can use virtio-fs as an example) - you are welcomed.

Marietto2008 commented 2 years ago

I can help only as tester,but it makes no sense if there aren't programmers interested or if it is even not planned. I haven't any programming language competences.

sskras commented 2 years ago

@YanVugenfirer commented 43 minutes ago:

virtio-fs driver is part of the repository.

I guess, exact location of code is this: https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/viofs

YanVugenfirer commented 2 years ago

@YanVugenfirer commented 43 minutes ago:

virtio-fs driver is part of the repository.

I guess, exact location of code is this: https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/viofs

Yes.

ehntoo commented 2 years ago

@YanVugenfirer As VirtFS/virtio-9p support is not planned to be implemented, could this issue status be changed to closed as "not planned" rather than "completed"?

YanVugenfirer commented 2 years ago

@ehntoo virtio-fs is implemented. Virtio-9p is not planned.

Those are two different devices with similar purpose.

KOLANICH commented 2 years ago

Could it be ported to Windowa XP, which is still heavily used?

ehntoo commented 2 years ago

@YanVugenfirer I understand that virtfs/virtio-9p is not planned, and stated as such in my message. The title of this issue is "VirtFS / 9p support for Windows", and it is currently closed with a status of "completed". It would be helpful who are new to the project (as I was yesterday) if this issue was closed as "not planned" or similar.. :)

I spent a number of hours yesterday trying to figure out why a virtfs share was not mounting after seeing this issue was closed with an "completed" status.

YanVugenfirer commented 2 years ago

Again. Virtio-fs and virtio-9p are two different two different devices serving the same purpose from user point of view. Virtio-fs should be mounted. Try following the instructions: https://github.com/virtio-win/kvm-guest-drivers-windows/wiki/VirtIO-FS:-Shared-file-system

YanVugenfirer commented 2 years ago

Could it be ported to Windowa XP, which is still heavily used?

Theoretically it probably could. Practically we are not developing new features for OSes older than Window 8. It WinFsp supports Windows XP, the porting could be relatively simple.

ehntoo commented 2 years ago

@YanVugenfirer Please take a moment to read my message again. This issue title is for 9p support. 9p support is not planned. Can you change this issue status to "not planned"?

At least in qemu, "Virtfs" was commonly used to refer to virtio-9p support, which is why I was mentioning "VirtFS". The -virtfs flag in qemu sets up a virtio-9p device. https://wiki.qemu.org/Documentation/9psetup I understand very well that it is not the same as virtio-fs, and am not asking for any support or instruction on how to use this project.

lbmeng commented 2 years ago

Windows 9p support is planned. v2 patch will be sent to QEMU ML soon. Stay tuned.

Marietto2008 commented 2 years ago

Hello @lbmeng : what it means ? can we use v2 patch to create a virtio-9p driver for Windows 11 so that I can use virtio-9p in bhyve ? I'm not a bhyve developer,but I know one that can grab that patch and that can implement it inside the bhyve code. He already took some qemu code and has ported it to bhyve. I find very useful to share a folder between windows and freebsd in bhyve,in this way :


bhyve -S -c 4 -m 8G -w -H \
-s 0,hostbridge \
-s 1,ahci-cd,/home/marietto/Downloads/virtio/virtio-win-0.1.208.iso \
-s 2,ahci-hd,/mnt/da0p1/Backups/OS/bhyve/Windows/win11.img \
-s 3,fbuf,tcp=0.0.0.0:5900,w=1440,h=900,wait \
-s 8,virtio-net,tap0 \
----> -s 9,virtio-9p,sharename=/mnt \
-s 30,xhci,tablet \
-s 31,lpc \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
vm0
ehntoo commented 2 years ago

@lbmeng if you are referring to a v2 patch of your 9pfs host support patches in https://lists.gnu.org/archive/html/qemu-devel/2022-04/msg04075.html, this github issue is (or was originally) for windows support for mounting 9p in windows guests.

YanVugenfirer commented 2 years ago

Windows 9p support is planned. v2 patch will be sent to QEMU ML soon. Stay tuned.

I think you are confusing the support of 9p when QEMU is used in Windows host and the Windows guest driver. But if you are planning Windows guest 9p support, I will gladly review it.

lbmeng commented 2 years ago

@ehntoo @YanVugenfirer Thanks for helping clarfy the situation. I meant to share some information and do not mean to confuse anyone.

I know this thread was originally requesting 9p on Windows. I think it needs QEMU to support 9p on Windows first, then it's up to the team here to decide whether a Windows guest driver for 9p is planned or not.

Sorry for any confusion made.

YanVugenfirer commented 2 years ago

@ehntoo @YanVugenfirer Thanks for helping clarfy the situation. I meant to share some information and do not mean to confuse anyone.

I know this thread was originally requesting 9p on Windows. I think it needs QEMU to support 9p on Windows first, then it's up to the team here to decide whether a Windows guest driver for 9p is planned or not.

Sorry for any confusion made.

No problem :)