tap: set vhostfd passed from qemu cli to non-blocking
PATCH 1/1 tap: set vhostfd passed from qemu cli to non-blocking
A guest boot hangs while probing the network interface when iommu_platform=on is used.
The following qemu cli hangs without this patch:
# $QEMU \
-netdev tap,fd=3,id=hostnet0,vhost=on,vhostfd=4 3<>/dev/tap67 4<>/dev/host-net \
-device virtio-net-pci,netdev=hostnet0,id=net0,iommu_platform=on,disable-legacy=on \
...
Commit: c471ad0e9bd46 (vhost_net: device IOTLB support) took care of setting vhostfd to non-blocking when QEMU opens /dev/host-net but if the fd is passed from qemu cli then we need to ensure that fd is set to non-blocking.
--- net/tap.c | 1 + 1 file changed, 1 insertion(+)
net/tap.c +1 -0
@@ -693,6 +693,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, }return ; } +fcntl (vhostfd,F_SETFL ,O_NONBLOCK ); }else { vhostfd =open ("/dev/vhost-net" ,O_RDWR );if (vhostfd <0 ) {
Signature · 1 line
2.14.3
Quoted 28 lines · Brijesh Singh
A guest boot hangs while probing the network interface when iommu_platform=on is used.
The following qemu cli hangs without this patch:
# $QEMU \
-netdev tap,fd=3,id=hostnet0,vhost=on,vhostfd=4 3<>/dev/tap67 4<>/dev/host-net \
-device virtio-net-pci,netdev=hostnet0,id=net0,iommu_platform=on,disable-legacy=on \
...Commit:
c471ad0e9bd46(vhost_net: device IOTLB support) took care of setting vhostfd to non-blocking when QEMU opens/dev/host-netbut if the fd is passed from qemu cli then we need to ensure that fd is set to non-blocking.Fixes c471ad0e9bd46 "vhost_net: device IOTLB support"Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Signed-off-by Brijesh Singh <[email protected]>--- net/tap.c | 1 + 1 file changed, 1 insertion(+)net/tap.c +0
-0
net/tap.c static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, · line 696
Quoted 4 lines
net/tap.c +1
-0@@ -693,6 +693,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, }return ; } +fcntl (vhostfd,F_SETFL ,O_NONBLOCK );
Please use qemu_set_nonblock() instead.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 24 lines · Eric Blake
Quoted 23 lines · Brijesh Singh
A guest boot hangs while probing the network interface when iommu_platform=on is used.
The following qemu cli hangs without this patch:
# $QEMU \ -netdev tap,fd=3,id=hostnet0,vhost=on,vhostfd=4 3<>/dev/tap67 4<>/dev/host-net \ -device virtio-net-pci,netdev=hostnet0,id=net0,iommu_platform=on,disable-legacy=on \ ...Commit:
c471ad0e9bd46(vhost_net: device IOTLB support) took care of setting vhostfd to non-blocking when QEMU opens/dev/host-netbut if the fd is passed from qemu cli then we need to ensure that fd is set to non-blocking.Fixes c471ad0e9bd46 "vhost_net: device IOTLB support"Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Signed-off-by Brijesh Singh <[email protected]>--- net/tap.c | 1 + 1 file changed, 1 insertion(+)
Quoted 12 lines
net/tap.c static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, · line 696
Quoted 9 lines
net/tap.c +1
-0@@ -693,6 +693,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, }return ; } +fcntl (vhostfd,F_SETFL ,O_NONBLOCK );Please use
qemu_set_nonblock()instead.
Sure will do.
Quoted 15 lines · Brijesh Singh
A guest boot hangs while probing the network interface when iommu_platform=on is used.
The following qemu cli hangs without this patch:
# $QEMU \
-netdev tap,fd=3,id=hostnet0,vhost=on,vhostfd=4 3<>/dev/tap67 4<>/dev/host-net \
-device virtio-net-pci,netdev=hostnet0,id=net0,iommu_platform=on,disable-legacy=on \
...Commit:
c471ad0e9bd46(vhost_net: device IOTLB support) took care of setting vhostfd to non-blocking when QEMU opens/dev/host-netbut if the fd is passed from qemu cli then we need to ensure that fd is set to non-blocking.
Quoted 4 lines
Fixes c471ad0e9bd46 "vhost_net: device IOTLB support"Cc Michael S. Tsirkin <[email protected]>Cc Jason Wang <[email protected]>Signed-off-by Brijesh Singh <[email protected]>
Quoted 18 lines
--- net/tap.c | 1 + 1 file changed, 1 insertion(+)net/tap.c +1
-0@@ -693,6 +693,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, }return ; } +fcntl (vhostfd,F_SETFL ,O_NONBLOCK ); }else { vhostfd =open ("/dev/vhost-net" ,O_RDWR );if (vhostfd <0 ) {Signature · 1 line
2.14.3