kvm-guest-drivers-windows icon indicating copy to clipboard operation
kvm-guest-drivers-windows copied to clipboard

how to use virtiofs in Windows 10 guest?

Open alex1258840 opened this issue 4 years ago • 48 comments

how to use virtiofs in Windows 10 guest? I install VIRTIO FS Driver

alex1258840 avatar Jun 29 '20 10:06 alex1258840

where did you get this driver? it's not included yet.

DocMAX avatar Jul 07 '20 20:07 DocMAX

Assuming that qemu and virtiofsd are set and running on the host and you know how to compile the project for Windows you need to do the following: Install WinFsp, install the virtiofs Windows driver and then run the virtiofs service.

hammerg avatar Jul 08 '20 09:07 hammerg

I'm getting this with service The service VirtIO-FS has failed to start (Status=c0000008). when starting it from command line, can't start it whatsoever, rest seems fine, driver installed fine and is displayed in devices

After adding it services via sc.exe when staring manually I;m getting " the handle is invalid"

barolo avatar Jul 08 '20 22:07 barolo

ok i managed to compile viofs.sys driver. i added the following line to my vm: -virtfs local,path=/mnt/t420/hdd,mount_tag=host0,security_model=passthrough,id=host0. i get a new pci device in device manager (1AF4:1009). but it doesnt seem to fit with viofs.inf (seems to be for 1AF4:105A). so how does it all work now? edit: followed https://virtio-fs.gitlab.io/howto-qemu.html and now i'm getting the correct device (mass storage, i wonder what the other one is). but still cant install. when installing the driver it says error: device was not migrated due to partial or ambiguous match edit2: now i disabled driver integrity check and enabled win10 test mode. the error changed to error 52: the digital signature can't be checked. edit3: ok got it working. somehow the driver integrity check was still enabled. looking good now. but it's mounted as network drive. can this be mounted as local disk drive?

DocMAX avatar Jul 09 '20 13:07 DocMAX

I'm getting this with service The service VirtIO-FS has failed to start (Status=c0000008). when starting it from command line, can't start it whatsoever, rest seems fine, driver installed fine and is displayed in devices

After adding it services via sc.exe when staring manually I;m getting " the handle is invalid"

When you run virtiofs.exe from command line, was it in an Administrator console (Run as...)?

hammerg avatar Jul 13 '20 09:07 hammerg

ok i managed to compile viofs.sys driver. i added the following line to my vm: -virtfs local,path=/mnt/t420/hdd,mount_tag=host0,security_model=passthrough,id=host0. i get a new pci device in device manager (1AF4:1009). but it doesnt seem to fit with viofs.inf (seems to be for 1AF4:105A). so how does it all work now?

Virtfs and virtio-fs are two different implementations of the shared files feature (PCI devices and protocols).

edit: followed https://virtio-fs.gitlab.io/howto-qemu.html and now i'm getting the correct device (mass storage, i wonder what the other one is). but still cant install. when installing the driver it says error: device was not migrated due to partial or ambiguous match

Where did you saw this error message? On Windows?

edit2: now i disabled driver integrity check and enabled win10 test mode. the error changed to error 52: the digital signature can't be checked. edit3: ok got it working. somehow the driver integrity check was still enabled. looking good now. but it's mounted as network drive. can this be mounted as local disk drive?

I submitted a patch which mount the shared folder as a disk drive (and remove the network option for now).

hammerg avatar Jul 13 '20 09:07 hammerg

I'm getting this with service The service VirtIO-FS has failed to start (Status=c0000008). when starting it from command line, can't start it whatsoever, rest seems fine, driver installed fine and is displayed in devices After adding it services via sc.exe when staring manually I;m getting " the handle is invalid"

When you run virtiofs.exe from command line, was it in an Administrator console (Run as...)?

Yes, tried it via admin console and later via services panel after registering it. Same issue

barolo avatar Jul 13 '20 10:07 barolo

When you run virtiofs.exe from command line, was it in an Administrator console (Run as...)?

Yes, tried it via admin console and later via services panel after registering it. Same issue

Can you please try to run it from a "normal" cmd? (BTW do you have WinFsp installed?) Thanks.

