Skip to contentSkip to conversation

net/virtio: fix multi-queue negotiation

PATCH In review Marcel Apfelbaum 4 participants 8 messages Jun 18, 2015 – Jun 26, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/virtio: fix multi-queue negotiation

Clear host multi-queue related features if the peer doesn't support it.

---
Notes:
This fixes a guest CPU soft lock, however the virtio-net device will not work correctly. It seems that is peer's "fault", not knowing how to handle the situation. However, I submit this patch since it corrects the negotiation and saves us from a guest crash (!).

Any ideas from the virtio/multi-queue developers on how to debug this further are welcomed.

 hw/net/virtio-net.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +12 -1
index 9281aa1..63e59e8 100644
@@ -367,6 +367,11 @@ static int peer_has_ufo(VirtIONet *n)
     return n->has_ufo;
 }
 
+static int peer_has_multiqueue(VirtIONet *n)
+{
+    return n->multiqueue;
+}
+
 static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs,
                                        int version_1)
 {
@@ -469,6 +474,13 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features)
         virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO);
     }
 
+    if (!peer_has_multiqueue(n)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_MQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_VQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_RX);
+    }
+
     if (!get_vhost_net(nc->peer)) {
         virtio_add_feature(&features, VIRTIO_F_VERSION_1);
         return features;
@@ -1314,7 +1326,6 @@ static void virtio_net_tx_bh(void *opaque)
 static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)
 {
     n->multiqueue = multiqueue;
-
     virtio_net_set_queues(n);
 }
 
Signature · 1 line
2.1.0
#1 lore raw
Quoted 38 lines · Marcel Apfelbaum

Clear host multi-queue related features if the peer doesn't support it.

---
Notes:
This fixes a guest CPU soft lock, however the virtio-net device will not work correctly. It seems that is peer's "fault", not knowing how to handle the situation. However, I submit this patch since it corrects the negotiation and saves us from a guest crash (!).

Any ideas from the virtio/multi-queue developers on how to debug this further are welcomed.

 hw/net/virtio-net.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +5 -0
index 9281aa1..63e59e8 100644
@@ -367,6 +367,11 @@ static int peer_has_ufo(VirtIONet *n)
     return n->has_ufo;
 }
 
+static int peer_has_multiqueue(VirtIONet *n)
+{
+    return n->multiqueue;
+}
+
 static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs,
                                        int version_1)
 {
@@ -469,6 +474,13 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features)
         virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO);
     }
 

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) · line 486

Quoted 10 lines
hw/net/virtio-net.c +7 -0
+    if (!peer_has_multiqueue(n)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_MQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_VQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_RX);
+    }
+
     if (!get_vhost_net(nc->peer)) {
         virtio_add_feature(&features, VIRTIO_F_VERSION_1);
         return features;

_MQ makes sense but what about the rest? Why clear them?

Quoted 10 lines
hw/net/virtio-net.c +0 -1
@@ -1314,7 +1326,6 @@ static void virtio_net_tx_bh(void *opaque)
 static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)
 {
     n->multiqueue = multiqueue;
-
     virtio_net_set_queues(n);
 }
 
Signature · 1 line
2.1.0
#2 lore raw
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Marcel Apfelbaum

Clear host multi-queue related features if the peer doesn't support it.

---
Notes:
This fixes a guest CPU soft lock, however the virtio-net device will not work correctly. It seems that is peer's "fault", not knowing how to handle the situation. However, I submit this patch since it corrects the negotiation and saves us from a guest crash (!).

Any ideas from the virtio/multi-queue developers on how to debug this further are welcomed.

  hw/net/virtio-net.c | 13 ++++++++++++-
  1 file changed, 12 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +5 -0
index 9281aa1..63e59e8 100644
@@ -367,6 +367,11 @@ static int peer_has_ufo(VirtIONet *n)
      return n->has_ufo;
  }
 
+static int peer_has_multiqueue(VirtIONet *n)
+{
+    return n->multiqueue;
+}
+
  static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs,
                                         int version_1)
  {
@@ -469,6 +474,13 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features)
          virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO);
      }
 
Quoted 12 lines

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) · line 486

Quoted 10 lines
hw/net/virtio-net.c +7 -0
+    if (!peer_has_multiqueue(n)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_MQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_VQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_RX);
+    }
+
      if (!get_vhost_net(nc->peer)) {
          virtio_add_feature(&features, VIRTIO_F_VERSION_1);
          return features;

_MQ makes sense but what about the rest? Why clear them?

Guest's virtio driver doesn't like if MQ is off and any of the other flags remains ON. It has a specific check for each of them and fails the loading if not all are off.

Thanks,
Marcel

Quoted 11 lines
Quoted 11 lines
hw/net/virtio-net.c +0 -2
@@ -1314,7 +1326,6 @@ static void virtio_net_tx_bh(void *opaque)
  static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)
  {
      n->multiqueue = multiqueue;
-
      virtio_net_set_queues(n);
  }
 
