]> git.proxmox.com Git - mirror_qemu.git/commitdiff
virtio-net: Set mac address to hardware if the peer is vdpa
authorCindy Lu <lulu@redhat.com>
Fri, 25 Sep 2020 15:13:33 +0000 (23:13 +0800)
committerJason Wang <jasowang@redhat.com>
Wed, 11 Nov 2020 08:52:23 +0000 (16:52 +0800)
If the peer's type is vdpa, we need to set the mac address to hardware
in virtio_net_device_realize,

Signed-off-by: Cindy Lu <lulu@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hw/net/virtio-net.c

index 277289d56e7645b3ba1037a71881147fab27aae3..9179013ac4025d31481c5b0004f8fffc45d1cadd 100644 (file)
@@ -3395,6 +3395,12 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
     nc = qemu_get_queue(n->nic);
     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_MASTER);
+    }
     QTAILQ_INIT(&n->rsc_chains);
     n->qdev = dev;