mirror of https://github.com/xemu-project/xemu.git
vhost-user-blk: split vhost_user_blk_sync_config()
Split vhost_user_blk_sync_config() out from vhost_user_blk_handle_config_change(), to be reused in the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Acked-by: Raphael Norwitz <raphael@enfabrica.net> Message-Id: <20240920094936.450987-3-vsementsov@yandex-team.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
This commit is contained in:
parent
9e4cc917e0
commit
4dfa127314
|
@ -90,27 +90,39 @@ static void vhost_user_blk_set_config(VirtIODevice *vdev, const uint8_t *config)
|
|||
s->blkcfg.wce = blkcfg->wce;
|
||||
}
|
||||
|
||||
static int vhost_user_blk_sync_config(DeviceState *dev, Error **errp)
|
||||
{
|
||||
int ret;
|
||||
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
|
||||
VHostUserBlk *s = VHOST_USER_BLK(vdev);
|
||||
|
||||
ret = vhost_dev_get_config(&s->dev, (uint8_t *)&s->blkcfg,
|
||||
vdev->config_len, errp);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
memcpy(vdev->config, &s->blkcfg, vdev->config_len);
|
||||
virtio_notify_config(vdev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vhost_user_blk_handle_config_change(struct vhost_dev *dev)
|
||||
{
|
||||
int ret;
|
||||
VirtIODevice *vdev = dev->vdev;
|
||||
VHostUserBlk *s = VHOST_USER_BLK(dev->vdev);
|
||||
Error *local_err = NULL;
|
||||
|
||||
if (!dev->started) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = vhost_dev_get_config(dev, (uint8_t *)&s->blkcfg,
|
||||
vdev->config_len, &local_err);
|
||||
ret = vhost_user_blk_sync_config(DEVICE(dev->vdev), &local_err);
|
||||
if (ret < 0) {
|
||||
error_report_err(local_err);
|
||||
return ret;
|
||||
}
|
||||
|
||||
memcpy(dev->vdev->config, &s->blkcfg, vdev->config_len);
|
||||
virtio_notify_config(dev->vdev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue