Eu criei um dispositivo de toque ( tap0
) que gostaria de fornecer como uma interface de rede para o qemu. Eu criei o dispositivo com o seguinte comando e o conectei a uma ponte de rede que eu configurei:
tunctl -t tap0
ifconfig tap0 up
brctl addif virbr0 tap0
Eu então executei os comandos sugeridos em esta resposta :
chgrp netdev /dev/net/tun
chmod 660 /dev/net/tun
Ambos os comandos foram concluídos com êxito e eu confirmei que eles entraram em vigor:
nathan@nathan-desktop:~$ stat /dev/net/tun
File: ‘/dev/net/tun’
Size: 0 Blocks: 0 IO Block: 4096 character special file
Device: 6h/6d Inode: 1224 Links: 1 Device type: a,c8
Access: (0660/crw-rw----) Uid: ( 0/ root) Gid: ( 108/ netdev)
Access: 2015-11-16 10:16:35.127338320 -0800
Modify: 2015-11-16 10:16:35.127338320 -0800
Change: 2015-11-16 10:37:18.338948110 -0800
Birth: -
Confirmei também que estou no grupo netdev
:
nathan@nathan-desktop:~$ groups
[...] netdev [...]
No entanto, quando tentei iniciar uma máquina virtual do qemu com a interface, encontrei o seguinte erro:
nathan@nathan-desktop:~$ qemu-system-arm [...] -net tap,ifname=tap0
qemu-system-arm: -net tap,ifname=tap0: could not configure /dev/net/tun (tap0): Operation not permitted
qemu-system-arm: -net tap,ifname=tap0: Device 'tap' could not be initialized
strace
A saída relevante de strace
é apresentada abaixo:
open("/dev/net/tun", O_RDWR) = 7
ioctl(7, TUNGETFEATURES, 0x7ffcc532ab2c) = 0
ioctl(7, TUNSETVNETHDRSZ, 0x7ffcc532ab28) = -1 EBADFD (File descriptor in bad state)
ioctl(7, TUNSETIFF, 0x7ffcc532ab30) = -1 EPERM (Operation not permitted)
write(2, "qemu-system-arm:", 16qemu-system-arm:) = 16
write(2, " -net", 5 -net) = 5
write(2, " tap,ifname=tap0", 16 tap,ifname=tap0) = 16
write(2, ": ", 2: ) = 2
write(2, "could not configure /dev/net/tun"..., 64could not configure /dev/net/tun (tap0): Operation not permitted) = 64
write(2, "\n", 1
) = 1
close(7) = 0
write(2, "qemu-system-arm:", 16qemu-system-arm:) = 16
write(2, " -net", 5 -net) = 5
write(2, " tap,ifname=tap0", 16 tap,ifname=tap0) = 16
write(2, ": ", 2: ) = 2
write(2, "Device 'tap' could not be initia"..., 37Device 'tap' could not be initialized) = 37
write(2, "\n", 1
)