qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v5 1/1] virtio-net: Add check for mac address while peer is v


From: Sean Mooney
Subject: Re: [PATCH v5 1/1] virtio-net: Add check for mac address while peer is vdpa
Date: Mon, 01 Mar 2021 13:04:19 +0000
User-agent: Evolution 3.38.3 (3.38.3-1.module_f33+11014+b95688ad)

On Thu, 2021-02-25 at 14:14 -0500, Michael S. Tsirkin wrote:
> On Fri, Feb 26, 2021 at 12:55:06AM +0800, Cindy Lu wrote:
> > While peer is vdpa, sometime qemu get an all zero mac address from the 
> > hardware,
> > This is not a legal value. Add the check for this.if we get an zero mac 
> > address.
> > qemu will use the default mac address or the mac address from qemu cmdline
> > 
> > Signed-off-by: Cindy Lu <lulu@redhat.com>
> 
> I guess I will have to rewrite the comments and commit log :(
> 
> It is all saying what does the patch do. We want it to rather
> give motivation.
> 
> Sean could you please comment on whether this patch fixes your
> config?
sorry this came in just as i was finsihing up for the day and firday was a 
company day.

i just applied the patch on my dev env.
when i do the mac is set to the value i set on the qemu command line.
i am able to bring up the interface in the guest and i can successfully ping 
the host so setting 
only the mac seams to be sufficent to allow the vdpa interface to be used in a 
guest.

i tested using an unmodifed alpine linux image for the guest and appied the 
patch
to qemu commit e90ef02389dc8b57eaea22b290244609d720a8bf which was the had of 
master when i cloned qemu a few days ago.
regards
sean

> 
> > ---
> >  hw/net/virtio-net.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > index 9179013ac4..8f36ca5066 100644
> > --- a/hw/net/virtio-net.c
> > +++ b/hw/net/virtio-net.c
> > @@ -126,6 +126,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, 
> > uint8_t *config)
> >      VirtIONet *n = VIRTIO_NET(vdev);
> >      struct virtio_net_config netcfg;
> >      NetClientState *nc = qemu_get_queue(n->nic);
> > +    static const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
> >  
> > 
> > 
> > 
> >      int ret = 0;
> >      memset(&netcfg, 0 , sizeof(struct virtio_net_config));
> > @@ -151,6 +152,15 @@ static void virtio_net_get_config(VirtIODevice *vdev, 
> > uint8_t *config)
> >          ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t 
> > *)&netcfg,
> >                                     n->config_size);
> >          if (ret != -1) {
> > +            /*
> > +             * Here is a work around, the 0 mac address is not a legal 
> > value.
> > +             * if we got this from hardware, qemu will use the mac address
> > +             * saved in VirtIONet->mac.
> > +             */
> > +            if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) {
> > +                info_report("Get an all zero mac address from hardware");
> > +                memcpy(netcfg.mac, n->mac, ETH_ALEN);
> > +            }
> >              memcpy(config, &netcfg, n->config_size);
> >          }
> >      }
> > -- 
> > 2.21.3
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]