Skip to contentSkip to conversation

virtio-net not working with the latest qemu-kvm git

PATCH Applied Sridhar Samudrala 8 participants 20 messages May 4, 2009 – Oct 1, 2009 KVM

lore
Share & tools
lore
#0 lore raw

When i moved to the latest qemu-kvm git tree from kvm-85, i noticed that networking stopped working between the host and the guest. It started working when i put the device in promiscuos mode by running tcpdump in background on the guest.

After browsing through the recent patches, i found that the following commit is causing the regression.

Remove stray GSO code from virtio_net (Mark McLoughlin)
http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commitdiff;h=559a8f45f34cc50d1a60b4f67a06614d506b2e01

The comment doesn't seem to match with the code that is removed with this patch.

Thanks
Sridhar

#1 lore raw
Quoted 5 lines · Sridhar Samudrala

When i moved to the latest qemu-kvm git tree from kvm-85, i noticed that networking stopped working between the host and the guest. It started working when i put the device in promiscuos mode by running tcpdump in background on the guest.

Quoted 7 lines

After browsing through the recent patches, i found that the following commit is causing the regression.

Remove stray GSO code from virtio_net (Mark McLoughlin)
http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commitdiff;h=559a8f45f34cc50d1a60b4f67a06614d506b2e01

The comment doesn't seem to match with the code that is removed with this patch.

Yep, I agree, the removed code is not bogus. We have to skip the vnet header to to get to the ethernet header, which we do the filtering on.

Alex

#2 lore raw

PATCH 1/1 qemu-kvm: virtio-net: Re-instate GSO code removed upstream

This commit:

commit 559a8f45f34cc50d1a60b4f67a06614d506b2e01
Subject: Remove stray GSO code from virtio_net (Mark McLoughlin)

Removed some GSO code from upstream qemu.git, but it needs to be re-instated in qemu-kvm.git.

---
 hw/virtio-net.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
hw/virtio-net.c +5 -0
index ac8e030..e5d7add 100644
@@ -424,6 +424,11 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
     if (n->promisc)
         return 1;
 
+#ifdef TAP_VNET_HDR
+    if (tap_has_vnet_hdr(n->vc->vlan->first_client))
+        ptr += sizeof(struct virtio_net_hdr);
+#endif
+
     if (!memcmp(&ptr[12], vlan, sizeof(vlan))) {
         int vid = be16_to_cpup((uint16_t *)(ptr + 14)) & 0xfff;
         if (!(n->vlans[vid >> 5] & (1U << (vid & 0x1f))))
Signature · 1 line
1.6.0.6
Applied
#3 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

Quoted 9 lines · Mark McLoughlin

This commit:

commit 559a8f45f34cc50d1a60b4f67a06614d506b2e01
Subject: Remove stray GSO code from virtio_net (Mark McLoughlin)

Removed some GSO code from upstream qemu.git, but it needs to be re-instated in qemu-kvm.git.

Applied, thanks.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
#4 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

In reply to Mark McLoughlin
Quoted 20 lines · Mark McLoughlin

This commit:

commit 559a8f45f34cc50d1a60b4f67a06614d506b2e01
Subject: Remove stray GSO code from virtio_net (Mark McLoughlin)

Removed some GSO code from upstream qemu.git, but it needs to be re-instated in qemu-kvm.git.

---
 hw/virtio-net.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
hw/virtio-net.c +0 -0
index ac8e030..e5d7add 100644
@@ -424,6 +424,11 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
     if (n->promisc)

hw/virtio-net.c static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) · line 434

Quoted 10 lines
hw/virtio-net.c +5 -0
         return 1;
 