--

2.1.0

#3 lore raw
Quoted 52 lines · Marcel Apfelbaum
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Marcel Apfelbaum

Clear host multi-queue related features if the peer doesn't support it.

---
Notes:
This fixes a guest CPU soft lock, however the virtio-net device will not work correctly. It seems that is peer's "fault", not knowing how to handle the situation. However, I submit this patch since it corrects the negotiation and saves us from a guest crash (!).

Any ideas from the virtio/multi-queue developers on how to debug this further are welcomed.

 hw/net/virtio-net.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +5 -0
index 9281aa1..63e59e8 100644
@@ -367,6 +367,11 @@ static int peer_has_ufo(VirtIONet *n)
     return n->has_ufo;
 }
 
+static int peer_has_multiqueue(VirtIONet *n)
+{
+    return n->multiqueue;
+}
+
 static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs,
                                        int version_1)
 {
@@ -469,6 +474,13 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features)
         virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO);
     }
 
Quoted 12 lines

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) · line 486

Quoted 10 lines
hw/net/virtio-net.c +7 -0
+    if (!peer_has_multiqueue(n)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_MQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_VQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_RX);
+    }
+
     if (!get_vhost_net(nc->peer)) {
         virtio_add_feature(&features, VIRTIO_F_VERSION_1);
         return features;

_MQ makes sense but what about the rest? Why clear them?

Quoted 5 lines

Guest's virtio driver doesn't like if MQ is off and any of the other flags remains ON. It has a specific check for each of them and fails the loading if not all are off.

Thanks,
Marcel

I think you are mistaken.

        if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) &&
            (VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_CTRL_RX,
                             "VIRTIO_NET_F_CTRL_VQ") ||
             VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_CTRL_VLAN,
                             "VIRTIO_NET_F_CTRL_VQ") ||
             VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE,
                             "VIRTIO_NET_F_CTRL_VQ") ||
             VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_MQ, "VIRTIO_NET_F_CTRL_VQ") ||
             VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR,
                             "VIRTIO_NET_F_CTRL_VQ"))) {
                return false;
        }

        return true;

So if CTRL VQ is not set, you can not have MQ or any of the others.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
hw/net/virtio-net.c +0 -2
@@ -1314,7 +1326,6 @@ static void virtio_net_tx_bh(void *opaque)
 static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)
 {
     n->multiqueue = multiqueue;
-
     virtio_net_set_queues(n);
 }
 
--

2.1.0

#5 lore raw
In reply to Marcel Apfelbaum
Quoted 11 lines · Marcel Apfelbaum

Clear host multi-queue related features if the peer doesn't support it.

---
Notes:
This fixes a guest CPU soft lock, however the virtio-net device will not work correctly. It seems that is peer's "fault", not knowing how to handle the situation. However, I submit this patch since it corrects the negotiation and saves us from a guest crash (!).

Could you please describe how to reproduce this issue?

Quoted 12 lines

Any ideas from the virtio/multi-queue developers on how to debug this further are welcomed.

 hw/net/virtio-net.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +0 -0
index 9281aa1..63e59e8 100644

hw/net/virtio-net.c static int peer_has_ufo(VirtIONet *n) · line 373

Quoted 7 lines
hw/net/virtio-net.c +4 -0
@@ -367,6 +367,11 @@ static int peer_has_ufo(VirtIONet *n)
     return n->has_ufo;
 }
 
+static int peer_has_multiqueue(VirtIONet *n)
+{
+    return n->multiqueue;
+}

The name is confusing, this is in fact whether or not guest support multiqueue. To check peer's ability, you need check n->nic_conf.peers.queues instead.

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) · line 478

Quoted 10 lines
hw/net/virtio-net.c +3 -0
+
 static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs,
                                        int version_1)
 {
@@ -469,6 +474,13 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features)
         virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO);
     }
 
+    if (!peer_has_multiqueue(n)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_MQ);

I'm not quite understand this, VIRTIO_NET_F_MQ should work if peer has only 1 queue.

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) · line 483

Quoted 5 lines
hw/net/virtio-net.c +5 -0
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_VQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_RX);
+    }
+

Those features don't depend on multiqueue, why clear them?

Quoted 11 lines
hw/net/virtio-net.c +0 -1
     if (!get_vhost_net(nc->peer)) {
         virtio_add_feature(&features, VIRTIO_F_VERSION_1);
         return features;
@@ -1314,7 +1326,6 @@ static void virtio_net_tx_bh(void *opaque)
 static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)
 {
     n->multiqueue = multiqueue;
-
     virtio_net_set_queues(n);
 }
 
