diff mbox series

[v2,2/4] virtio_net: copy VIRTIO_NET_S_ANNOUNCE if device model has it

Message ID 20221124173314.2123015-3-eperezma@redhat.com
State New
Headers show
Series Guest announce feature emulation using Shadow VirtQueue | expand

Commit Message

Eugenio Perez Martin Nov. 24, 2022, 5:33 p.m. UTC
Status part of the emulated feature. It will follow device model, so we
must copy it as long as NIC device model has it set.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 hw/net/virtio-net.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Jason Wang Nov. 30, 2022, 6:58 a.m. UTC | #1
On Fri, Nov 25, 2022 at 1:33 AM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> Status part of the emulated feature. It will follow device model, so we
> must copy it as long as NIC device model has it set.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
>  hw/net/virtio-net.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index eed629766f..bf71ef33e8 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -183,6 +183,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
>              memcpy(netcfg.mac, n->mac, ETH_ALEN);
>          }
>
> +        netcfg.status |= (n->status & VIRTIO_NET_S_ANNOUNCE);

Do we need to care about the endian here? We use:

    virtio_stw_p(vdev, &netcfg.status, n->status);

At the beginning of this function.

Thanks

>          memcpy(config, &netcfg, n->config_size);
>      }
>  }
> --
> 2.31.1
>
Michael S. Tsirkin Dec. 20, 2022, 1:44 p.m. UTC | #2
On Wed, Nov 30, 2022 at 02:58:35PM +0800, Jason Wang wrote:
> On Fri, Nov 25, 2022 at 1:33 AM Eugenio Pérez <eperezma@redhat.com> wrote:
> >
> > Status part of the emulated feature. It will follow device model, so we
> > must copy it as long as NIC device model has it set.
> >
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > ---
> >  hw/net/virtio-net.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > index eed629766f..bf71ef33e8 100644
> > --- a/hw/net/virtio-net.c
> > +++ b/hw/net/virtio-net.c
> > @@ -183,6 +183,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
> >              memcpy(netcfg.mac, n->mac, ETH_ALEN);
> >          }
> >
> > +        netcfg.status |= (n->status & VIRTIO_NET_S_ANNOUNCE);
> 
> Do we need to care about the endian here? We use:
> 
>     virtio_stw_p(vdev, &netcfg.status, n->status);
> 
> At the beginning of this function.
> 
> Thanks


Didn't see this answered.

> >          memcpy(config, &netcfg, n->config_size);
> >      }
> >  }
> > --
> > 2.31.1
> >
Eugenio Perez Martin Dec. 20, 2022, 1:53 p.m. UTC | #3
On Wed, Nov 30, 2022 at 7:58 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Fri, Nov 25, 2022 at 1:33 AM Eugenio Pérez <eperezma@redhat.com> wrote:
> >
> > Status part of the emulated feature. It will follow device model, so we
> > must copy it as long as NIC device model has it set.
> >
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > ---
> >  hw/net/virtio-net.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > index eed629766f..bf71ef33e8 100644
> > --- a/hw/net/virtio-net.c
> > +++ b/hw/net/virtio-net.c
> > @@ -183,6 +183,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
> >              memcpy(netcfg.mac, n->mac, ETH_ALEN);
> >          }
> >
> > +        netcfg.status |= (n->status & VIRTIO_NET_S_ANNOUNCE);
>
> Do we need to care about the endian here? We use:
>
>     virtio_stw_p(vdev, &netcfg.status, n->status);
>
> At the beginning of this function.
>

Right, this is a miss. I'll fix it in the next version.

Thanks!
diff mbox series

Patch

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index eed629766f..bf71ef33e8 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -183,6 +183,7 @@  static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
             memcpy(netcfg.mac, n->mac, ETH_ALEN);
         }
 
+        netcfg.status |= (n->status & VIRTIO_NET_S_ANNOUNCE);
         memcpy(config, &netcfg, n->config_size);
     }
 }