When I'm testing the vhost-user-blk, and I found the features bits in guest os are not the same as the setting in vhost backend. After digging into the details, I found there are two different features set path. One is the vhost-user socket path VHOST_USER_GET_FEATURES, the another is:
220 static uint64_t vhost_user_blk_get_features(VirtIODevice *vdev, 221 uint64_t features, 222 Error **errp) 223 { 224 VHostUserBlk *s = VHOST_USER_BLK(vdev); 225 uint64_t get_features; 226 227 /* Turn on pre-defined features */ 228 virtio_add_feature(&features, VIRTIO_BLK_F_SEG_MAX); 229 virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY); 230 virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY); 231 virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE); 232 virtio_add_feature(&features, VIRTIO_BLK_F_FLUSH); 233 234 if (s->config_wce) { 235 virtio_add_feature(&features, VIRTIO_BLK_F_CONFIG_WCE); 236 } 237 if (s->config_ro) { 238 virtio_add_feature(&features, VIRTIO_BLK_F_RO); 239 } 240 if (s->num_queues > 1) { 241 virtio_add_feature(&features, VIRTIO_BLK_F_MQ); 242 } 243 244 get_features = vhost_get_features(&s->dev, user_feature_bits, features); 245 246 return get_features; 247 } This set is the last one, so whatever features I have set in vhost backend still doesn't work. For example, I set device features to 0x754005646, after negotiation, the device features are 0x110000644. This issue is definitely from Qemu, not the vhost backend, and linux kernel. Looks like this code is copied from virtio-blk.c, it's not right. [root@node1 13:17:29 ~]$print_features 0x110000644 2: 1 6: 1 9: 1 10: 1 28: 1 32: 1 [root@node1 13:17:43 ~]$print_features 0x754005646 1: 1 2: 1 6: 1 9: 1 10: 1 12: 1 14: 1 26: 1 28: 1 30: 1 32: 1 33: 1 34: 1