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

Michael Bommarito posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260617151739.4072252-1-michael.bommarito@gmail.com
Maintainers: Stefan Hajnoczi <stefanha@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
hw/block/virtio-blk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] virtio-blk: store the zone-append sector as little-endian
Posted by Michael Bommarito 1 month, 1 week ago
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.

Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
---
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(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 9cb9f1fb2..e2a35fae2 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -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)) {
-- 
2.53.0
Re: [PATCH] virtio-blk: store the zone-append sector as little-endian
Posted by Stefan Hajnoczi 1 month, 1 week ago
On Wed, Jun 17, 2026 at 11:17:39AM -0400, Michael Bommarito wrote:
> 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.
> 
> Suggested-by: Michael S. Tsirkin <mst@redhat.com>
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
> ---
> 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(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Re: [PATCH] virtio-blk: store the zone-append sector as little-endian
Posted by Daniel P. Berrangé 1 month, 1 week ago
On Thu, Jun 18, 2026 at 11:20:59AM -0400, Stefan Hajnoczi wrote:
> On Wed, Jun 17, 2026 at 11:17:39AM -0400, Michael Bommarito wrote:
> > 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.
> > 
> > Suggested-by: Michael S. Tsirkin <mst@redhat.com>
> > 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.

> > Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
> > ---
> > 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(-)
> 
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>



With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
Re: [PATCH] virtio-blk: store the zone-append sector as little-endian
Posted by Michael Bommarito 1 month, 1 week ago
On Thu, Jun 18, 2026 at 12:23 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> 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