]> git.ipfire.org Git - thirdparty/qemu.git/commit
tap: setting error appropriately when calling net_init_tap_one()
authorJay Zhou <jianjay.zhou@huawei.com>
Fri, 2 Mar 2018 09:04:44 +0000 (17:04 +0800)
committerJason Wang <jasowang@redhat.com>
Mon, 5 Mar 2018 02:30:16 +0000 (10:30 +0800)
commit46d4d36d0bf2b24b205f2f604f0905db80264eef
tree0b165bbdc0a9ba3f24fe13243aab59f47a230271
parentb20219b6451546b9664ceae471b2622b54f0a4bd
tap: setting error appropriately when calling net_init_tap_one()

If netdev_add tap,id=net0,...,vhost=on failed in net_init_tap_one(),
the followed up device_add virtio-net-pci,netdev=net0 will fail
too, prints:

   TUNSETOFFLOAD ioctl() failed: Bad file descriptor TUNSETOFFLOAD
   ioctl() failed: Bad file descriptor

The reason is that the fd of tap is closed when error occured after
calling net_init_tap_one().

The fd should be closed when calling net_init_tap_one failed:
   - if tap_set_sndbuf() failed
   - if tap_set_sndbuf() succeeded but vhost failed to open or
     initialize with vhostforce flag on
   - with wrong vhost command line parameter
The fd should not be closed just because vhost failed to open or
initialize but without vhostforce flag. So the followed up
device_add can fall back to userspace virtio successfully.

Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Suggested-by: Igor Mammedov <imammedo@redhat.com>
Suggested-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
include/net/vhost_net.h
net/tap.c