BBVA/kvm

RancherOS: tap could not be initialized

pwFoo opened this issue ยท 3 comments

pwFoo commented

Try to start the container with (AUTO_ATTACH=y, working with container interfaces):

docker run -p 5900:5900 -p 2222:22 -p 4444:4444 -td --name kvm --privileged -v /home/rancher/image.qcow2:/image/image.qcow2 -e AUTO_ATTACH=y bbvainnotech/kvm:latest

docker logs kvm:

Lauching dnsmasq                                    --dhcp-option=option:dns-server,8.8.8.8,8.8.4.4                  --dhcp-option=option:router,172.17.0.1                    

dnsmasq: bad dhcp-range at line 1 of /etc/dnsmasq.d/eth0.conf
Launching /usr/libexec/qemu-kvm -enable-kvm   -drive file=/image/image.qcow2,if=none,id=drive-ide0-0-0,format=qcow2,cache=writethrough   -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-1,bootindex=1      -machine rhel6.0.0,accel=kvm,usb=off   -nodefaults   -no-acpi   -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2   -realtime mlock=off   -msg timestamp=on   -chardev pty,id=charserial0   -device isa-serial,chardev=charserial0,id=serial0   -serial stdio    -m 1024 -smp 4,sockets=4,cores=1,threads=1    -device virtio-net-pci,netdev=net0,mac=16:a5:26:d0:e8:43 -netdev tap,id=net0,vhost=on,fd=3 3<>/dev/macvtap0
char device redirected to /dev/pts/0 (label charserial0)
2016-10-05T08:19:47.042107Z qemu-kvm: -netdev tap,id=net0,vhost=on,fd=3: vhost-net requested but could not be initialized
2016-10-05T08:19:47.043419Z qemu-kvm: -netdev tap,id=net0,vhost=on,fd=3: Device 'tap' could not be initialized

Tried additional options alone and also combined like that:

docker run -p 5900:5900 -p 2222:22 -p 4444:4444 -td --name kvm --privileged -v /home/rancher/image.qcow2:/image/image.qcow2 -e AUTO_ATTACH=y -v /lib/modules:/lib/modules -v /lib64/modules:/lib64/modules -v /dev:/dev -v /sys:/sys bbvainnotech/kvm:latest

But tap problem still there:

2016-10-05T08:19:47.042107Z qemu-kvm: -netdev tap,id=net0,vhost=on,fd=3: vhost-net requested but could not be initialized
2016-10-05T08:19:47.043419Z qemu-kvm: -netdev tap,id=net0,vhost=on,fd=3: Device 'tap' could not be initialized

I don't know how I solved this yesterday with many different attempts...

So I added bash as CMD and manually executed /usr/local/bin/startvm.

cat: /sys/class/net/macvtap0/address: No such file or directory
cat: /sys/devices/virtual/net/macvtap0/tap*/dev: No such file or directory
mknod: missing operand after 'c'
Special files require major and minor device numbers.
Try 'mknod --help' for more information.
Lauching dnsmasq                                    --dhcp-option=option:dns-server,8.8.8.8,8.8.4.4                  --dhcp-option=option:router,172.17.0.1                    

dnsmasq: bad dhcp-range at line 1 of /etc/dnsmasq.d/eth0.conf
Launching /usr/libexec/qemu-kvm -enable-kvm   -drive file=/image/image.qcow2,if=none,id=drive-ide0-0-0,format=qcow2,cache=writethrough   -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-1,bootindex=1      -machine rhel6.0.0,accel=kvm,usb=off   -nodefaults   -no-acpi   -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2   -realtime mlock=off   -msg timestamp=on   -chardev pty,id=charserial0   -device isa-serial,chardev=charserial0,id=serial0   -serial stdio    -m 1024 -smp 4,sockets=4,cores=1,threads=1    -device virtio-net-pci,netdev=net0,mac= -netdev tap,id=net0,vhost=on,fd=3 3<>/dev/macvtap0
char device redirected to /dev/pts/6 (label charserial0)
2016-10-05T08:32:10.319878Z qemu-kvm: -netdev tap,id=net0,vhost=on,fd=3: TUNGETIFF ioctl() failed: Inappropriate ioctl for device
TUNSETOFFLOAD ioctl() failed: Inappropriate ioctl for device
2016-10-05T08:32:10.321238Z qemu-kvm: -netdev tap,id=net0,vhost=on,fd=3: vhost-net requested but could not be initialized
2016-10-05T08:32:10.321937Z qemu-kvm: -netdev tap,id=net0,vhost=on,fd=3: Device 'tap' could not be initialized

Now it tried it with --net=host to attach just the host eth1 to the VM.
docker run -p 5900:5900 -p 2222:22 -p 4444:4444 -td --name kvm --privileged -v /home/rancher/image.qcow2:/image/image.qcow2 -e AUTO_ATTACH=n -e ATTACH_IFACES=eth1 --net=host bbvainnotech/kvm:latest bash

Entered the container with docker exec -ti kvm bash and launched the startvm script:

/usr/local/bin/startvm: line 75: /8: syntax error: operand expected (error token is "/8")
Lauching dnsmasq                                    --dhcp-option=option:dns-server,8.8.8.8,8.8.4.4                  --dhcp-option=option:router,192.168.200.1                     --dhcp-option=option:domain-name,fam-hoeg.de

dnsmasq: bad dhcp-range at line 1 of /etc/dnsmasq.d/eth1.conf
Launching /usr/libexec/qemu-kvm -enable-kvm   -drive file=/image/image.qcow2,if=none,id=drive-ide0-0-0,format=qcow2,cache=writethrough   -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-1,bootindex=1      -machine rhel6.0.0,accel=kvm,usb=off   -nodefaults   -no-acpi   -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2   -realtime mlock=off   -msg timestamp=on   -chardev pty,id=charserial0   -device isa-serial,chardev=charserial0,id=serial0   -serial stdio    -m 1024 -smp 4,sockets=4,cores=1,threads=1    -device virtio-net-pci,netdev=net0,mac=76:20:fd:95:1e:b8 -netdev tap,id=net0,vhost=on,fd=3 3<>/dev/macvtap0
char device redirected to /dev/pts/0 (label charserial0)
2016-10-05T08:35:38.277312Z qemu-kvm: -netdev tap,id=net0,vhost=on,fd=3: vhost-net requested but could not be initialized
2016-10-05T08:35:38.277966Z qemu-kvm: -netdev tap,id=net0,vhost=on,fd=3: Device 'tap' could not be initialized

So what's missing here? Any kernel module to load? Tested it with macvtap un-/loaded. Both with the same result...

pwFoo commented

@methadata
Solution is to load a needed kernel modul first!

sudo modprobe vhost-net

Maybe you could add this information to a troubleshooting section?

Great! ๐Ÿ‘

I suggest you to contribute yourself if you wish, creating a pull request directly from github and editing the readme.md file.

Anyway, it seems that this issue is happening only with RancherOS, right? I have tried the container with Ubuntu 16.04 and Centos Atomic 16.07

pwFoo commented

I'll take a look how to create a pull requests. Haven't done this before.

Thanks for your awesome work with this project!!! ๐Ÿ‘