quickemu-project / quickemu

Quickly create and run optimised Windows, macOS and Linux virtual machines
MIT License
10.88k stars 478 forks source link

fix: specify helper to qemu #1421

Open NicGrimpe opened 3 months ago

NicGrimpe commented 3 months ago

Description

Without this change I could not launch a vm with a network configured. network="br0"

failed to create tun device: Operation not permitted
qemu-system-x86_64: -nic bridge,br=br0,model=virtio-net-pci: bridge helper failed

Tested on nixos. Maybe there is a better way to get it to work, feel free to let me know and close this PR in that case :)

Type of change

Bug fix (non-breaking change which fixes an issue)

Checklist:

2b commented 1 month ago

Hi! Thank you for the fix!

Maybe this should be fixed at the package.nix level, if it's NixOS-specific. What do you think? In the meantime, here is a Nix overlay for anyone who stumbled upon this, like me:

final: prev: {
  quickemu = prev.quickemu.overrideAttrs (oldAttrs: {
    postPatch = (oldAttrs.postPatch or "") + ''
      substituteInPlace quickemu \
        --replace-fail 'args+=(-nic bridge,br=''${network},model=virtio-net-pci''${MAC})' \
                       'args+=(-nic bridge,br=''${network},helper=$(type -p qemu-bridge-helper),model=virtio-net-pci''${MAC})'
    '';
  });
}