hammerg avatar Jul 13 '20 10:07 hammerg

I had the same issue. Turned out the driver was not installed correctly (yellow exl. mark)

DocMAX avatar Jul 13 '20 12:07 DocMAX

I have WinFS installed, its dev stuff was necessary for compilation. What was the proper way to install the drivet? Mine seems fine, win is in testing mode

barolo avatar Jul 13 '20 13:07 barolo

Does running with debug logs (virtiofs.exe -d -1 -D -) show useful information?

I'm using the Device Manager to install the driver (Right-click on the Mass Storage Device and Install Driver). Windows should be with "bcdedit /set testsigning on" (and follow with a reboot), the driver file should be self-signed with a certificate that is in the Trusted Root Certificate store.

Double-click on the driver after it was installed should show "This device is working properly." in the Device status.

hammerg avatar Jul 13 '20 15:07 hammerg

It means that it isn't signed properly doesn't it?

image

barolo avatar Jul 13 '20 15:07 barolo

Yep. You should sign the viofs.sys file and install the certificate you signed the driver with to the "Trusted Root Certificates" store.

hammerg avatar Jul 13 '20 15:07 hammerg

Ok, I'm trying to figure it out, MS documentation is particularly obtuse Edit. Painfull but I did it. Onward

barolo avatar Jul 13 '20 15:07 barolo

Ok, driver installed, service installed, no error, but now I'm getting this on the host side

qemu-system-x86_64: Failed initializing vhost-user memory map, consider using -object memory-backend-file share=on
qemu-system-x86_64: vhost_set_mem_table failed: Interrupted system call (4)
qemu-system-x86_64: Error starting vhost: 4

or when started as root

qemu-system-x86_64: Failed initializing vhost-user memory map, consider using -object memory-backend-file share=on
qemu-system-x86_64: vhost_set_mem_table failed: Resource temporarily unavailable (11)
qemu-system-x86_64: Error starting vhost: 11

barolo avatar Jul 13 '20 16:07 barolo

I submitted a patch which mount the shared folder as a disk drive (and remove the network option for now).

thank you

DocMAX avatar Jul 13 '20 21:07 DocMAX

Ok, driver installed, service installed, no error, but now I'm getting this on the host side

qemu-system-x86_64: Failed initializing vhost-user memory map, consider using -object memory-backend-file share=on
qemu-system-x86_64: vhost_set_mem_table failed: Interrupted system call (4)
qemu-system-x86_64: Error starting vhost: 4

or when started as root

qemu-system-x86_64: Failed initializing vhost-user memory map, consider using -object memory-backend-file share=on
qemu-system-x86_64: vhost_set_mem_table failed: Resource temporarily unavailable (11)
qemu-system-x86_64: Error starting vhost: 11

What command line are you using to run qemu? It should include something like:

        -chardev socket,id=char0,path=/tmp/vhostqemu \
        -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on -numa node,memdev=mem \
        -device vhost-user-fs-pci,queue-size=1024,chardev=char0,tag=myfs \

hammerg avatar Jul 14 '20 06:07 hammerg

The doc that I was following lacked the -object ... tidbit. Thanks, will test it in a bit

barolo avatar Jul 14 '20 11:07 barolo

It works! I just had to adjust memory of -object memory-backend-file to match systems memory. I have permissions issue in mounted folder though, is it read only? Virtiofsd is started with sudo, also as soon as I click properties in mounted folder machine crashes It;s quite performant when copying into VM

barolo avatar Jul 14 '20 19:07 barolo

It works! I just had to adjust memory of -object memory-backend-file to match systems memory.

Nice ;-).

I have permissions issue in mounted folder though, is it read only? Virtiofsd is started with sudo, also as soon as I click properties in mounted folder machine crashes

Virtio-fs is not a read-only file system. What are the permissions of the shared folder on the host side?

Do you mean Windows crash? Or QEMU? If it Windows can you send me the Windows coredump? It will help me if you can explain with a bit more details on how to reproduce it.

It;s quite performant when copying into VM

I'm not sure what you mean here. Is it too slow?

hammerg avatar Jul 15 '20 05:07 hammerg

