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

virtio-fs cannot support "cargo bulid" #517

Closed
XeCycle opened this issue Nov 4, 2020 · 7 comments
Closed

virtio-fs cannot support "cargo bulid" #517

XeCycle opened this issue Nov 4, 2020 · 7 comments
Assignees
Labels
Bug Bug Not virtio-win Not related to virtio-win project virtio-fs

Comments

@XeCycle
Copy link

XeCycle commented Nov 4, 2020

Running cargo build in a typical rust project on virtio-fs mount (something as simple as cargo new helloworld can reproduce it), will fail saying cannot canonicalize paths; mounting to a new drive letter or a junction point makes no difference. I tried cargo build --target-dir=C:\somewhere-else, same error. Seems rust tools insist on using paths with symlinks resolved, but the current implementation based on winfsp does not support that; cmake-based c++ projects work fine, in contrast, however only if build tree is not on virtio-fs. The opposite would fail, too, with some cryptic message I don't understand; no idea whether that's intended.

Versions:

  • Windows 10
  • virtiofsd as shipped with qemu 5.1.0, packaged by arch
  • guest driver 0.1.189
<viofs/w10/amd64 $ ll
.r-xr-xr-x 9.3Ki xecycle 10 Aug 12:17 viofs.cat*
.r-xr-xr-x 2.4Ki xecycle 10 Aug  8:51 viofs.inf*
.r-xr-xr-x 956Ki xecycle 10 Aug  8:51 viofs.pdb*
.r-xr-xr-x  54Ki xecycle 10 Aug 12:17 viofs.sys*
.r-xr-xr-x 117Ki xecycle 10 Aug 12:18 virtiofs.exe*
.r-xr-xr-x 3.1Mi xecycle 10 Aug  8:51 virtiofs.pdb*
<viofs/w10/amd64 $ sha1sum *
2574e91a5d5f9cd4e28f871c90cac8140b0ed9b4  viofs.cat
85a3a16108ea5bf5032d2959e4b460aed3764ed1  viofs.inf
8993fce1cfc6bce7011f0d2d94b35d39076a2e28  viofs.pdb
9819cec611918f9b62500204cc25cdd2948c36a3  viofs.sys
313f7a0c5f8c22a85f5ffeeb567690e5a3d5775d  virtiofs.exe
a896ac7cfaeb7f1a5f93513517e1897d6d685baa  virtiofs.pdb

Btw. a simple test of fio fio-rand-RW.fio (basically the one from fio examples) says virtio-fs is slower than samba, in this random 4k read-write-mixed test. Do we intend to outperform samba?

@hammerg
Copy link

hammerg commented Dec 29, 2020

Thanks for trying virtio-fs for Windows. Are you sure the cargo failure is a result of unresolved symbolic links? Because at the moment symbolic links are not supported.

The performance comparison and optimization (if required ;-)) are planned after virtio-fs will be more stable and usable.

@XeCycle
Copy link
Author

XeCycle commented Dec 30, 2020

@hammerg Actually my paths contains no symlinks; somehow, if mounted to a junction point, that point looks like a symlink.

Example of error message when mounted at a drive letter (error is similar if on a junction point):

PS Z:\work\test\rust\hello> C:\Users\Administrator\.cargo\bin\cargo build --target-dir=C:\build\rshello                                                       
warning: could not canonicalize path: 'Z:\work\test\rust\hello'                                                                                               
warning: could not canonicalize path: 'Z:\work\test\rust\hello'                                                                                   
warning: could not canonicalize path: 'Z:\work\test\rust'                                                                                                     
warning: could not canonicalize path: 'Z:\work\test'                                                                                              
warning: could not canonicalize path: 'Z:\work'                                                                                                               
warning: could not canonicalize path: 'Z:\'                                                                                                       
   Compiling hello v0.1.0 (Z:\work\test\rust\hello)                                                                                                           
error: could not parse/generate dep info at: C:\build\rshello\debug\deps\hello.d                                                                              
                                                                                                                                                              
Caused by:
  此卷不包含可识别的文件系统。
  请确定所有请求的文件系统驱动程序已加载,且此卷未损坏。 (os error 1005)

and the error code is defined as:

ERROR_UNRECOGNIZED_VOLUME

1005 (0x3ED)

The volume does not contain a recognized file system. Please make sure that all required file system drivers are loaded and that the volume is not corrupted.

@xiagao
Copy link

xiagao commented May 12, 2021

@XeCycle
We have a bug to track this issue in downstream, if there is process, I will update here.

@viktor-prutyanov
Copy link
Collaborator

Cargo is a Rust software. Rust's fs::canonicalize has problems with network drives and some filesystems:
rust-lang/rustup#682
rust-lang/rust#86447

This is how fs::canonicalize calls GetFinalPathNameByHandleW with VOLUME_NAME_DOS argument:
https://github.com/rust-lang/rust/blob/7be8693984d32d2f65ce9ded4f65b6b7340bddce/library/std/src/sys/windows/fs.rs#L875

Small sample with GetFinalPathNameByHandle with VOLUME_NAME_DOS invocation:
https://gist.github.com/viktor-prutyanov/1d8680f19e200d0079cb47bf8057bf4a

This is how it reacts to VirtIO-FS path:

PS C:\Users\Administrator\source\repos\GetPath\x64\Debug> .\GetPath.exe X:\testfile.txt
GetFinalPathNameByHandle (error 1005)

ERROR_UNRECOGNIZED_VOLUME (1005):
The volume does not contain a recognized file system. Please make sure that all required file system drivers are loaded and that the volume is not corrupted.

For example, output for NTFS path:

PS C:\Users\Administrator\source\repos\GetPath\x64\Debug> .\GetPath.exe C:\Windows\System32\notepad.exe
The final path is: \\?\C:\Windows\System32\notepad.exe

WinFSP MemFS shows exactly the same behaviour as VirtIO-FS does. Looks like it is WinFSP limitation.

By the way, GetFinalPathNameByHandle with VOLUME_NAME_NT works:

The final path is: \Device\Volume{60e35478-7719-11ec-b332-525400f94cb9}\testfile.txt

@YanVugenfirer YanVugenfirer added Not virtio-win Not related to virtio-win project and removed Not virtio-win Not related to virtio-win project labels Jan 17, 2022
@viktor-prutyanov viktor-prutyanov added the Bug Bug label Jan 17, 2022
@viktor-prutyanov
Copy link
Collaborator

Hi @XeCycle,

According to winfsp/winfsp#410, to make GetFinalPathNameByHandle (and thus fs::canonicalize) work with WinFsp one can set mount point \\.\Z: instead of Z:.

For now, it can be done through registry: reg add HKLM\Software\VirtIO-FS /v MountPoint /d \\.\Z:

After that, cargo will work with VirtIO-FS:

Z:\>cargo new helloworld
     Created binary (application) `helloworld` package

Z:\>cd helloworld

Z:\helloworld>cargo run
   Compiling helloworld v0.1.0 (Z:\helloworld)
    Finished dev [unoptimized + debuginfo] target(s) in 0.67s
     Running `target\debug\helloworld.exe`
Hello, world!

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

@XeCycle
Copy link
Author

XeCycle commented Feb 2, 2022

Thanks @viktor-prutyanov and @YanVugenfirer, I switched to smb last year and have not found time to verify this. Now that you have verified the fix I think we can just close this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Not virtio-win Not related to virtio-win project virtio-fs
Projects
None yet
Development

No branches or pull requests

5 participants