tap-device, multi-queue: enforce single-queue tap
When netlink creates the tap device, and a single queue is
requested, it mistakingly uses the multi-queue flags: [0].
Until [1] is fixed, we need to explicitly indicate we're using the
single-queue flags.
[0]
[1]
@@ -20,6 +20,14 @@ func createTapDevice(name string, owner uint, group uint, queueNumber int) error
Group: uint32(group),
}
+ // when netlink receives a request for a tap device with 1 queue, it uses
+ // the MULTI_QUEUE flag, which differs from libvirt; as such, we need to
+ // manually request the single queue flags, enabling libvirt to consume
+ // the tap device.
+ // See https://github.com/vishvananda/netlink/issues/574
+ if queueNumber == 1 {
+ tapDevice.Flags = netlink.TUNTAP_DEFAULTS
+ }
if err := netlink.LinkAdd(tapDevice); err != nil {
return fmt.Errorf("failed to create tap device named %s. Reason: %v", name, err)
}
