Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use virtiofs in Windows 10 guest? #473

Closed
alex1258840 opened this issue Jun 29, 2020 · 50 comments
Closed

how to use virtiofs in Windows 10 guest? #473

alex1258840 opened this issue Jun 29, 2020 · 50 comments
Assignees

Comments

@alex1258840
Copy link

alex1258840 commented Jun 29, 2020

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

@DocMAX
Copy link

DocMAX commented Jul 7, 2020

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

@hammerg
Copy link

hammerg commented Jul 8, 2020

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.

@barolo
Copy link

barolo commented Jul 8, 2020

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"

@DocMAX
Copy link

DocMAX commented Jul 9, 2020

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?

@hammerg
Copy link

hammerg commented Jul 13, 2020

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
Copy link

hammerg commented Jul 13, 2020

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).

@barolo
Copy link

barolo commented Jul 13, 2020

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

@hammerg
Copy link

hammerg commented Jul 13, 2020

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.

@DocMAX
Copy link

DocMAX commented Jul 13, 2020

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

@barolo
Copy link

barolo commented Jul 13, 2020

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

@hammerg
Copy link

hammerg commented Jul 13, 2020

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.

@barolo
Copy link

barolo commented Jul 13, 2020

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

image

@hammerg
Copy link

hammerg commented Jul 13, 2020

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

@barolo
Copy link

barolo commented Jul 13, 2020

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

@barolo
Copy link

barolo commented Jul 13, 2020

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

@DocMAX
Copy link

DocMAX commented Jul 13, 2020

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

thank you

@hammerg
Copy link

hammerg commented Jul 14, 2020

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 \

@barolo
Copy link

barolo commented Jul 14, 2020

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

@barolo
Copy link

barolo commented Jul 14, 2020

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

@hammerg
Copy link

hammerg commented Jul 15, 2020

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?

@barolo
Copy link

barolo commented Jul 15, 2020

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

@hammerg
Copy link

hammerg commented Jul 15, 2020

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?

@barolo
Copy link

barolo commented Jul 15, 2020

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

@tkolo
Copy link

tkolo commented Aug 5, 2020

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.

@barolo
Copy link

barolo commented Aug 5, 2020

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

@daiaji
Copy link

daiaji commented Aug 15, 2020

@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.

@Aetf
Copy link

Aetf commented Oct 1, 2020

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.

@jakubklos77
Copy link

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.

@daiaji
Copy link

daiaji commented Nov 17, 2020

Excuse me, is there any progress?

@StevenDoesStuffs
Copy link

I am also experiencing the same issue. I'm not very familiar with how this stuff works, but might this be related: winfsp/winfsp#204?

@mgjadoul
Copy link

mgjadoul commented Jan 22, 2021

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

@jakubklos77
Copy link

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.

@daiaji
Copy link

daiaji commented Feb 12, 2021

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?

@marcello-pietrobon
Copy link

marcello-pietrobon commented Feb 21, 2021

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

@daiaji
Copy link

daiaji commented Mar 11, 2021

@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.

@fubar-1
Copy link

fubar-1 commented May 18, 2021

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:

@hammerg
Copy link

hammerg commented May 26, 2021

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.

@fubar-1
Copy link

fubar-1 commented May 27, 2021

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

@ohrenkram
Copy link

ohrenkram commented Oct 27, 2021

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".

@dreamcat4
Copy link

dreamcat4 commented Dec 7, 2021

  • 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

@viktor-prutyanov
Copy link
Collaborator

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.

@dreamcat4
Copy link

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

@viktor-prutyanov
Copy link
Collaborator

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>

@dreamcat4
Copy link

dreamcat4 commented Dec 7, 2021

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

@mgjadoul
Copy link

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.

@xiagao
Copy link

xiagao commented Jan 19, 2022

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.

@YanVugenfirer
Copy link
Collaborator

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: #726

Thanks a lot,
Yan.

@sighoya
Copy link

sighoya commented Apr 29, 2022

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?

@YanVugenfirer
Copy link
Collaborator

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.

@caohuilong
Copy link

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.

Just create a virtiofs service and set it to auto start, then reboot the system, all will be right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests