cirruslabs / tart

macOS and Linux VMs on Apple Silicon to use in CI and other automations
https://tart.run
Other
3.67k stars 103 forks source link

Open file count keeps increasing #700

Closed gsakun closed 6 months ago

gsakun commented 6 months ago

Description: I have been using Tart to launch a macos virtual machine and mount a local directory. Within the macos virtual machine, I have a Python script that downloads files into the mounted directory. While the file handles in the virtual machine are functioning properly, I have noticed an issue on the host machine. The number of file handles keeps increasing and does not get released, leading to potential resource exhaustion. Steps to reproduce:

  1. Launch tart and create a macos virtual machine. Mount a local directory within the virtual machine using TART.
    tart run mac-vm-2 --dir=workspace:/Users/akun/workspace --no-graphics
  2. Enter the virtual machine
  3. echo 111 >> /Volumes/My\ Shared\ Files/workspace/test.txt
  4. lsof |grep test.txt no response
  5. exit return to host machine
  6. lsof |grep test.txt will return
    com.apple 83360 akun   14r      REG               1,17           4            11434466 /Users/akun/build_dir/workspace/test.txt

    Expected behavior: The file handles on the host machine should be released after the virtual machine finishes executing the script, preventing a continuous increase in file handle usage.

Actual behavior: The file handles on the host machine keep increasing and are not released, which could potentially lead to resource exhaustion.

Additional information:

fkorotkov commented 6 months ago

Just to clarify. Do you shutdown the VM? Or just the script execution and the VM keeps running?

If the latter, then unfortunately it might be an expected behavior due to VirtioFS. With VirtioFS there is a "server" running on the host and guest VirtioFS drivers talks to it via API to read/write files.

We'll dig a bit more but wanted to clarify if you shutdown the VM.

gsakun commented 6 months ago

Just to clarify. Do you shutdown the VM? Or just the script execution and the VM keeps running?

If the latter, then unfortunately it might be an expected behavior due to VirtioFS. With VirtioFS there is a "server" running on the host and guest VirtioFS drivers talks to it via API to read/write files.

We'll dig a bit more but wanted to clarify if you shutdown the VM.

No,VM keeps running

fkorotkov commented 6 months ago

With a little bit more investigation it seems like the behavior of VirtioFS support in macOS which we don't have control of.