Skip to contentSkip to conversation

virtio-blk: store the zone-append sector as little-endian

PATCH In review Michael Bommarito 3 participants 4 messages Jun 17 – Jun 18

lore
Share & tools
lore
#0 lore raw

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.

Assisted-by Claude:claude-opus-4-8

---
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
index 9cb9f1fb2..e2a35fae2 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
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 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.

Assisted-by Claude:claude-opus-4-8

---
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.

Quoted 2 lines
 hw/block/virtio-blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#2 lore raw
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 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.

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.

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

---
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.

Quoted 4 lines
Quoted 2 lines
 hw/block/virtio-blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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 :|
#3 lore raw
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