+#ifdef TAP_VNET_HDR
+    if (tap_has_vnet_hdr(n->vc->vlan->first_client))
+        ptr += sizeof(struct virtio_net_hdr);
+#endif
+
     if (!memcmp(&ptr[12], vlan, sizeof(vlan))) {
         int vid = be16_to_cpup((uint16_t *)(ptr + 14)) & 0xfff;
         if (!(n->vlans[vid >> 5] & (1U << (vid & 0x1f))))

I'm not sure[1] how we didn't notice, but this has been broken on the stable-0.10 branch since 0.10.3; please apply there too

See:

https://bugzilla.redhat.com/522994

Cheers,
Mark.

[1] - well, one reason is that libvirt doesn't seem to be enabling vnet_hdr at the moment. That's the next thing to look at

#5 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

Quoted 37 lines · Mark McLoughlin
Quoted 20 lines · Mark McLoughlin

This commit:

commit 559a8f45f34cc50d1a60b4f67a06614d506b2e01
Subject: Remove stray GSO code from virtio_net (Mark McLoughlin)

Removed some GSO code from upstream qemu.git, but it needs to be re-instated in qemu-kvm.git.

---
 hw/virtio-net.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
hw/virtio-net.c +0 -0
index ac8e030..e5d7add 100644
@@ -424,6 +424,11 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
     if (n->promisc)

hw/virtio-net.c static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) · line 434

Quoted 10 lines
hw/virtio-net.c +5 -0
         return 1;
 
+#ifdef TAP_VNET_HDR
+    if (tap_has_vnet_hdr(n->vc->vlan->first_client))
+        ptr += sizeof(struct virtio_net_hdr);
+#endif
+
     if (!memcmp(&ptr[12], vlan, sizeof(vlan))) {
         int vid = be16_to_cpup((uint16_t *)(ptr + 14)) & 0xfff;
         if (!(n->vlans[vid >> 5] & (1U << (vid & 0x1f))))

I'm not sure[1] how we didn't notice, but this has been broken on the stable-0.10 branch since 0.10.3; please apply there too

See:

Quoted 7 lines

https://bugzilla.redhat.com/522994

Cheers,
Mark.

[1] - well, one reason is that libvirt doesn't seem to be enabling vnet_hdr at the moment. That's the next thing to look at

Oh, another reason is that this is only a problem with 2.6.30 guests which enable MAC based receive filtering

Cheers,
Mark.

#6 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

In reply to Mark McLoughlin
Quoted 24 lines · Mark McLoughlin
Quoted 22 lines · Mark McLoughlin

This commit:

commit 559a8f45f34cc50d1a60b4f67a06614d506b2e01
Subject: Remove stray GSO code from virtio_net (Mark McLoughlin)

Removed some GSO code from upstream qemu.git, but it needs to be re-instated in qemu-kvm.git.

---
  hw/virtio-net.c |    5 +++++
  1 files changed, 5 insertions(+), 0 deletions(-)
hw/virtio-net.c +0 -0
index ac8e030..e5d7add 100644
@@ -424,6 +424,11 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
      if (n->promisc)
          return 1;
 
Quoted 13 lines

hw/virtio-net.c static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)

Quoted 9 lines
hw/virtio-net.c +5 -0
+#ifdef TAP_VNET_HDR
+    if (tap_has_vnet_hdr(n->vc->vlan->first_client))
+        ptr += sizeof(struct virtio_net_hdr);
+#endif
+
      if (!memcmp(&ptr[12], vlan, sizeof(vlan))) {
          int vid = be16_to_cpup((uint16_t *)(ptr + 14))&  0xfff;
          if (!(n->vlans[vid>>  5]&  (1U<<  (vid&  0x1f))))

I'm not sure[1] how we didn't notice, but this has been broken on the stable-0.10 branch since 0.10.3; please apply there too

Thanks, we'll queue it on stable-0.10.

Anthony/Glauber, is 0.10.7 in the works? If not, we'll release it as 0.10.6.1.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
#7 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

Quoted 39 lines · Avi Kivity
Quoted 24 lines · Mark McLoughlin
Quoted 22 lines · Mark McLoughlin

This commit:

commit 559a8f45f34cc50d1a60b4f67a06614d506b2e01
Subject: Remove stray GSO code from virtio_net (Mark McLoughlin)

Removed some GSO code from upstream qemu.git, but it needs to be re-instated in qemu-kvm.git.

---
  hw/virtio-net.c |    5 +++++
  1 files changed, 5 insertions(+), 0 deletions(-)
hw/virtio-net.c +0 -0
index ac8e030..e5d7add 100644
@@ -424,6 +424,11 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
      if (n->promisc)
          return 1;
 
Quoted 13 lines

hw/virtio-net.c static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)

