If the backend advertises F_STANDALONE validate that it supports the other mandatory features or error out.
Signed-off-by: Alex Bennée <[email protected]> --- hw/virtio/vhost-user.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 28b021d5d3..3116b3e46a 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -74,6 +74,8 @@ enum VhostUserProtocolFeature { /* Feature 14 reserved for VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS. */ VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS = 15, VHOST_USER_PROTOCOL_F_STATUS = 16, + VHOST_USER_PROTOCOL_F_XEN_MMAP = 17, + VHOST_USER_PROTOCOL_F_STANDALONE = 18, VHOST_USER_PROTOCOL_F_MAX }; @@ -2048,6 +2050,21 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, } } + /* + * If the backend supports F_STANDALONE we should validate it + * supports the other features we expect. We can't check for + * F_CONFIG support until we know if there is a config space + * to manage. + */ + if (virtio_has_feature(protocol_features, + VHOST_USER_PROTOCOL_F_STANDALONE)) { + if (!virtio_has_feature(protocol_features, VHOST_USER_PROTOCOL_F_STATUS)) { + error_setg(errp, "vhost-user device expecting F_STANDALONE device to also " + "support F_STATUS but it does not."); + return -EPROTO; + } + } + /* final set of protocol features */ dev->protocol_features = protocol_features; err = vhost_user_set_protocol_features(dev, dev->protocol_features); -- 2.39.2
