- ret = ioctl(dev->vhostfd, req_vdpa, arg);
- if (ret < 0)
- PMD_DRV_LOG(ERR, "%s failed: %s",
- vhost_msg_strings[req], strerror(errno));
+ memcpy(data, config->buf, len);
+out:
+ free(config);
+
+ return ret;
+}
+
+static int
+vhost_vdpa_set_config(struct virtio_user_dev *dev, const uint8_t *data, uint32_t off, uint32_t len)
+{
+ struct vhost_vdpa_data *vdpa_data = dev->backend_data;
+ struct vhost_vdpa_config *config;
+ int ret = 0;
+
+ config = malloc(sizeof(*config) + len);
+ if (!config) {
+ PMD_DRV_LOG(ERR, "Failed to allocate vDPA config data");
+ return -1;
+ }
+
+ config->off = off;
+ config->len = len;
+
+ memcpy(config->buf, data, len);
+
+ ret = vhost_vdpa_ioctl(vdpa_data->vhostfd, VHOST_VDPA_SET_CONFIG, config);
+ if (ret) {
+ PMD_DRV_LOG(ERR, "Failed to set vDPA config (offset 0x%x, len 0x%x)", off, len);
+ ret = -1;
+ }
+
+ free(config);