Quoted 9 lines
hw/virtio-net.c +5 -0
+#ifdef TAP_VNET_HDR
+    if (tap_has_vnet_hdr(n->vc->vlan->first_client))
+        ptr += sizeof(struct virtio_net_hdr);
+#endif
+
      if (!memcmp(&ptr[12], vlan, sizeof(vlan))) {
          int vid = be16_to_cpup((uint16_t *)(ptr + 14))&  0xfff;
          if (!(n->vlans[vid>>  5]&  (1U<<  (vid&  0x1f))))

I'm not sure[1] how we didn't notice, but this has been broken on the stable-0.10 branch since 0.10.3; please apply there too

Quoted 4 lines

Thanks, we'll queue it on stable-0.10.

Anthony/Glauber, is 0.10.7 in the works? If not, we'll release it as 0.10.6.1.

Since it is just one patch, I don't see a problem in anthony picking it directly and making a new release.

#8 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

Quoted 40 lines · Glauber Costa
Quoted 39 lines · Avi Kivity
Quoted 37 lines · Mark McLoughlin
Quoted 21 lines · Mark McLoughlin

This commit:

commit 559a8f45f34cc50d1a60b4f67a06614d506b2e01
Subject: Remove stray GSO code from virtio_net (Mark McLoughlin)

Removed some GSO code from upstream qemu.git, but it needs to be re-instated in qemu-kvm.git.

---
  hw/virtio-net.c |    5 +++++
  1 files changed, 5 insertions(+), 0 deletions(-)
hw/virtio-net.c +0 -0
index ac8e030..e5d7add 100644
@@ -424,6 +424,11 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
      if (n->promisc)

hw/virtio-net.c static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) · line 434

Quoted 10 lines
hw/virtio-net.c +5 -0
          return 1;
 
