From 8c65e8d7c923ade6f3c7fbef43000562d4733629 Mon Sep 17 00:00:00 2001 From: fangyi Date: Sat, 7 Sep 2024 07:11:07 +0000 Subject: [PATCH 2/6] vdpa: support resizing virtio-blk capacity online for kernel vdpa Signed-off-by: fangyi --- hw/virtio/vdpa-dev.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c index 91e71847b0..bf4b3ec3fd 100644 --- a/hw/virtio/vdpa-dev.c +++ b/hw/virtio/vdpa-dev.c @@ -31,6 +31,7 @@ #include "hw/virtio/vdpa-dev-mig.h" #include "migration/migration.h" #include "exec/address-spaces.h" +#include "standard-headers/linux/virtio_ids.h" static void vhost_vdpa_device_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq) @@ -201,7 +202,23 @@ static void vhost_vdpa_device_get_config(VirtIODevice *vdev, uint8_t *config) { VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev); + uint8_t *new_config; + int ret; + + if (s->vdev_id != VIRTIO_ID_BLOCK) { + goto out; + } + new_config = g_malloc0(s->config_size); + ret = vhost_dev_get_config(&s->dev, new_config, s->config_size, NULL); + if (ret < 0) { + error_report("vhost-vdpa-device: get config failed(%d)\n", ret); + goto free; + } + memcpy(s->config, new_config, s->config_size); +free: + g_free(new_config); +out: memcpy(config, s->config, s->config_size); } -- 2.43.0