While the hardware MAC address is 0 and the MAC address in
the QEMU command line is also 0, this configuration is
acceptable.
Signed-off-by: Cindy Lu <lulu@redhat.com>
---
hw/net/virtio-net.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 5c610d8078..668fbed9f2 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3620,6 +3620,17 @@ static bool virtio_net_check_vdpa_mac(NetClientState *nc, VirtIONet *n,
return true;
}
}
+ /*
+ * 3.The hardware MAC address is 0,
+ * and the MAC address in the QEMU command line is also 0.
+ * In this situation, qemu will use random mac address
+ */
+ if ((memcmp(&hwcfg.mac, &zero, sizeof(MACAddr)) == 0) &&
+ (memcmp(cmdline_mac, &zero, sizeof(MACAddr)) == 0)) {
+ memcpy(&n->mac[0], &n->nic_conf.macaddr, sizeof(n->mac));
+
+ return true;
+ }
error_setg(errp,
"vDPA device's mac %02x:%02x:%02x:%02x:%02x:%02x"
--
2.45.0
On Mon, Sep 30, 2024 at 12:01 AM Cindy Lu <lulu@redhat.com> wrote: > > While the hardware MAC address is 0 and the MAC address in > the QEMU command line is also 0, this configuration is > acceptable. > > Signed-off-by: Cindy Lu <lulu@redhat.com> > --- > hw/net/virtio-net.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c > index 5c610d8078..668fbed9f2 100644 > --- a/hw/net/virtio-net.c > +++ b/hw/net/virtio-net.c > @@ -3620,6 +3620,17 @@ static bool virtio_net_check_vdpa_mac(NetClientState *nc, VirtIONet *n, > return true; > } > } > + /* > + * 3.The hardware MAC address is 0, > + * and the MAC address in the QEMU command line is also 0. > + * In this situation, qemu will use random mac address And explain how the device knows such a random mac address or it's just for a best effort try. Thanks > + */ > + if ((memcmp(&hwcfg.mac, &zero, sizeof(MACAddr)) == 0) && > + (memcmp(cmdline_mac, &zero, sizeof(MACAddr)) == 0)) { > + memcpy(&n->mac[0], &n->nic_conf.macaddr, sizeof(n->mac)); > + > + return true; > + } > > error_setg(errp, > "vDPA device's mac %02x:%02x:%02x:%02x:%02x:%02x" > -- > 2.45.0 >
On Wed, 9 Oct 2024 at 16:30, Jason Wang <jasowang@redhat.com> wrote: > > On Mon, Sep 30, 2024 at 12:01 AM Cindy Lu <lulu@redhat.com> wrote: > > > > While the hardware MAC address is 0 and the MAC address in > > the QEMU command line is also 0, this configuration is > > acceptable. > > > > Signed-off-by: Cindy Lu <lulu@redhat.com> > > --- > > hw/net/virtio-net.c | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c > > index 5c610d8078..668fbed9f2 100644 > > --- a/hw/net/virtio-net.c > > +++ b/hw/net/virtio-net.c > > @@ -3620,6 +3620,17 @@ static bool virtio_net_check_vdpa_mac(NetClientState *nc, VirtIONet *n, > > return true; > > } > > } > > + /* > > + * 3.The hardware MAC address is 0, > > + * and the MAC address in the QEMU command line is also 0. > > + * In this situation, qemu will use random mac address > > And explain how the device knows such a random mac address or it's > just for a best effort try. > > Thanks > sure, will add these Thanks cindy > > + */ > > + if ((memcmp(&hwcfg.mac, &zero, sizeof(MACAddr)) == 0) && > > + (memcmp(cmdline_mac, &zero, sizeof(MACAddr)) == 0)) { > > + memcpy(&n->mac[0], &n->nic_conf.macaddr, sizeof(n->mac)); > > + > > + return true; > > + } > > > > error_setg(errp, > > "vDPA device's mac %02x:%02x:%02x:%02x:%02x:%02x" > > -- > > 2.45.0 > > >
© 2016 - 2024 Red Hat, Inc.