Skip to contentSkip to conversation

tap: set vhostfd passed from qemu cli to non-blocking

PATCH In review Brijesh Singh 3 participants 5 messages Apr 6, 2018 – May 21, 2018 Networking

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

Fixes c471ad0e9bd46 "vhost_net: device IOTLB support"
Cc Michael S. Tsirkin <[email protected]>
Cc Jason Wang <[email protected]>

---

Changes since v1:
- use qemu_set_nonblock() instead of fcntl(..)

 net/tap.c | 2 ++
 1 file changed, 2 insertions(+)
net/tap.c +2 -0
index 2b3a36f9b50d..89c4e19162a2 100644
@@ -40,6 +40,7 @@
 #include "qemu-common.h"
 #include "qemu/cutils.h"
 #include "qemu/error-report.h"
+#include "qemu/sockets.h"
 
 #include "net/tap.h"
 
@@ -693,6 +694,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
                 }
                 return;
             }
+            qemu_set_nonblock(vhostfd);
         } else {
             vhostfd = open("/dev/vhost-net", O_RDWR);
             if (vhostfd < 0) {
Signature · 1 line
2.14.3
Reviewed-by on v2 1/1
#1 lore raw
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-net but 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]>
Quoted 30 lines

---

Changes since v1:
- use qemu_set_nonblock() instead of fcntl(..)

 net/tap.c | 2 ++
 1 file changed, 2 insertions(+)
net/tap.c +2 -0
index 2b3a36f9b50d..89c4e19162a2 100644
@@ -40,6 +40,7 @@
 #include "qemu-common.h"
 #include "qemu/cutils.h"
 #include "qemu/error-report.h"
+#include "qemu/sockets.h"
 
 #include "net/tap.h"
 
@@ -693,6 +694,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
                 }
                 return;
             }
+            qemu_set_nonblock(vhostfd);
         } else {
             vhostfd = open("/dev/vhost-net", O_RDWR);
             if (vhostfd < 0) {
Signature · 1 line
2.14.3
#2 lore raw

Hi Michael and Jason,

Looks like this patch was not included in any of your pull request hence it didn't made into 2.12. Can you please include this patch in your next pull request?

~ Brijesh

Quoted 53 lines · Michael S. Tsirkin
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-net but 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]>
Quoted 30 lines

---

Changes since v1:
- use qemu_set_nonblock() instead of fcntl(..)

  net/tap.c | 2 ++
  1 file changed, 2 insertions(+)
net/tap.c +2 -0
index 2b3a36f9b50d..89c4e19162a2 100644
@@ -40,6 +40,7 @@
  #include "qemu-common.h"
  #include "qemu/cutils.h"
  #include "qemu/error-report.h"
+#include "qemu/sockets.h"
 
  #include "net/tap.h"
 
@@ -693,6 +694,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
                  }
                  return;
              }
+            qemu_set_nonblock(vhostfd);
          } else {
              vhostfd = open("/dev/vhost-net", O_RDWR);
              if (vhostfd < 0) {
Signature · 1 line
2.14.3
#3 lore raw
Quoted 7 lines · Brijesh Singh

Hi Michael and Jason,

Looks like this patch was not included in any of your pull request hence it didn't made into 2.12. Can you please include this patch in your next pull request?

~ Brijesh

I reviewed.
Jason?
Cc stable I guess ...

Quoted 52 lines · Michael S. Tsirkin
Quoted 51 lines · Brijesh Singh
Quoted 15 lines

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.

Quoted 4 lines
Fixes c471ad0e9bd46 "vhost_net: device IOTLB support"
Cc Michael S. Tsirkin <[email protected]>
Cc Jason Wang <[email protected]>
Quoted 28 lines

---

Changes since v1:
- use qemu_set_nonblock() instead of fcntl(..)

  net/tap.c | 2 ++
  1 file changed, 2 insertions(+)
net/tap.c +2 -0
index 2b3a36f9b50d..89c4e19162a2 100644
@@ -40,6 +40,7 @@
  #include "qemu-common.h"
  #include "qemu/cutils.h"
  #include "qemu/error-report.h"
+#include "qemu/sockets.h"
  #include "net/tap.h"
@@ -693,6 +694,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
                  }
                  return;
              }
+            qemu_set_nonblock(vhostfd);
          } else {
              vhostfd = open("/dev/vhost-net", O_RDWR);
              if (vhostfd < 0) {
Signature · 1 line
2.14.3
#4 lore raw
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Brijesh Singh

Hi Michael and Jason,

Looks like this patch was not included in any of your pull request hence it didn't made into 2.12. Can you please include this patch in your next pull request?

Quoted 5 lines
Quoted 1 line

~ Brijesh

I reviewed.
Jason?
Cc stable I guess ...

Yes. Applied.

Thanks