qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
28.04k stars 3.96k forks source link

`Errored: Invalid Argument` when downloading to Qemu shared directory #21217

Closed rgri closed 2 months ago

rgri commented 2 months ago

qBittorrent & operating system versions

qBittorrent: 4.6.5 x64 Operating system: NixOS 24.11.20240809.5e0ca22 (Vicuna) Qt: 6.7.2 Libtorrent: 2.0.10.0 Boost: 1.81.0 OpenSSL: 3.0.14 zlib: 1.3.1

What is the problem?

In a qemu VM, qBittorrent will download perhaps .1-.5% of a torrent which targets a directory shared between the host and guest before stopping with Errored: Invalid Argument.

Steps to reproduce

On non-NixOS (I don't have a non-NixOS computer to test with)

  1. Start a qemu VM with a flag like: -virtfs local,path=/home/USER/temp,security_model=none,mount_tag=temp
  2. Attempt to download a torrent with the "Save at" field set to a path under /home/USER/temp

On NixOS (easiest if you do not have knowledge of qemu, and how I've tested this)

  1. Import this module into your config and nixos-rebuild build-vm:
    { config, lib, pkgs, ... }:
    let USER = "";
    in {
    virtualisation.vmVariant.virtualisation.sharedDirectories."temp" = {
    target = "/home/${USER}/temp";
    source = "/home/${USER}/temp";
    };
    }
  2. Attempt to download a torrent with the "Save at" field set to a path under /home/USER/temp

Additional context

No response

Log(s) & preferences file(s)

preferences_logs.zip

rgri commented 2 months ago

I fixed this by mounting the drive with the option cache=mmap[1], which is not set on NixOS by default when creating virtual machines with nixos-rebuild build-vm. Attached is a screenshot of the working /etc/fstab line. workingfstab

Also, here is the nixos option I used to set this flag:

virtualisation.vmVariant.virtualisation.fileSystems."/home/USER/Videos/Media".options =
      [ "cache=mmap" ];
Joniator commented 2 months ago

Thank you, I've had the same issue in an Unraid VM running in the docker image on ubuntu, with the download dir set to my Unraid Share mount (9p/virtio) for quite some time, and worked around it by downloading to my os and then move it to the share.

This was the tip I needed, adding a cache=mmap to my /etc/fstab fixed it: media /mnt/media 9p [...],cache=mmap 0 0