I meant that it's fast. Is there plan to enable it RW eventually? It was a qemu crash

barolo avatar Jul 15 '20 14:07 barolo

I meant that it's fast. Is there plan to enable it RW eventually?

It is RW now. At least on my setup...

It was qemu crash

Cool. Do you have a coredump?

hammerg avatar Jul 15 '20 14:07 hammerg

Oh, nvm about RW then, I've read you wrong. Host folder permissions are drwxrwxrwx owned by current [ non root ] user I'm yet to carsh it again, I'll send one your way if

barolo avatar Jul 15 '20 22:07 barolo

Hi, today I installed virtiofs dirver from fedora ISO v0.1.187 and had some fun with it. I can reproduce @barolo's permission problem to some extent, it seems I'm able to create new files but can't however modify files already there, even those that were created from the VM. The folder is owned by the same user that's running qemu (which, incidentally, is my user as I've changed default settings for unrelated reasons), the chmod is set to 777.

Steps to reproduce:

  1. Share a folder, make sure permissions are as permissive as possible (777)
  2. In windows, create new TXT file
  3. Try to edit and save said TXT file.

tkolo avatar Aug 05 '20 00:08 tkolo

@tkolo there's issue #483 of virtiofsd quitting prematurely which might be related

barolo avatar Aug 05 '20 12:08 barolo

@tkolo Yes, there seems to be some problems with permissions. Even if I use the permissions of 777, I can only create a folder, not create new text in the created folder.

daiaji avatar Aug 15 '20 14:08 daiaji

With permission 777 on the host folder, I have strange behavior in the guest windows:

  • can only create new folders but not normal files (new folder is the only option in the context menu)
  • when creating new folder, 4 folders got created ("New Folder", "New Folder (1)", "New Folder (2)", "New Folder (3)")
  • when copying a normal file, I got promoted there is already a file with the same name

So it looks like the file creation is repeated many times.

Aetf avatar Oct 01 '20 05:10 Aetf

This

With permission 777 on the host folder, I have strange behavior in the guest windows:

  • can only create new folders but not normal files (new folder is the only option in the context menu)
  • when creating new folder, 4 folders got created ("New Folder", "New Folder (1)", "New Folder (2)", "New Folder (3)")
  • when copying a normal file, I got promoted there is already a file with the same name

So it looks like the file creation is repeated many times.

This issue seems to be related to WinFSP actually. I have the exact same issue with sshfs-Win and WinFSP. If I run the VM under VirtualBox it works properly. If the same VM (converted) runs under KVM I have the issue.

Tried to do a research but found nothing. Weird the same approach works in VBox but not KVM. Some driver issue perhaps.

jakubklos77 avatar Oct 21 '20 11:10 jakubklos77

Excuse me, is there any progress?

daiaji avatar Nov 17 '20 14:11 daiaji

I am also experiencing the same issue. I'm not very familiar with how this stuff works, but might this be related: https://github.com/billziss-gh/winfsp/issues/204?

StevenDoesStuffs avatar Jan 19 '21 06:01 StevenDoesStuffs

With permission 777 on the host folder, I have strange behavior in the guest windows:

  • can only create new folders but not normal files (new folder is the only option in the context menu)
  • when creating new folder, 4 folders got created ("New Folder", "New Folder (1)", "New Folder (2)", "New Folder (3)")
  • when copying a normal file, I got promoted there is already a file with the same name

So it looks like the file creation is repeated many times.

I have the same symptoms as Aetf above. If I create a folder 4 get created. If I create a file Windows tell me it already exists. It is still created but it is empty. I have Fedora 33 as host, Win 10 (1809), WINFSP 2020.1 & virtio-win-0.1.190.iso. I followed this https://virtio-fs.gitlab.io/howto-windows.html

mgjadoul avatar Jan 22 '21 19:01 mgjadoul

I figured it is simply not usable on Windows. Tried all of the available methods and the only way to get this working is the samba. Not happy about it but it works ok.

jakubklos77 avatar Jan 23 '21 09:01 jakubklos77

https://virtio-fs.gitlab.io/howto-windows.html https://libvirt.org/kbase/virtiofs.html Under the guidance of these two tutorials, I successfully got virtiofs to work, but when I rebooted the VM, the virtiofsd in the host did not seem to be restarted. But when I shut down the VM and booted the VM again, virtiofsd seemed to be started again. Is this a bug in libvirt?

daiaji avatar Feb 12 '21 10:02 daiaji

I tend to believe this issue has been finally solved. kvm-guest-drivers-windows/issues/550

marcello-pietrobon avatar Feb 21 '21 02:02 marcello-pietrobon

@marcello-pietrobon I compiled the virtiofs.exe of the master branch. However, after the VM restarts, the virtiofsd process on the host still does not restart. This seems to be two different problems.

daiaji avatar Mar 11 '21 11:03 daiaji

Hmm, read/write works when you manually start virtiofs.exe manually from an command shell but is read-only when started as a service. 🤷‍♂️

For the moment I just created a batch file in C:\Users\Windows User\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup that contains start "vfio-fs" /min "C:\Program Files\Virtio-Win\VioFS\virtiofs.exe" -m z:

fubar-1 avatar May 18 '21 02:05 fubar-1

Hi @Dave--G,

Hmm, read/write works when you manually start virtiofs.exe manually from an command shell but is read-only when started as a service. man_shrugging

This sound like an issue we had and was resolved. Does you virtiofs service file included commit #525 ?

For the moment I just created a batch file in C:\Users\Windows User\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup that contains start "vfio-fs" /min "C:\Program Files\Virtio-Win\VioFS\virtiofs.exe" -m z:

Thanks,

Gal.

hammerg avatar May 26 '21 09:05 hammerg

I'm using virtiofs from virtio-win version 190 obtained here https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.190-1/ which appear to be dated 2020/11/24. It may not contain commit #525 (?) Is a more recent signed build available? I'm looking and can't find anything more recent.

Thanks

fubar-1 avatar May 27 '21 00:05 fubar-1

I have similar issues regarding write access to the host with virtio-win 208, running a Windows 10 20H2 guest on an Ubuntu 20.04.3 host, and reported them to the virtiofs mailing list, see https://listman.redhat.com/archives/virtio-fs/2021-October/msg00185.html. They are not yet resolved. Problem investigation is complex due to two operating systems with different security models and several pieces of software on host and guest being involved. It seems to me that the file owner on the host is not correctly reported to the guest, but I don't know whether the problem is on the host (qemu, virtiofsd) or guest (virtio-win, WinFsp) side. For the time being, and as a temporary solution, I use one of the following 2 workarounds whenever I need to write or delete a file on the host from the guest:

I use a shell (Windows CMD or Cygwin bash) with Administrator rights on the guest OR I change the folder/file permissions on the host as needed, giving write permissions to "other".

ohrenkram avatar Oct 27 '21 08:10 ohrenkram

  • on kvm / virt manager (of ubuntu 21.04). have a win10 guest machine
  • installed virtio guest additions from the fedora ISO today. onto win10 lcsc 10.0.17763 build 17763
  • from the fedora downloads section, version virtio-win-0.1.208
  • installed winFSP too, and the service WinFsp.Launcher look in 'running' state
  • tried to run the service virtiofs.exe
The service VirtIO-FS has failed to start (Status=c00000008)

🤷 will installing a newer version of windows (eg win11) help anything here? or be a waste of time? because win11 just by itself can be some extra challenges to install

dreamcat4 avatar Dec 07 '21 14:12 dreamcat4

Hi @dreamcat4,

  • on kvm / virt manager (of ubuntu 21.04). have a win10 guest machine
  • installed virtio guest additions from the fedora ISO today. onto win10 lcsc 10.0.17763 build 17763
  • from the fedora downloads section, version virtio-win-0.1.208
  • installed winFSP too, and the service WinFsp.Launcher look in 'running' state
  • tried to run the service virtiofs.exe
The service VirtIO-FS has failed to start (Status=c00000008)

Could you please show your libvirt virtiofs XML configuration?

It should look something like that:

<filesystem type="mount" accessmode="passthrough">
  <driver type="virtiofs"/>
  <source dir="/home/vp/vms/viofs"/>
  <target dir="mount_tag"/>
  <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
</filesystem>

shrug will installing a newer version of windows (eg win11) help anything here? or be a waste of time? because win11 just by itself can be some extra challenges to install

You're right, it will be a waste of time.

viktor-prutyanov avatar Dec 07 '21 15:12 viktor-prutyanov

lol thanks so much man! yeah it was wrong config there...

<filesystem type="mount" accessmode="mapped">
  <source dir="/tmp/share"/>
  <target dir="/share-vfiofs"/>
  <readonly/>
  <alias name="fs0"/>
  <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
</filesystem>

so i changed edited to match yours. Then it said SHM was disabled. Great! because now I can go enable that in the CPU config tabs. And it should then appear in the guest. Which is a fantastic progress.

...not to say it wont still be broken for whatever other reasons, but at least can get a bit further along the journey. Thanks so much! Very grateful

dreamcat4 avatar Dec 07 '21 15:12 dreamcat4

so i changed edited to match yours. Then it said SHM was disabled.

This is because memory should be also configured in a proper way:

  <memoryBacking>
    <source type="memfd"/>
    <access mode="shared"/>
  </memoryBacking>

viktor-prutyanov avatar Dec 07 '21 15:12 viktor-prutyanov

yep, just added it in. after finding it a linux guide page for virtiofs

https://libvirt.org/kbase/virtiofs.html

[EDIT] it worked! thanks so very much @viktor-prutyanov Screenshot from 2021-12-07 15-57-23

dreamcat4 avatar Dec 07 '21 15:12 dreamcat4

I come to the conclusion that this still needs some thinking before it works.

My intent is to share a file system from the linux host to the windows guest. I think I am not the only one in this case.

But the windows Guest is using/seeing an NTFS file system and the linux host is seing an ext4fs (or other unix) filesystem. Therefor the first question is how is the user in windows guest mapped to the user in linux host?

But just after.... when this will eventually work.... what about the fact that NTFS is case insensitive and the Unix FS is case sensitive?

And so on....

Samba or NFS sharing through the network do this out of the box. The current virtiofs solution, lacks something to do the conversion.

An idea could be to agree that the shared filesystem is an NTFS4G filesystem on the linux host. I did not tried, but I do not expect it to work OOB. Or may be a FAT32 filesystem.... But I expect that the virtiofs.exe component would need to be extended to take this into account.

mgjadoul avatar Jan 17 '22 19:01 mgjadoul

I come to the conclusion that this still needs some thinking before it works.

My intent is to share a file system from the linux host to the windows guest. I think I am not the only one in this case.

But the windows Guest is using/seeing an NTFS file system and the linux host is seing an ext4fs (or other unix) filesystem. Therefor the first question is how is the user in windows guest mapped to the user in linux host?

But just after.... when this will eventually work.... what about the fact that NTFS is case insensitive and the Unix FS is case sensitive?

The case-insensitive issue is also tracked in downstream. And the other are really good points. Thank you.

And so on....

Samba or NFS sharing through the network do this out of the box. The current virtiofs solution, lacks something to do the conversion.

An idea could be to agree that the shared filesystem is an NTFS4G filesystem on the linux host. I did not tried, but I do not expect it to work OOB. Or may be a FAT32 filesystem.... But I expect that the virtiofs.exe component would need to be extended to take this into account.

xiagao avatar Jan 19 '22 05:01 xiagao

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.

YanVugenfirer avatar Jan 31 '22 12:01 YanVugenfirer

Hmm, I've the problem that virtiofs.exe didn't start on windows 11. I'm using an older version of win virtio of 0.215.2, because it is the newest stable version for windows as the newer ones have currently a bug. There is simply no output of virtiofs.exe in cmd, starting it over services.msc marks it as failstart. What can I do?

sighoya avatar Apr 29 '22 18:04 sighoya

The question to original issue: https://github.com/virtio-win/kvm-guest-drivers-windows/wiki/VirtIO-FS:-Shared-file-system

Please don't mix different topics in one in issue. If anyone experiencing issues with virtio-fs, please open a separate issue.

YanVugenfirer avatar Sep 05 '22 13:09 YanVugenfirer