virtio_net: Add the check for vdpa's mac address
PATCH 1/3 virtio_net: Add the check for vdpa's mac address
When using a VDPA device, it is important to ensure that the MAC address in the hardware matches the MAC address from the QEMU command line.
This will allow the device to boot.
--- hw/net/virtio-net.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)
hw/net/virtio-net.c +29 -4
@@ -3579,12 +3579,36 @@ static bool failover_hide_primary_device(DeviceListener *listener,/* failover_primary_hidden is set during feature negotiation */ return qatomic_read (&n->failover_primary_hidden); } +static bool virtio_net_check_vdpa_mac (NetClientState *nc,VirtIONet *n,MACAddr *cmdline_mac, +Error **errp) +{ +struct virtio_net_config hwcfg = {}; +static const MACAddr zero = { .a = {0 ,0 ,0 ,0 ,0 ,0 } }; + +vhost_net_get_config (get_vhost_net (nc->peer), (uint8_t *)&hwcfg,ETH_ALEN ); + +/* +* For VDPA device: Only two situations are acceptable: +* 1.The hardware MAC address is the same as the QEMU command line MAC +* address, and both of them are not 0. +*/ + +if (memcmp (&hwcfg.mac, &zero,sizeof (MACAddr)) !=0 ) { +if ((memcmp (&hwcfg.mac, cmdline_mac,sizeof (MACAddr)) ==0 )) { +return true; + } + } +error_setg (errp,"vDPA device's mac != the mac address from qemu cmdline" +"Please check the the vdpa device's setting." ); +return false; +}static void virtio_net_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);VirtIONet *n =VIRTIO_NET (dev);NetClientState *nc; +MACAddr macaddr_cmdline;int i;if (n->net_conf.mtu) {
@@ -3692,6 +3716,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)virtio_net_add_queue (n,0 ); n->ctrl_vq =virtio_add_queue (vdev,64 , virtio_net_handle_ctrl); +memcpy (&macaddr_cmdline, &n->nic_conf.macaddr,sizeof (n->mac));qemu_macaddr_default_if_unset (&n->nic_conf.macaddr);memcpy (&n->mac[0 ], &n->nic_conf.macaddr,sizeof (n->mac)); n->status =VIRTIO_NET_S_LINK_UP ;
@@ -3739,10 +3764,10 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) nc->rxfilter_notify_enabled =1 ;if (nc->peer && nc->peer->info->type ==NET_CLIENT_DRIVER_VHOST_VDPA ) { -struct virtio_net_config netcfg = {}; -memcpy (&netcfg.mac, &n->nic_conf.macaddr,ETH_ALEN ); -vhost_net_set_config (get_vhost_net (nc->peer), - (uint8_t *)&netcfg,0 ,ETH_ALEN ,VHOST_SET_CONFIG_TYPE_FRONTEND ); +if (!virtio_net_check_vdpa_mac (nc, n, &macaddr_cmdline, errp)) { +virtio_cleanup (vdev); +return ; + } }QTAILQ_INIT (&n->rsc_chains); n->qdev = dev;
Signature · 1 line
2.45.0
PATCH 2/3 virtio_net: Add the check for vdpa mac address
When using a VDPA device, this is another acceptable situations
The hardware MAC address is not 0, and the MAC address in the QEMU command line is 0. This is also acceptable
--- hw/net/virtio-net.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +12 -1
@@ -3592,11 +3592,22 @@ static bool virtio_net_check_vdpa_mac(NetClientState *nc, VirtIONet *n, MACAddr* 1.The hardware MAC address is the same as the QEMU command line MAC * address, and both of them are not 0. */ - +/* +* 2.The hardware MAC address is not 0, +* and the MAC address in the QEMU command line is 0. +* In this situation, the hardware MAC address will overwrite +* the QEMU command line address. +*/ if (memcmp (&hwcfg.mac, &zero,sizeof (MACAddr)) !=0 ) {if ((memcmp (&hwcfg.mac, cmdline_mac,sizeof (MACAddr)) ==0 )) {return true; } +if (memcmp (cmdline_mac, &zero,sizeof (MACAddr)) ==0 ) { +/* overwrite the mac address with hardware address*/ +memcpy (&n->mac[0 ], &hwcfg.mac,sizeof (n->mac)); +memcpy (&n->nic_conf.macaddr, &hwcfg.mac,sizeof (n->mac)); +return true; + } }error_setg (errp,"vDPA device's mac != the mac address from qemu cmdline" "Please check the the vdpa device's setting." );
Signature · 1 line
2.45.0
Re: [PATCH 2/3] virtio_net: Add the check for vdpa mac address
Quoted 15 lines · Cindy Lu
When using a VDPA device, this is another acceptable situations
The hardware MAC address is not 0, and the MAC address in the QEMU command line is 0. This is also acceptableSigned-off-by Cindy Lu <[email protected]>--- hw/net/virtio-net.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)hw/net/virtio-net.c +0
-0
hw/net/virtio-net.c static bool virtio_net_check_vdpa_mac(NetClientState *nc, VirtIONet *n, MACAddr · line 3599
Quoted 9 lines
hw/net/virtio-net.c +5
-1@@ -3592,11 +3592,22 @@ static bool virtio_net_check_vdpa_mac(NetClientState *nc, VirtIONet *n, MACAddr* 1.The hardware MAC address is the same as the QEMU command line MAC * address, and both of them are not 0. */ - +/* +* 2.The hardware MAC address is not 0, +* and the MAC address in the QEMU command line is 0. +* In this situation, the hardware MAC address will overwrite +* the QEMU command line address.
This seems to break libvirt assumption?
Adding Jonathon.
Quoted 15 lines
hw/net/virtio-net.c +7
-1+*/ if (memcmp (&hwcfg.mac, &zero,sizeof (MACAddr)) !=0 ) {if ((memcmp (&hwcfg.mac, cmdline_mac,sizeof (MACAddr)) ==0 )) {return true; } +if (memcmp (cmdline_mac, &zero,sizeof (MACAddr)) ==0 ) { +/* overwrite the mac address with hardware address*/ +memcpy (&n->mac[0 ], &hwcfg.mac,sizeof (n->mac)); +memcpy (&n->nic_conf.macaddr, &hwcfg.mac,sizeof (n->mac)); +return true; + } }error_setg (errp,"vDPA device's mac != the mac address from qemu cmdline" "Please check the the vdpa device's setting." ); --
Quoted 2 lines
2.45.0
Thanks
PATCH 3/3 virtio_net: remove the unnecessary check in get_config
In reply to Cindy LuThe vdpa device with MAC address 0 should not boot. So remove the check here
--- hw/net/virtio-net.c | 13 ------------- 1 file changed, 13 deletions(-)
hw/net/virtio-net.c +0 -13
@@ -142,7 +142,6 @@ 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 ));
@@ -170,18 +169,6 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)if (ret ==-1 ) {return ; } - -/* -* Some NIC/kernel combinations present 0 as the mac address. As that -* is not a legal address, try to proceed with the address from the -* QEMU command line in the hope that the address has been configured -* correctly elsewhere - just not reported by the device. -*/ -if (memcmp (&netcfg.mac, &zero,sizeof (zero)) ==0 ) { -info_report ("Zero hardware mac address detected. Ignoring." ); -memcpy (netcfg.mac, n->mac,ETH_ALEN ); - } - netcfg.status |=virtio_tswap16 (vdev, n->status &VIRTIO_NET_S_ANNOUNCE );memcpy (config, &netcfg, n->config_size);
Signature · 1 line
2.45.0
Re: [PATCH 3/3] virtio_net: remove the unnecessary check in get_config
Quoted 5 lines · Cindy Lu
The vdpa device with MAC address 0 should not boot. So remove the check here
Signed-off-by Cindy Lu <[email protected]>
Please describe what issues you've seen, and how it is fixed by this commit.
Thanks
Quoted 38 lines
--- hw/net/virtio-net.c | 13 ------------- 1 file changed, 13 deletions(-)hw/net/virtio-net.c +0
-14@@ -142,7 +142,6 @@ 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 ));@@ -170,18 +169,6 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)if (ret ==-1 ) {return ; } - -/* -* Some NIC/kernel combinations present 0 as the mac address. As that -* is not a legal address, try to proceed with the address from the -* QEMU command line in the hope that the address has been configured -* correctly elsewhere - just not reported by the device. -*/ -if (memcmp (&netcfg.mac, &zero,sizeof (zero)) ==0 ) { -info_report ("Zero hardware mac address detected. Ignoring." ); -memcpy (netcfg.mac, n->mac,ETH_ALEN ); - } - netcfg.status |=virtio_tswap16 (vdev, n->status &VIRTIO_NET_S_ANNOUNCE );memcpy (config, &netcfg, n->config_size); --2.45.0
Re: [PATCH 3/3] virtio_net: remove the unnecessary check in get_config
Quoted 12 lines · Jason Wang
Quoted 5 lines · Cindy Lu
The vdpa device with MAC address 0 should not boot. So remove the check here
Signed-off-by Cindy Lu <[email protected]>Please describe what issues you've seen, and how it is fixed by this commit.
Thanks
this is a fix after the previous one. In the previous fix, the device with MAC address 0 would not allow booting, so there is no need to check if the MAC address is 0 here.
I will re-organize the whole patch and make it more clear Thanks
Cindy
Quoted 39 lines
Quoted 38 lines
--- hw/net/virtio-net.c | 13 ------------- 1 file changed, 13 deletions(-)hw/net/virtio-net.c +0
-14@@ -142,7 +142,6 @@ 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 ));@@ -170,18 +169,6 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)if (ret ==-1 ) {return ; } - -/* -* Some NIC/kernel combinations present 0 as the mac address. As that -* is not a legal address, try to proceed with the address from the -* QEMU command line in the hope that the address has been configured -* correctly elsewhere - just not reported by the device. -*/ -if (memcmp (&netcfg.mac, &zero,sizeof (zero)) ==0 ) { -info_report ("Zero hardware mac address detected. Ignoring." ); -memcpy (netcfg.mac, n->mac,ETH_ALEN ); - } - netcfg.status |=virtio_tswap16 (vdev, n->status &VIRTIO_NET_S_ANNOUNCE );memcpy (config, &netcfg, n->config_size); --2.45.0
Quoted 21 lines · Cindy Lu
When using a VDPA device, it is important to ensure that the MAC address in the hardware matches the MAC address from the QEMU command line.
This will allow the device to boot.Signed-off-by Cindy Lu <[email protected]>--- hw/net/virtio-net.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)hw/net/virtio-net.c +2
-0@@ -3579,12 +3579,36 @@ static bool failover_hide_primary_device(DeviceListener *listener,/* failover_primary_hidden is set during feature negotiation */ return qatomic_read (&n->failover_primary_hidden); } +static bool virtio_net_check_vdpa_mac (NetClientState *nc,VirtIONet *n,MACAddr *cmdline_mac, +Error **errp)
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener, · line 3593
Quoted 10 lines
hw/net/virtio-net.c +10
-0+{ +struct virtio_net_config hwcfg = {}; +static const MACAddr zero = { .a = {0 ,0 ,0 ,0 ,0 ,0 } }; + +vhost_net_get_config (get_vhost_net (nc->peer), (uint8_t *)&hwcfg,ETH_ALEN ); + +/* +* For VDPA device: Only two situations are acceptable: +* 1.The hardware MAC address is the same as the QEMU command line MAC +* address, and both of them are not 0.
I guess there should be a bullet 2?
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener, · line 3602
Quoted 9 lines
hw/net/virtio-net.c +9
-0+*/ + +if (memcmp (&hwcfg.mac, &zero,sizeof (MACAddr)) !=0 ) { +if ((memcmp (&hwcfg.mac, cmdline_mac,sizeof (MACAddr)) ==0 )) { +return true; + } + } +error_setg (errp,"vDPA device's mac != the mac address from qemu cmdline" +"Please check the the vdpa device's setting." );
For error messages I think it's better to use english instead of "!=" to describe the issue.
Quoted 22 lines
hw/net/virtio-net.c +4
-0+return false; +}static void virtio_net_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);VirtIONet *n =VIRTIO_NET (dev);NetClientState *nc; +MACAddr macaddr_cmdline;int i;if (n->net_conf.mtu) {@@ -3692,6 +3716,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)virtio_net_add_queue (n,0 ); n->ctrl_vq =virtio_add_queue (vdev,64 , virtio_net_handle_ctrl); +memcpy (&macaddr_cmdline, &n->nic_conf.macaddr,sizeof (n->mac));qemu_macaddr_default_if_unset (&n->nic_conf.macaddr);memcpy (&n->mac[0 ], &n->nic_conf.macaddr,sizeof (n->mac)); n->status =VIRTIO_NET_S_LINK_UP ;@@ -3739,10 +3764,10 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) nc->rxfilter_notify_enabled =1 ;
hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp) · line 3770
Quoted 10 lines
hw/net/virtio-net.c +4
-4if (nc->peer && nc->peer->info->type ==NET_CLIENT_DRIVER_VHOST_VDPA ) { -struct virtio_net_config netcfg = {}; -memcpy (&netcfg.mac, &n->nic_conf.macaddr,ETH_ALEN ); -vhost_net_set_config (get_vhost_net (nc->peer), - (uint8_t *)&netcfg,0 ,ETH_ALEN ,VHOST_SET_CONFIG_TYPE_FRONTEND ); +if (!virtio_net_check_vdpa_mac (nc, n, &macaddr_cmdline, errp)) { +virtio_cleanup (vdev); +return ; + }
Any reason we remove vhost_net_set_config() here? It is not described in the commit or does it belong to another patch?
Thanks
Quoted 6 lines
hw/net/virtio-net.c +0
-1}QTAILQ_INIT (&n->rsc_chains); n->qdev = dev; --2.45.0
Quoted 27 lines · Jason Wang
Quoted 25 lines · Cindy Lu
When using a VDPA device, it is important to ensure that the MAC address in the hardware matches the MAC address from the QEMU command line.
This will allow the device to boot.Signed-off-by Cindy Lu <[email protected]>--- hw/net/virtio-net.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)hw/net/virtio-net.c +6
-0@@ -3579,12 +3579,36 @@ static bool failover_hide_primary_device(DeviceListener *listener,/* failover_primary_hidden is set during feature negotiation */ return qatomic_read (&n->failover_primary_hidden); } +static bool virtio_net_check_vdpa_mac (NetClientState *nc,VirtIONet *n,MACAddr *cmdline_mac, +Error **errp) +{ +struct virtio_net_config hwcfg = {}; +static const MACAddr zero = { .a = {0 ,0 ,0 ,0 ,0 ,0 } }; +
Quoted 9 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener, · line 3593
Quoted 6 lines
hw/net/virtio-net.c +6
-0+vhost_net_get_config (get_vhost_net (nc->peer), (uint8_t *)&hwcfg,ETH_ALEN ); + +/* +* For VDPA device: Only two situations are acceptable: +* 1.The hardware MAC address is the same as the QEMU command line MAC +* address, and both of them are not 0. I guess there should be a bullet 2?
yes, there is a section 2, will change this code here Thanks
cindy
Quoted 49 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener, · line 3602
Quoted 9 lines
hw/net/virtio-net.c +9
-0+*/ + +if (memcmp (&hwcfg.mac, &zero,sizeof (MACAddr)) !=0 ) { +if ((memcmp (&hwcfg.mac, cmdline_mac,sizeof (MACAddr)) ==0 )) { +return true; + } + } +error_setg (errp,"vDPA device's mac != the mac address from qemu cmdline" +"Please check the the vdpa device's setting." );For error messages I think it's better to use english instead of "!=" to describe the issue.
Quoted 22 lines
hw/net/virtio-net.c +4
-0+return false; +}static void virtio_net_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);VirtIONet *n =VIRTIO_NET (dev);NetClientState *nc; +MACAddr macaddr_cmdline;int i;if (n->net_conf.mtu) {@@ -3692,6 +3716,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)virtio_net_add_queue (n,0 ); n->ctrl_vq =virtio_add_queue (vdev,64 , virtio_net_handle_ctrl); +memcpy (&macaddr_cmdline, &n->nic_conf.macaddr,sizeof (n->mac));qemu_macaddr_default_if_unset (&n->nic_conf.macaddr);memcpy (&n->mac[0 ], &n->nic_conf.macaddr,sizeof (n->mac)); n->status =VIRTIO_NET_S_LINK_UP ;@@ -3739,10 +3764,10 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) nc->rxfilter_notify_enabled =1 ;hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp) · line 3770
Quoted 10 lines
hw/net/virtio-net.c +4
-4if (nc->peer && nc->peer->info->type ==NET_CLIENT_DRIVER_VHOST_VDPA ) { -struct virtio_net_config netcfg = {}; -memcpy (&netcfg.mac, &n->nic_conf.macaddr,ETH_ALEN ); -vhost_net_set_config (get_vhost_net (nc->peer), - (uint8_t *)&netcfg,0 ,ETH_ALEN ,VHOST_SET_CONFIG_TYPE_FRONTEND ); +if (!virtio_net_check_vdpa_mac (nc, n, &macaddr_cmdline, errp)) { +virtio_cleanup (vdev); +return ; + }Any reason we remove
vhost_net_set_config()here? It is not described in the commit or does it belong to another patch?
Quoted 2 lines
Thanks
as we discussed before, the MAC address in hardware should have a "higher priority"
than the MAC address in qemu cmdline. So I remove the set_config there, the MAC address from the hardware will overwrite the MAC in qemu cmdline. so don't need to set_config to hardware now
Thanks,
cindy
Quoted 7 lines
Quoted 6 lines
hw/net/virtio-net.c +0
-1}QTAILQ_INIT (&n->rsc_chains); n->qdev = dev; --2.45.0
Do we check that the MAC from the command line or HW was formed correctly and doesn't include multicast bit?
Best regards,
Yan.
Quoted 108 lines · Cindy Lu
Quoted 27 lines · Jason Wang
Quoted 25 lines · Cindy Lu
When using a VDPA device, it is important to ensure that the MAC address in the hardware matches the MAC address from the QEMU command line.
This will allow the device to boot.Signed-off-by Cindy Lu <[email protected]>--- hw/net/virtio-net.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)hw/net/virtio-net.c +6
-0@@ -3579,12 +3579,36 @@ static bool failover_hide_primary_device(DeviceListener *listener,/* failover_primary_hidden is set during feature negotiation */ return qatomic_read (&n->failover_primary_hidden); } +static bool virtio_net_check_vdpa_mac (NetClientState *nc,VirtIONet *n,MACAddr *cmdline_mac, +Error **errp) +{ +struct virtio_net_config hwcfg = {}; +static const MACAddr zero = { .a = {0 ,0 ,0 ,0 ,0 ,0 } }; +Quoted 9 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener, · line 3593
Quoted 6 lines
hw/net/virtio-net.c +6
-0+vhost_net_get_config (get_vhost_net (nc->peer), (uint8_t *)&hwcfg,ETH_ALEN ); + +/* +* For VDPA device: Only two situations are acceptable: +* 1.The hardware MAC address is the same as the QEMU command line MAC +* address, and both of them are not 0. I guess there should be a bullet 2?
yes, there is a section 2, will change this code here Thanks
cindyQuoted 49 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener, · line 3602
Quoted 9 lines
hw/net/virtio-net.c +9
-0+*/ + +if (memcmp (&hwcfg.mac, &zero,sizeof (MACAddr)) !=0 ) { +if ((memcmp (&hwcfg.mac, cmdline_mac,sizeof (MACAddr)) ==0 )) { +return true; + } + } +error_setg (errp,"vDPA device's mac != the mac address from qemu cmdline" +"Please check the the vdpa device's setting." );For error messages I think it's better to use english instead of "!=" to describe the issue.
Quoted 22 lines
hw/net/virtio-net.c +4
-0+return false; +}static void virtio_net_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);VirtIONet *n =VIRTIO_NET (dev);NetClientState *nc; +MACAddr macaddr_cmdline;int i;if (n->net_conf.mtu) {@@ -3692,6 +3716,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)virtio_net_add_queue (n,0 ); n->ctrl_vq =virtio_add_queue (vdev,64 , virtio_net_handle_ctrl); +memcpy (&macaddr_cmdline, &n->nic_conf.macaddr,sizeof (n->mac));qemu_macaddr_default_if_unset (&n->nic_conf.macaddr);memcpy (&n->mac[0 ], &n->nic_conf.macaddr,sizeof (n->mac)); n->status =VIRTIO_NET_S_LINK_UP ;@@ -3739,10 +3764,10 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) nc->rxfilter_notify_enabled =1 ;hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp) · line 3770
Quoted 10 lines
hw/net/virtio-net.c +4
-4if (nc->peer && nc->peer->info->type ==NET_CLIENT_DRIVER_VHOST_VDPA ) { -struct virtio_net_config netcfg = {}; -memcpy (&netcfg.mac, &n->nic_conf.macaddr,ETH_ALEN ); -vhost_net_set_config (get_vhost_net (nc->peer), - (uint8_t *)&netcfg,0 ,ETH_ALEN ,VHOST_SET_CONFIG_TYPE_FRONTEND ); +if (!virtio_net_check_vdpa_mac (nc, n, &macaddr_cmdline, errp)) { +virtio_cleanup (vdev); +return ; + }Any reason we remove
vhost_net_set_config()here? It is not described in the commit or does it belong to another patch?Quoted 2 lines
Thanks
as we discussed before, the MAC address in hardware should have a "higher priority"
than the MAC address in qemu cmdline. So I remove theset_configthere, the MAC address from the hardware will overwrite the MAC in qemu cmdline. so don't need toset_configto hardware now
Thanks,
cindyQuoted 7 lines
Quoted 6 lines
hw/net/virtio-net.c +0
-1}QTAILQ_INIT (&n->rsc_chains); n->qdev = dev; --2.45.0
Quoted 7 lines · Yan Vugenfirer
Do we check that the MAC from the command line or HW was formed correctly and doesn't include multicast bit?
Best regards,
Yan.I didn't include a check for this, but it seems the vhost also doesn't
have this kind of verification. I will double check this Thanks
Cindy
Quoted 125 lines · Cindy Lu
Quoted 15 lines · Jason Wang
Quoted 13 lines · Cindy Lu
Quoted 11 lines
When using a VDPA device, it is important to ensure that the MAC address in the hardware matches the MAC address from the QEMU command line.
This will allow the device to boot.Signed-off-by Cindy Lu <[email protected]>--- hw/net/virtio-net.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)Quoted 5 lines
Quoted 5 lines
hw/net/virtio-net.c static bool
Quoted 5 lines
hw/net/virtio-net.c +0
-0@@ -3579,12 +3579,36 @@ static boolfailover_hide_primary_device(DeviceListener *listener,
Quoted 4 lines
Quoted 4 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener,
Quoted 4 lines
hw/net/virtio-net.c +1
-0/* failover_primary_hidden is set during feature negotiation */ return qatomic_read (&n->failover_primary_hidden); } +static bool virtio_net_check_vdpa_mac(NetClientState *nc, VirtIONet*n, MACAddr
*cmdline_mac,Quoted 6 lines
Quoted 6 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener,
Quoted 6 lines
hw/net/virtio-net.c +6
-0+ Error **errp) +{ +struct virtio_net_config hwcfg = {}; +static const MACAddr zero = { .a = {0 ,0 ,0 ,0 ,0 ,0 } }; + + vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t*)&hwcfg,
ETH_ALEN);Quoted 4 lines
Quoted 4 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener,
Quoted 4 lines
hw/net/virtio-net.c +4
-0+ +/* +* For VDPA device: Only two situations are acceptable: +* 1.The hardware MAC address is the same as the QEMU command line MAC
Quoted 11 lines
Quoted 4 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener, · line 3593
Quoted 1 line
hw/net/virtio-net.c +1
-0+* address, and both of them are not 0. I guess there should be a bullet 2?
yes, there is a section 2, will change this code here Thanks
cindyQuoted 4 lines
Quoted 4 lines
hw/net/virtio-net.c +4
-0+*/ + +if (memcmp (&hwcfg.mac, &zero,sizeof (MACAddr)) !=0 ) { + if ((memcmp(&hwcfg.mac, cmdline_mac,sizeof(MACAddr)) == 0)) {
Quoted 4 lines
Quoted 4 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener,
Quoted 4 lines
hw/net/virtio-net.c +4
-0+return true; + } + } + error_setg(errp, "vDPA device's mac != the mac address fromqemu cmdline"
Quoted 1 line
Quoted 1 line
hw/net/virtio-net.c static bool · line 3602
Quoted 1 line
hw/net/virtio-net.c +1
-0+ "Please check the the vdpa device'ssetting.");
Quoted 8 lines
Quoted 8 lines
For error messages I think it's better to use english instead of "!=" to describe the issue.
Quoted 4 lines
hw/net/virtio-net.c +2
-0+return false; +} static void virtio_net_device_realize(DeviceState *dev, Error**errp)
Quoted 9 lines
Quoted 9 lines
hw/net/virtio-net.c static void
Quoted 9 lines
hw/net/virtio-net.c +1
-0{VirtIODevice *vdev =VIRTIO_DEVICE (dev);VirtIONet *n =VIRTIO_NET (dev);NetClientState *nc; +MACAddr macaddr_cmdline;int i;if (n->net_conf.mtu) {@@ -3692,6 +3716,7 @@ static void
virtio_net_device_realize(DeviceState *dev, Error **errp)Quoted 8 lines
Quoted 8 lines
hw/net/virtio-net.c static void
Quoted 8 lines
hw/net/virtio-net.c +1
-0virtio_net_add_queue (n,0 ); n->ctrl_vq =virtio_add_queue (vdev,64 , virtio_net_handle_ctrl); +memcpy (&macaddr_cmdline, &n->nic_conf.macaddr,sizeof (n->mac));qemu_macaddr_default_if_unset (&n->nic_conf.macaddr);memcpy (&n->mac[0 ], &n->nic_conf.macaddr,sizeof (n->mac)); n->status =VIRTIO_NET_S_LINK_UP ;@@ -3739,10 +3764,10 @@ static void
virtio_net_device_realize(DeviceState *dev, Error **errp)Quoted 3 lines
Quoted 3 lines
hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp)
Quoted 3 lines
hw/net/virtio-net.c +0
-0nc->rxfilter_notify_enabled =1 ; if (nc->peer && nc->peer->info->type ==
NET_CLIENT_DRIVER_VHOST_VDPA) {Quoted 4 lines
Quoted 4 lines
hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp)
Quoted 4 lines
hw/net/virtio-net.c +0
-4-struct virtio_net_config netcfg = {}; -memcpy (&netcfg.mac, &n->nic_conf.macaddr,ETH_ALEN ); - vhost_net_set_config(get_vhost_net(nc->peer), - (uint8_t *)&netcfg, 0, ETH_ALEN,
VHOST_SET_CONFIG_TYPE_FRONTEND);Quoted 1 line
Quoted 1 line
hw/net/virtio-net.c static void · line 3767
Quoted 1 line
hw/net/virtio-net.c +1
-0+ if (!virtio_net_check_vdpa_mac(nc, n, &macaddr_cmdline,errp)) {
Quoted 25 lines
Quoted 9 lines
hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp) · line 3770
Quoted 3 lines
hw/net/virtio-net.c +3
-0+virtio_cleanup (vdev); +return ; + }Any reason we remove
vhost_net_set_config()here? It is not described in the commit or does it belong to another patch?Thanks
as we discussed before, the MAC address in hardware should have a "higher priority"
than the MAC address in qemu cmdline. So I remove theset_configthere, the MAC address from the hardware will overwrite the MAC in qemu cmdline. so don't need toset_configto hardware now
Thanks,
cindyQuoted 7 lines
Quoted 6 lines
hw/net/virtio-net.c +0
-1}QTAILQ_INIT (&n->rsc_chains); n->qdev = dev; --2.45.0
Quoted 90 lines · Cindy Lu
Quoted 27 lines · Jason Wang
Quoted 25 lines · Cindy Lu
When using a VDPA device, it is important to ensure that the MAC address in the hardware matches the MAC address from the QEMU command line.
This will allow the device to boot.Signed-off-by Cindy Lu <[email protected]>--- hw/net/virtio-net.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)hw/net/virtio-net.c +6
-0@@ -3579,12 +3579,36 @@ static bool failover_hide_primary_device(DeviceListener *listener,/* failover_primary_hidden is set during feature negotiation */ return qatomic_read (&n->failover_primary_hidden); } +static bool virtio_net_check_vdpa_mac (NetClientState *nc,VirtIONet *n,MACAddr *cmdline_mac, +Error **errp) +{ +struct virtio_net_config hwcfg = {}; +static const MACAddr zero = { .a = {0 ,0 ,0 ,0 ,0 ,0 } }; +Quoted 9 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener, · line 3593
Quoted 6 lines
hw/net/virtio-net.c +6
-0+vhost_net_get_config (get_vhost_net (nc->peer), (uint8_t *)&hwcfg,ETH_ALEN ); + +/* +* For VDPA device: Only two situations are acceptable: +* 1.The hardware MAC address is the same as the QEMU command line MAC +* address, and both of them are not 0. I guess there should be a bullet 2?
yes, there is a section 2, will change this code here Thanks
cindyQuoted 49 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener, · line 3602
Quoted 9 lines
hw/net/virtio-net.c +9
-0+*/ + +if (memcmp (&hwcfg.mac, &zero,sizeof (MACAddr)) !=0 ) { +if ((memcmp (&hwcfg.mac, cmdline_mac,sizeof (MACAddr)) ==0 )) { +return true; + } + } +error_setg (errp,"vDPA device's mac != the mac address from qemu cmdline" +"Please check the the vdpa device's setting." );For error messages I think it's better to use english instead of "!=" to describe the issue.
Quoted 22 lines
hw/net/virtio-net.c +4
-0+return false; +}static void virtio_net_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);VirtIONet *n =VIRTIO_NET (dev);NetClientState *nc; +MACAddr macaddr_cmdline;int i;if (n->net_conf.mtu) {@@ -3692,6 +3716,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)virtio_net_add_queue (n,0 ); n->ctrl_vq =virtio_add_queue (vdev,64 , virtio_net_handle_ctrl); +memcpy (&macaddr_cmdline, &n->nic_conf.macaddr,sizeof (n->mac));qemu_macaddr_default_if_unset (&n->nic_conf.macaddr);memcpy (&n->mac[0 ], &n->nic_conf.macaddr,sizeof (n->mac)); n->status =VIRTIO_NET_S_LINK_UP ;@@ -3739,10 +3764,10 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) nc->rxfilter_notify_enabled =1 ;hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp) · line 3770
Quoted 10 lines
hw/net/virtio-net.c +4
-4if (nc->peer && nc->peer->info->type ==NET_CLIENT_DRIVER_VHOST_VDPA ) { -struct virtio_net_config netcfg = {}; -memcpy (&netcfg.mac, &n->nic_conf.macaddr,ETH_ALEN ); -vhost_net_set_config (get_vhost_net (nc->peer), - (uint8_t *)&netcfg,0 ,ETH_ALEN ,VHOST_SET_CONFIG_TYPE_FRONTEND ); +if (!virtio_net_check_vdpa_mac (nc, n, &macaddr_cmdline, errp)) { +virtio_cleanup (vdev); +return ; + }Any reason we remove
vhost_net_set_config()here? It is not described in the commit or does it belong to another patch?
Quoted 7 lines
Quoted 2 lines
Thanks
as we discussed before, the MAC address in hardware should have a "higher priority"
than the MAC address in qemu cmdline. So I remove theset_configthere, the MAC address from the hardware will overwrite the MAC in qemu cmdline. so don't need toset_configto hardware now
Probably, but I meant it needs to be a separate patch.
For example the title said "add ...." but here it's a removal of something.
Thanks
Quoted 10 lines
Thanks,
cindyQuoted 7 lines
Quoted 6 lines
hw/net/virtio-net.c +0
-1}QTAILQ_INIT (&n->rsc_chains); n->qdev = dev; --2.45.0
Quoted 112 lines · Jason Wang
Quoted 15 lines · Cindy Lu
Quoted 13 lines · Jason Wang
Quoted 11 lines · Cindy Lu
When using a VDPA device, it is important to ensure that the MAC address in the hardware matches the MAC address from the QEMU command line.
This will allow the device to boot.Signed-off-by Cindy Lu <[email protected]>--- hw/net/virtio-net.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)Quoted 5 lines
Quoted 5 lines
hw/net/virtio-net.c static bool
Quoted 5 lines
hw/net/virtio-net.c +0
-0@@ -3579,12 +3579,36 @@ static boolfailover_hide_primary_device(DeviceListener *listener,
Quoted 4 lines
Quoted 4 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener,
Quoted 4 lines
hw/net/virtio-net.c +1
-0/* failover_primary_hidden is set during feature negotiation */ return qatomic_read (&n->failover_primary_hidden); } +static bool virtio_net_check_vdpa_mac(NetClientState *nc, VirtIONet*n, MACAddr
*cmdline_mac,Quoted 6 lines
Quoted 6 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener,
Quoted 6 lines
hw/net/virtio-net.c +6
-0+ Error **errp) +{ +struct virtio_net_config hwcfg = {}; +static const MACAddr zero = { .a = {0 ,0 ,0 ,0 ,0 ,0 } }; + + vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t*)&hwcfg,
ETH_ALEN);Quoted 4 lines
Quoted 4 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener,
Quoted 4 lines
hw/net/virtio-net.c +4
-0+ +/* +* For VDPA device: Only two situations are acceptable: +* 1.The hardware MAC address is the same as the QEMU command line MAC
Quoted 11 lines
Quoted 4 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener, · line 3593
Quoted 1 line
hw/net/virtio-net.c +1
-0+* address, and both of them are not 0. I guess there should be a bullet 2?
yes, there is a section 2, will change this code here Thanks
cindyQuoted 4 lines
Quoted 4 lines
hw/net/virtio-net.c +4
-0+*/ + +if (memcmp (&hwcfg.mac, &zero,sizeof (MACAddr)) !=0 ) { + if ((memcmp(&hwcfg.mac, cmdline_mac,sizeof(MACAddr)) == 0)) {
Quoted 4 lines
Quoted 4 lines
hw/net/virtio-net.c static bool failover_hide_primary_device(DeviceListener *listener,
Quoted 4 lines
hw/net/virtio-net.c +4
-0+return true; + } + } + error_setg(errp, "vDPA device's mac != the mac address fromqemu cmdline"
Quoted 1 line
Quoted 1 line
hw/net/virtio-net.c static bool · line 3602
Quoted 1 line
hw/net/virtio-net.c +1
-0+ "Please check the the vdpa device'ssetting.");
Quoted 8 lines
Quoted 8 lines
For error messages I think it's better to use english instead of "!=" to describe the issue.
Quoted 4 lines
hw/net/virtio-net.c +2
-0+return false; +} static void virtio_net_device_realize(DeviceState *dev, Error**errp)
Quoted 9 lines
Quoted 9 lines
hw/net/virtio-net.c static void
Quoted 9 lines
hw/net/virtio-net.c +1
-0{VirtIODevice *vdev =VIRTIO_DEVICE (dev);VirtIONet *n =VIRTIO_NET (dev);NetClientState *nc; +MACAddr macaddr_cmdline;int i;if (n->net_conf.mtu) {@@ -3692,6 +3716,7 @@ static void
virtio_net_device_realize(DeviceState *dev, Error **errp)Quoted 8 lines
Quoted 8 lines
hw/net/virtio-net.c static void
Quoted 8 lines
hw/net/virtio-net.c +1
-0virtio_net_add_queue (n,0 ); n->ctrl_vq =virtio_add_queue (vdev,64 , virtio_net_handle_ctrl); +memcpy (&macaddr_cmdline, &n->nic_conf.macaddr,sizeof (n->mac));qemu_macaddr_default_if_unset (&n->nic_conf.macaddr);memcpy (&n->mac[0 ], &n->nic_conf.macaddr,sizeof (n->mac)); n->status =VIRTIO_NET_S_LINK_UP ;@@ -3739,10 +3764,10 @@ static void
virtio_net_device_realize(DeviceState *dev, Error **errp)Quoted 3 lines
Quoted 3 lines
hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp)
Quoted 3 lines
hw/net/virtio-net.c +0
-0nc->rxfilter_notify_enabled =1 ; if (nc->peer && nc->peer->info->type ==
NET_CLIENT_DRIVER_VHOST_VDPA) {Quoted 4 lines
Quoted 4 lines
hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp)
Quoted 4 lines
hw/net/virtio-net.c +0
-4-struct virtio_net_config netcfg = {}; -memcpy (&netcfg.mac, &n->nic_conf.macaddr,ETH_ALEN ); - vhost_net_set_config(get_vhost_net(nc->peer), - (uint8_t *)&netcfg, 0, ETH_ALEN,
VHOST_SET_CONFIG_TYPE_FRONTEND);Quoted 1 line
Quoted 1 line
hw/net/virtio-net.c static void · line 3767
Quoted 1 line
hw/net/virtio-net.c +1
-0+ if (!virtio_net_check_vdpa_mac(nc, n, &macaddr_cmdline,errp)) {
Quoted 7 lines
Quoted 7 lines
hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp) · line 3770
Quoted 3 lines
hw/net/virtio-net.c +3
-0+virtio_cleanup (vdev); +return ; + }Any reason we remove
vhost_net_set_config()here? It is not described in the commit or does it belong to another patch?Quoted 7 lines
Quoted 2 lines
Thanks
as we discussed before, the MAC address in hardware should have a "higher priority"
than the MAC address in qemu cmdline. So I remove theset_configthere, the MAC address from the hardware will overwrite the MAC in qemu cmdline. so don't need toset_configto hardware now
Quoted 7 lines
Probably, but I meant it needs to be a separate patch.
For example the title said "add ...." but here it's a removal of something.
Thanks
sure will fix this
Thanks
cindy
Quoted 12 lines
Quoted 10 lines
Thanks,
cindyQuoted 7 lines
Quoted 6 lines
hw/net/virtio-net.c +0
-1}QTAILQ_INIT (&n->rsc_chains); n->qdev = dev; --2.45.0
Quoted 6 lines · Cindy Lu
When using a VDPA device, it is important to ensure that the MAC address in the hardware matches the MAC address from the QEMU command line.
This will allow the device to boot.Signed-off-by Cindy Lu <[email protected]>
Always post threads with a cover letter please.
Quoted 70 lines
--- hw/net/virtio-net.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)hw/net/virtio-net.c +29
-4@@ -3579,12 +3579,36 @@ static bool failover_hide_primary_device(DeviceListener *listener,/* failover_primary_hidden is set during feature negotiation */ return qatomic_read (&n->failover_primary_hidden); } +static bool virtio_net_check_vdpa_mac (NetClientState *nc,VirtIONet *n,MACAddr *cmdline_mac, +Error **errp) +{ +struct virtio_net_config hwcfg = {}; +static const MACAddr zero = { .a = {0 ,0 ,0 ,0 ,0 ,0 } }; + +vhost_net_get_config (get_vhost_net (nc->peer), (uint8_t *)&hwcfg,ETH_ALEN ); + +/* +* For VDPA device: Only two situations are acceptable: +* 1.The hardware MAC address is the same as the QEMU command line MAC +* address, and both of them are not 0. +*/ + +if (memcmp (&hwcfg.mac, &zero,sizeof (MACAddr)) !=0 ) { +if ((memcmp (&hwcfg.mac, cmdline_mac,sizeof (MACAddr)) ==0 )) { +return true; + } + } +error_setg (errp,"vDPA device's mac != the mac address from qemu cmdline" +"Please check the the vdpa device's setting." ); +return false; +}static void virtio_net_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);VirtIONet *n =VIRTIO_NET (dev);NetClientState *nc; +MACAddr macaddr_cmdline;int i;if (n->net_conf.mtu) {@@ -3692,6 +3716,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)virtio_net_add_queue (n,0 ); n->ctrl_vq =virtio_add_queue (vdev,64 , virtio_net_handle_ctrl); +memcpy (&macaddr_cmdline, &n->nic_conf.macaddr,sizeof (n->mac));qemu_macaddr_default_if_unset (&n->nic_conf.macaddr);memcpy (&n->mac[0 ], &n->nic_conf.macaddr,sizeof (n->mac)); n->status =VIRTIO_NET_S_LINK_UP ;@@ -3739,10 +3764,10 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) nc->rxfilter_notify_enabled =1 ;if (nc->peer && nc->peer->info->type ==NET_CLIENT_DRIVER_VHOST_VDPA ) { -struct virtio_net_config netcfg = {}; -memcpy (&netcfg.mac, &n->nic_conf.macaddr,ETH_ALEN ); -vhost_net_set_config (get_vhost_net (nc->peer), - (uint8_t *)&netcfg,0 ,ETH_ALEN ,VHOST_SET_CONFIG_TYPE_FRONTEND ); +if (!virtio_net_check_vdpa_mac (nc, n, &macaddr_cmdline, errp)) { +virtio_cleanup (vdev); +return ; + } }QTAILQ_INIT (&n->rsc_chains); n->qdev = dev;Signature · 1 line
2.45.0
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Cindy Lu
When using a VDPA device, it is important to ensure that the MAC address in the hardware matches the MAC address from the QEMU command line.
This will allow the device to boot.Signed-off-by Cindy Lu <[email protected]>Always post threads with a cover letter please.
Sure,will fix this
thanks
cindy
Quoted 72 lines
Quoted 71 lines
--- hw/net/virtio-net.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)hw/net/virtio-net.c +29
-5@@ -3579,12 +3579,36 @@ static bool failover_hide_primary_device(DeviceListener *listener,/* failover_primary_hidden is set during feature negotiation */ return qatomic_read (&n->failover_primary_hidden); } +static bool virtio_net_check_vdpa_mac (NetClientState *nc,VirtIONet *n,MACAddr *cmdline_mac, +Error **errp) +{ +struct virtio_net_config hwcfg = {}; +static const MACAddr zero = { .a = {0 ,0 ,0 ,0 ,0 ,0 } }; + +vhost_net_get_config (get_vhost_net (nc->peer), (uint8_t *)&hwcfg,ETH_ALEN ); + +/* +* For VDPA device: Only two situations are acceptable: +* 1.The hardware MAC address is the same as the QEMU command line MAC +* address, and both of them are not 0. +*/ + +if (memcmp (&hwcfg.mac, &zero,sizeof (MACAddr)) !=0 ) { +if ((memcmp (&hwcfg.mac, cmdline_mac,sizeof (MACAddr)) ==0 )) { +return true; + } + } +error_setg (errp,"vDPA device's mac != the mac address from qemu cmdline" +"Please check the the vdpa device's setting." ); +return false; +}static void virtio_net_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);VirtIONet *n =VIRTIO_NET (dev);NetClientState *nc; +MACAddr macaddr_cmdline;int i;if (n->net_conf.mtu) {@@ -3692,6 +3716,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)virtio_net_add_queue (n,0 ); n->ctrl_vq =virtio_add_queue (vdev,64 , virtio_net_handle_ctrl); +memcpy (&macaddr_cmdline, &n->nic_conf.macaddr,sizeof (n->mac));qemu_macaddr_default_if_unset (&n->nic_conf.macaddr);memcpy (&n->mac[0 ], &n->nic_conf.macaddr,sizeof (n->mac)); n->status =VIRTIO_NET_S_LINK_UP ;@@ -3739,10 +3764,10 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) nc->rxfilter_notify_enabled =1 ;if (nc->peer && nc->peer->info->type ==NET_CLIENT_DRIVER_VHOST_VDPA ) { -struct virtio_net_config netcfg = {}; -memcpy (&netcfg.mac, &n->nic_conf.macaddr,ETH_ALEN ); -vhost_net_set_config (get_vhost_net (nc->peer), - (uint8_t *)&netcfg,0 ,ETH_ALEN ,VHOST_SET_CONFIG_TYPE_FRONTEND ); +if (!virtio_net_check_vdpa_mac (nc, n, &macaddr_cmdline, errp)) { +virtio_cleanup (vdev); +return ; + } }QTAILQ_INIT (&n->rsc_chains); n->qdev = dev; --2.45.0