Skip to content

Commit

Permalink
virtio: check F_CONFIG feature before sending GET/SET_CONFIG
Browse files Browse the repository at this point in the history
The device might not have this message implemented.
Sending it could result in a connection being terminated.

Change-Id: I53c08f1108ebc7de630569f3983c317cc6510fa4
Signed-off-by: Dariusz Stojaczyk <[email protected]>
Reviewed-on: https://review.gerrithub.io/417636
Reviewed-by: Ben Walker <[email protected]>
Reviewed-by: Jim Harris <[email protected]>
Tested-by: SPDK Automated Test System <[email protected]>
  • Loading branch information
darsto authored and jimharris committed Jul 5, 2018
1 parent 62844ae commit 436c0c1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/virtio/virtio_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down

0 comments on commit 436c0c1

Please sign in to comment.