nixpkgs/lib/qemu-flags.nix
Eelco Dolstra 2e38d8cd31 * ZOMG, fixed a giant bug in the networking of distributed VM tests.
It turns out that all network interfaces in all VMs had the same
  Ethernet address (52:54:00:12:34:56) because we didn't specify any
  with the macaddr=... option.  This can obviously lead to great
  confusion.  For instance, when a router forwards a packet, it can
  actually end up sending the packet to itself because the target
  machine has the same Ethernet address (causing a loop until the TTL
  expires), while the target *also* receives the packet.  It's amazing
  anything worked at all, really.

  So now we just set the Ethernet addresses to 52:54:00:12:<virtual
  network number>:<machine number>.

svn path=/nixos/trunk/; revision=25020
2010-12-07 00:44:29 +00:00

16 lines
605 B
Nix

# QEMU flags shared between various Nix expressions.
{
qemuNICFlags = nic: net: machine:
"-net nic,vlan=${toString nic},macaddr=52:54:00:12:${toString net}:${toString machine},model=virtio " +
# Use 232.0.1.<vlan> as the multicast address to connect VMs on
# the same vlan, but allow it to be overriden using the
# $QEMU_MCAST_ADDR_<vlan> environment variable. The test driver
# sets this variable to prevent collisions between parallel
# builds.
"-net socket,vlan=${toString nic},mcast=" +
"\${QEMU_MCAST_ADDR_${toString net}:-232.0.1.${toString net}:1234} ";
}