#6 lore raw
Quoted 15 lines · Jason Wang
Quoted 11 lines · Marcel Apfelbaum

Clear host multi-queue related features if the peer doesn't support it.

---
Notes:
This fixes a guest CPU soft lock, however the virtio-net device will not work correctly. It seems that is peer's "fault", not knowing how to handle the situation. However, I submit this patch since it corrects the negotiation and saves us from a guest crash (!).

Quoted 1 line

Could you please describe how to reproduce this issue?

Hi Jason,
Sorry for the late reply.
I was hoping that a vhost-user multi-queue "insider" will ask questions :)

This happens when we have OVS as backend without multi-queue support and qemu/guest with multi-queue-support.

Quoted 16 lines
Quoted 16 lines

Any ideas from the virtio/multi-queue developers on how to debug this further are welcomed.

  hw/net/virtio-net.c | 13 ++++++++++++-
  1 file changed, 12 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +0 -0
index 9281aa1..63e59e8 100644
@@ -367,6 +367,11 @@ static int peer_has_ufo(VirtIONet *n)
      return n->has_ufo;
  }
 
Quoted 8 lines

hw/net/virtio-net.c static int peer_has_ufo(VirtIONet *n) · line 373

Quoted 4 lines
hw/net/virtio-net.c +4 -0
+static int peer_has_multiqueue(VirtIONet *n)
+{
+    return n->multiqueue;
+}

The name is confusing, this is in fact whether or not guest support multiqueue. To check peer's ability, you need check n->nic_conf.peers.queues instead.

I just wanted to mimic similar code, I have no issue against this approach.

Quoted 9 lines
Quoted 9 lines
hw/net/virtio-net.c +1 -0
+
  static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs,
                                         int version_1)
  {
@@ -469,6 +474,13 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features)
          virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO);
      }
 
Quoted 5 lines

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) · line 478

Quoted 2 lines
hw/net/virtio-net.c +2 -0
+    if (!peer_has_multiqueue(n)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_MQ);

I'm not quite understand this, VIRTIO_NET_F_MQ should work if peer has only 1 queue.

Please explain, I thought VIRTIO_NET_F_MQ flag *enables* multi-queue, and in our case we pass queue=2 to vhost.

Quoted 8 lines

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) · line 483

Quoted 6 lines
hw/net/virtio-net.c +5 -0
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_VQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_RX);
+    }
+

Those features don't depend on multiqueue, why clear them?

Once VIRTIO_NET_F_MQ is cleared, the virtio driver from guest is complaining about those other flags too.

Any explanations about how *it should* work are welcomed. Again, the scenario is: backend doesn't support multi-queue, QEMU/guest do, and queues=2 is passed on command line.

Thanks,
Marcel

Quoted 13 lines
Quoted 12 lines
hw/net/virtio-net.c +0 -1
      if (!get_vhost_net(nc->peer)) {
          virtio_add_feature(&features, VIRTIO_F_VERSION_1);
          return features;
@@ -1314,7 +1326,6 @@ static void virtio_net_tx_bh(void *opaque)
  static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)
  {
      n->multiqueue = multiqueue;
-
      virtio_net_set_queues(n);
  }
 
#4 lore raw
In reply to Michael S. Tsirkin
Quoted 77 lines · Michael S. Tsirkin
Quoted 52 lines · Marcel Apfelbaum
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Marcel Apfelbaum

Clear host multi-queue related features if the peer doesn't support it.

---
Notes:
This fixes a guest CPU soft lock, however the virtio-net device will not work correctly. It seems that is peer's "fault", not knowing how to handle the situation. However, I submit this patch since it corrects the negotiation and saves us from a guest crash (!).

Any ideas from the virtio/multi-queue developers on how to debug this further are welcomed.

  hw/net/virtio-net.c | 13 ++++++++++++-
  1 file changed, 12 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +5 -0
index 9281aa1..63e59e8 100644
@@ -367,6 +367,11 @@ static int peer_has_ufo(VirtIONet *n)
      return n->has_ufo;
  }
 
+static int peer_has_multiqueue(VirtIONet *n)
+{
+    return n->multiqueue;
+}
+
  static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs,
                                         int version_1)
  {
@@ -469,6 +474,13 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features)
          virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO);
      }
 
Quoted 12 lines

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) · line 486

