@@ -156,8 +156,9 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
* disconnect/reconnect a VDPA peer.
*/
if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
- ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
- n->config_size);
+ struct vhost_net *net = get_vhost_net(nc->peer);
+
+ ret = vhost_net_get_config(net, (uint8_t *)&netcfg, n->config_size);
if (ret == -1) {
return;
}
@@ -173,6 +174,12 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
memcpy(netcfg.mac, n->mac, ETH_ALEN);
}
+ if (vdev->guest_features & BIT_ULL(VIRTIO_NET_F_STATUS) &&
+ !(net->dev.features & BIT_ULL(VIRTIO_NET_F_STATUS))) {
+ /* Emulating link up in qemu */
+ netcfg.status |= VIRTIO_NET_S_LINK_UP;
+ }
+
memcpy(config, &netcfg, n->config_size);
}
}
At this moment this code path is not reached, but vdpa devices can offer VIRTIO_NET_F_STATUS unconditionally. While the guest must assume that link is always up by the standard, qemu will set the status bit to 1 always in this case. This makes little use by itself, but VIRTIO_NET_F_STATUS is needed for the guest to read status bit VIRTIO_NET_F_GUEST_ANNOUNCE, used by feature VIRTIO_NET_F_GUEST_ANNOUNCE. So qemu must emulate status feature in case it needs to emulate the guest announce feature. Signed-off-by: Eugenio PĂ©rez <eperezma@redhat.com> --- hw/net/virtio-net.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)