virtio-blk: store the zone-append sector as little-endian
PATCH 1/1 virtio-blk: store the zone-append sector as little-endian
The zone-append completion path writes the append sector back to the guest with virtio_stq_p(), the VIRTIO_F_VERSION_1-aware accessor, while the rest of the zoned reply path (the zone report descriptors and the report header) stores its fields with cpu_to_le64(). The zoned feature is only defined for VIRTIO 1.x devices and the virtio specification defines all of its fields as little-endian, so store the append sector with stq_le_p() too, for a single spec-matching convention across the zoned path.
This is not a functional change for a VIRTIO 1.x device, where virtio_stq_p() already stores little-endian; it only removes the mixed convention within the zoned reply path.
---
Testing: builds (qemu-system-x86_64) and the qos-test virtio-blk cases (basic, indirect, config, resize, msix, idx, nxvirtq, hotplug) pass against the patched binary. No functional change on a VIRTIO_F_VERSION_1 device, where virtio_stq_p() already stores little-endian.
hw/block/virtio-blk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/block/virtio-blk.c +2 -2
@@ -762,8 +762,8 @@ static void virtio_blk_zone_append_complete(void *opaque, int ret) goto out; } -virtio_stq_p (vdev, &append_sector, - data->zone_append_data.offset >>BDRV_SECTOR_BITS ); +stq_le_p (&append_sector, + data->zone_append_data.offset >>BDRV_SECTOR_BITS ); n =iov_from_buf (data->in_iov, data->in_num,0 , &append_sector,sizeof (append_sector));if (n !=sizeof (append_sector)) {
Signature · 1 line
2.53.0
Quoted 23 lines · Michael Bommarito
The zone-append completion path writes the append sector back to the guest with
virtio_stq_p(), the VIRTIO_F_VERSION_1-aware accessor, while the rest of the zoned reply path (the zone report descriptors and the report header) stores its fields withcpu_to_le64(). The zoned feature is only defined for VIRTIO 1.x devices and the virtio specification defines all of its fields as little-endian, so store the append sector withstq_le_p()too, for a single spec-matching convention across the zoned path.This is not a functional change for a VIRTIO 1.x device, where
virtio_stq_p()already stores little-endian; it only removes the mixed convention within the zoned reply path.Suggested-by Michael S. Tsirkin <[email protected]>Assisted-by Claude:claude-opus-4-8Signed-off-by Michael Bommarito <[email protected]>---
Testing: builds (qemu-system-x86_64) and the qos-test virtio-blk cases (basic, indirect, config, resize, msix, idx, nxvirtq, hotplug) pass against the patched binary. No functional change on aVIRTIO_F_VERSION_1device, wherevirtio_stq_p()already stores little-endian.
Quoted 2 lines
hw/block/virtio-blk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines · Stefan Hajnoczi
Quoted 9 lines · Michael Bommarito
The zone-append completion path writes the append sector back to the guest with
virtio_stq_p(), the VIRTIO_F_VERSION_1-aware accessor, while the rest of the zoned reply path (the zone report descriptors and the report header) stores its fields withcpu_to_le64(). The zoned feature is only defined for VIRTIO 1.x devices and the virtio specification defines all of its fields as little-endian, so store the append sector withstq_le_p()too, for a single spec-matching convention across the zoned path.
Quoted 6 lines
Quoted 6 lines
This is not a functional change for a VIRTIO 1.x device, where
virtio_stq_p()already stores little-endian; it only removes the mixed convention within the zoned reply path.Suggested-by Michael S. Tsirkin <[email protected]>Assisted-by Claude:claude-opus-4-8
^^^^^^^ strictly speaking this may not be compatible with our policy if Claude was used to write the patch. If Claude was merely used for research or testing, that's fine.
If it did write the patch, we could make an exception on the basis that there is only a single way to write this trivial fix.
None the less the Assisted-by advertizing hoarding should be removed before merging, as even our new proposed looser policy, rejects use of Assisted-by.
Quoted 8 lines
Quoted 8 lines
Signed-off-by Michael Bommarito <[email protected]>---
Testing: builds (qemu-system-x86_64) and the qos-test virtio-blk cases (basic, indirect, config, resize, msix, idx, nxvirtq, hotplug) pass against the patched binary. No functional change on aVIRTIO_F_VERSION_1device, wherevirtio_stq_p()already stores little-endian.
Quoted 4 lines
Quoted 2 lines
hw/block/virtio-blk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Reviewed-by Stefan Hajnoczi <[email protected]>
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Quoted 6 lines · Daniel P. Berrangé
If it did write the patch, we could make an exception on the basis that there is only a single way to write this trivial fix.
None the less the Assisted-by advertizing hoarding should be removed before merging, as even our new proposed looser policy, rejects use of Assisted-by.
FWIW, the patch is pretty mechanical and basically consisted of sed on a single function based on conversation with MST. I told Claude to make the change, and then it ran the rest of the testing and patch setup.
Appreciate the policy is in flux and sorry for not flagging that before.
Thanks,
Mike