diff --git a/lib/virtio/virtio_user.c b/lib/virtio/virtio_user.c index c688d61d6..cc1b3a18d 100644 --- a/lib/virtio/virtio_user.c +++ b/lib/virtio/virtio_user.c @@ -222,6 +222,10 @@ virtio_user_read_dev_config(struct virtio_dev *vdev, size_t offset, struct virtio_user_dev *dev = vdev->ctx; struct vhost_user_config cfg = {0}; + if ((dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_CONFIG)) == 0) { + return -ENOTSUP; + } + cfg.offset = 0; cfg.size = VHOST_USER_MAX_CONFIG_SIZE; @@ -241,6 +245,10 @@ virtio_user_write_dev_config(struct virtio_dev *vdev, size_t offset, struct virtio_user_dev *dev = vdev->ctx; struct vhost_user_config cfg = {0}; + if ((dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_CONFIG)) == 0) { + return -ENOTSUP; + } + cfg.offset = offset; cfg.size = length; memcpy(cfg.region, src, length);