+#ifdef TAP_VNET_HDR
+    if (tap_has_vnet_hdr(n->vc->vlan->first_client))
+        ptr += sizeof(struct virtio_net_hdr);
+#endif
+
      if (!memcmp(&ptr[12], vlan, sizeof(vlan))) {
          int vid = be16_to_cpup((uint16_t *)(ptr + 14))&  0xfff;
          if (!(n->vlans[vid>>  5]&  (1U<<  (vid&  0x1f))))

I'm not sure[1] how we didn't notice, but this has been broken on the stable-0.10 branch since 0.10.3; please apply there too

Quoted 6 lines
Quoted 4 lines

Thanks, we'll queue it on stable-0.10.

Anthony/Glauber, is 0.10.7 in the works? If not, we'll release it as 0.10.6.1.

Since it is just one patch, I don't see a problem in anthony picking it directly and making a new release.

It's not for qemu.git, it's for qemu-kvm.git - see the changelog

Cheers,
Mark.

#9 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

In reply to Avi Kivity
Quoted 1 line · Avi Kivity

Anthony/Glauber, is 0.10.7 in the works? If not, we'll release it as 0.10.6.1.

Yes. I can release it very soon.

Signature · 3 lines
Regards,

Anthony Liguori
#11 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

Quoted 3 lines · Christoph Hellwig

I might sound like a broken record, but why isn't the full GSO support for virtio-net upstream in qemu?

IIRC the current hacks are not upstream quality.

The problem (again IIRC) is that the guest and host negotiate a protocol, but the qemu vlan model doesn't have a guest and a host, it has peers (possibly more than two), so a lot of translation has to take place if you have one peer supporting a guest feature and another not.

IMO the best way out is to drop the vlan model. It has its uses, but they can all be implemented in other ways, and are all have minor usage compared to the business of getting data into and out of a guest.

Signature · 1 line
error compiling committee.c: too many arguments to function
#12 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

Quoted 11 lines · Avi Kivity
Quoted 3 lines · Christoph Hellwig

I might sound like a broken record, but why isn't the full GSO support for virtio-net upstream in qemu?

IIRC the current hacks are not upstream quality.

The problem (again IIRC) is that the guest and host negotiate a protocol, but the qemu vlan model doesn't have a guest and a host, it has peers (possibly more than two), so a lot of translation has to take place if you have one peer supporting a guest feature and another not.

Right.

Quoted 3 lines

IMO the best way out is to drop the vlan model. It has its uses, but they can all be implemented in other ways, and are all have minor usage compared to the business of getting data into and out of a guest.

I think we should keep the vlan stuff, just de-emphasise it.

I'm planning on adding -hostnet and -nic arguments, which would not use vlans by default but rather connect the nic directly to the host side.

The QemuOpts conversion of -net which is waiting to be merged is the first stage of that.

Cheers,
Mark.

#13 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

Quoted 2 lines · Mark McLoughlin

I'm planning on adding -hostnet and -nic arguments, which would not use vlans by default but rather connect the nic directly to the host side.

No new -nic argument please. We should just finalize the qdev-ifycation of the nic drivers, then you'll do either

-device e1000,vlan=<nr>

or

-device e1000,hostnet=<name>

and be done with it.

cheers,
Gerd

#14 lore raw

Re: [Qemu-devel] Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

Quoted 7 lines · Gerd Hoffmann
Quoted 2 lines · Mark McLoughlin

I'm planning on adding -hostnet and -nic arguments, which would not use vlans by default but rather connect the nic directly to the host side.

No new -nic argument please. We should just finalize the qdev-ifycation of the nic drivers, then you'll do either

Quoted 7 lines
   -device e1000,vlan=<nr>

or

   -device e1000,hostnet=<name>

and be done with it.

Yeah, that makes sense.

Cheers,
Mark.

#15 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

In reply to Mark McLoughlin
Quoted 2 lines · Mark McLoughlin

I think we should keep the vlan stuff, just de-emphasise it.

Maybe we should do what X.org does, break it silently and remove it some time later when no one complains.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
#16 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

Quoted 6 lines · Avi Kivity
Quoted 2 lines · Mark McLoughlin

I think we should keep the vlan stuff, just de-emphasise it.

Maybe we should do what X.org does, break it silently and remove it some time later when no one complains.

Well, the 'silently' part isn't going to work now, is it?

Anyway, I'm sure at least Jan would notice if his 'dump' backend stopped working

Cheers,
Mark.

#17 lore raw

Re: [PATCH 1/1] qemu-kvm: virtio-net: Re-instate GSO code removed upstream

Quoted 4 lines · Mark McLoughlin
Quoted 2 lines · Avi Kivity

On 09/30/2009 03:59 PM, Mark McLoughlin wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I think we should keep the vlan stuff, just de-emphasise it.

Maybe we should do what X.org does, break it silently and remove it some time later when no one complains.

Well, the 'silently' part isn't going to work now, is it?

Me and my big mouth.

Quoted 3 lines

Anyway, I'm sure at least Jan would notice if his 'dump' backend stopped working

Patch it to use libpcap?

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
#18 lore raw
In reply to Alex Williamson
Quoted 9 lines · Alex Williamson
Quoted 8 lines · Sridhar Samudrala

When i moved to the latest qemu-kvm git tree from kvm-85, i noticed that networking stopped working between the host and the guest. It started working when i put the device in promiscuos mode by running tcpdump in background on the guest.

After browsing through the recent patches, i found that the following commit is causing the regression.

Quoted 7 lines
Quoted 4 lines

Remove stray GSO code from virtio_net (Mark McLoughlin)
http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commitdiff;h=559a8f45f34cc50d1a60b4f67a06614d506b2e01

The comment doesn't seem to match with the code that is removed with this patch.

Yep, I agree, the removed code is not bogus. We have to skip the vnet header to to get to the ethernet header, which we do the filtering on.

The code was removed in upstream qemu.git, but we need it re-instated in qemu-kvm.git. Just sent a patch to do that.

Thanks,
Mark.

Applied
#19 lore raw
In reply to Sridhar Samudrala
Quoted 5 lines · Sridhar Samudrala

When i moved to the latest qemu-kvm git tree from kvm-85, i noticed that networking stopped working between the host and the guest. It started working when i put the device in promiscuos mode by running tcpdump in background on the guest.

Quoted 8 lines

After browsing through the recent patches, i found that the following commit is causing the regression.

Remove stray GSO code from virtio_net (Mark McLoughlin)
http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commitdiff;h=559a8f45f34cc50d1a60b4f67a06614d506b2e01

The comment doesn't seem to match with the code that is removed with this patch.

I applied a patch from Mark that fixes this. Thanks for reporting.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.