From: Stefan Hajnoczi Date: Tue, 23 Feb 2021 14:46:42 +0000 (+0000) Subject: vhost-user-blk: fix blkcfg->num_queues endianness X-Git-Tag: v6.0.0-rc0~54^2~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=535255b43898d2e96744057eb86f8497d4d7a461;p=thirdparty%2Fqemu.git vhost-user-blk: fix blkcfg->num_queues endianness Treat the num_queues field as virtio-endian. On big-endian hosts the vhost-user-blk num_queues field was in the wrong endianness. Move the blkcfg.num_queues store operation from realize to vhost_user_blk_update_config() so feature negotiation has finished and we know the endianness of the device. VIRTIO 1.0 devices are little-endian, but in case someone wants to use legacy VIRTIO we support all endianness cases. Cc: qemu-stable@nongnu.org Signed-off-by: Stefan Hajnoczi Reviewed-by: Raphael Norwitz Reviewed-by: Michael S. Tsirkin Message-Id: <20210223144653.811468-2-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index da4fbf90844..b870a50e6b2 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -54,6 +54,9 @@ static void vhost_user_blk_update_config(VirtIODevice *vdev, uint8_t *config) { VHostUserBlk *s = VHOST_USER_BLK(vdev); + /* Our num_queues overrides the device backend */ + virtio_stw_p(vdev, &s->blkcfg.num_queues, s->num_queues); + memcpy(config, &s->blkcfg, sizeof(struct virtio_blk_config)); } @@ -491,10 +494,6 @@ reconnect: goto reconnect; } - if (s->blkcfg.num_queues != s->num_queues) { - s->blkcfg.num_queues = s->num_queues; - } - return; virtio_err: