Skip to content

Commit

Permalink
vdpa-dev: Fix the issue of device status not updating when configurat…
Browse files Browse the repository at this point in the history
…ion interruption is triggered

The set_config callback function vhost_vdpa_device_get_config in
vdpa-dev does not fetch the current device status from the hardware
device, causing the guest os to not receive the latest device status
information.

The hardware updates the config status of the vdpa device and then
notifies the os. The guest os receives an interrupt notification,
triggering a get_config access in the kernel, which then enters qemu
internally. Ultimately, the vhost_vdpa_device_get_config function of
vdpa-dev is called

One scenario encountered is when the device needs to bring down the
vdpa net device. After modifying the status field of virtio_net_config
in the hardware, it sends an interrupt notification. However, the guest
os always receives the STATUS field as VIRTIO_NET_S_LINK_UP.

Signed-off-by: Yuxue Liu <[email protected]>
Acked-by: Jason Wang <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
(cherry picked from commit 6ae72f6)
Signed-off-by: Michael Tokarev <[email protected]>
  • Loading branch information
lyx634449800 authored and Michael Tokarev committed Apr 9, 2024
1 parent b57b102 commit cd461c8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hw/virtio/vdpa-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,14 @@ static void
vhost_vdpa_device_get_config(VirtIODevice *vdev, uint8_t *config)
{
VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
int ret;

ret = vhost_dev_get_config(&s->dev, s->config, s->config_size,
NULL);
if (ret < 0) {
error_report("get device config space failed");
return;
}
memcpy(config, s->config, s->config_size);
}

Expand Down

0 comments on commit cd461c8

Please sign in to comment.