Quoted 10 lines
hw/net/virtio-net.c +7 -0
+    if (!peer_has_multiqueue(n)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_MQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_VQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_RX);
+    }
+
      if (!get_vhost_net(nc->peer)) {
          virtio_add_feature(&features, VIRTIO_F_VERSION_1);
          return features;

_MQ makes sense but what about the rest? Why clear them?

Quoted 5 lines

Guest's virtio driver doesn't like if MQ is off and any of the other flags remains ON. It has a specific check for each of them and fails the loading if not all are off.

Thanks,
Marcel

I think you are mistaken.

         if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) &&
             (VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_CTRL_RX,
                              "VIRTIO_NET_F_CTRL_VQ") ||
              VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_CTRL_VLAN,
                              "VIRTIO_NET_F_CTRL_VQ") ||
              VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE,
                              "VIRTIO_NET_F_CTRL_VQ") ||
              VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_MQ, "VIRTIO_NET_F_CTRL_VQ") ||
              VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR,
                              "VIRTIO_NET_F_CTRL_VQ"))) {
                 return false;
         }

         return true;
Quoted 2 lines

So if CTRL VQ is not set, you can not have MQ or any of the others.

Hmm, I know what saw, but I don't fully understand why is happening. I'll give another try and I'll return with more info.

Thanks,
Marcel

Quoted 14 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
hw/net/virtio-net.c +0 -2
@@ -1314,7 +1326,6 @@ static void virtio_net_tx_bh(void *opaque)
  static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)
  {
      n->multiqueue = multiqueue;
-
      virtio_net_set_queues(n);
  }
 
--

2.1.0

#7 lore raw
In reply to Marcel Apfelbaum
Quoted 80 lines · Marcel Apfelbaum
Quoted 15 lines · Jason Wang
Quoted 11 lines · Marcel Apfelbaum

Clear host multi-queue related features if the peer doesn't support it.

---
Notes:
This fixes a guest CPU soft lock, however the virtio-net device will not work correctly. It seems that is peer's "fault", not knowing how to handle the situation. However, I submit this patch since it corrects the negotiation and saves us from a guest crash (!).

Quoted 1 line

Could you please describe how to reproduce this issue?

Hi Jason,
Sorry for the late reply.
I was hoping that a vhost-user multi-queue "insider" will ask questions :)

This happens when we have OVS as backend without multi-queue support and qemu/guest with multi-queue-support.

Quoted 16 lines
Quoted 16 lines

Any ideas from the virtio/multi-queue developers on how to debug this further are welcomed.

  hw/net/virtio-net.c | 13 ++++++++++++-
  1 file changed, 12 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +0 -0
index 9281aa1..63e59e8 100644
@@ -367,6 +367,11 @@ static int peer_has_ufo(VirtIONet *n)
      return n->has_ufo;
  }
 
Quoted 8 lines

hw/net/virtio-net.c static int peer_has_ufo(VirtIONet *n) · line 373

Quoted 4 lines
hw/net/virtio-net.c +4 -0
+static int peer_has_multiqueue(VirtIONet *n)
+{
+    return n->multiqueue;
+}

The name is confusing, this is in fact whether or not guest support multiqueue. To check peer's ability, you need check n->nic_conf.peers.queues instead.

I just wanted to mimic similar code, I have no issue against this approach.

Quoted 11 lines
Quoted 11 lines
hw/net/virtio-net.c +1 -0
+
  static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int
 mergeable_rx_bufs,
                                         int version_1)
  {
hw/net/virtio-net.c +0 -0
@@ -469,6 +474,13 @@ static uint64_t
 virtio_net_get_features(VirtIODevice *vdev, uint64_t features)
          virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO);
      }
 
Quoted 5 lines

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) · line 478

Quoted 2 lines
hw/net/virtio-net.c +2 -0
+    if (!peer_has_multiqueue(n)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_MQ);

I'm not quite understand this, VIRTIO_NET_F_MQ should work if peer has only 1 queue.

Please explain, I thought VIRTIO_NET_F_MQ flag *enables* multi-queue, and in our case we pass queue=2 to vhost.

Quoted 8 lines

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) · line 483

Quoted 6 lines
hw/net/virtio-net.c +5 -0
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_VQ);
+        virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_RX);
+    }
+

Those features don't depend on multiqueue, why clear them?

Quoted 9 lines

Once VIRTIO_NET_F_MQ is cleared, the virtio driver from guest is complaining
about those other flags too.

Any explanations about how *it should* work are welcomed. Again, the scenario is: backend doesn't support multi-queue, QEMU/guest do,
and queues=2 is passed on command line.

In this case, backend should just fail the initialization like what we've done for tap. I believe vhost-user should check whether or not its backend can support up to 2 queues and fail if not.

Thanks

Quoted 17 lines

Thanks,
Marcel

Quoted 13 lines
Quoted 12 lines
hw/net/virtio-net.c +0 -0
      if (!get_vhost_net(nc->peer)) {
          virtio_add_feature(&features, VIRTIO_F_VERSION_1);
          return features;
hw/net/virtio-net.c +0 -1
@@ -1314,7 +1326,6 @@ static void virtio_net_tx_bh(void *opaque)
  static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)
  {
      n->multiqueue = multiqueue;
-
      virtio_net_set_queues(n);
  }