On 1/7/26 11:08 AM, Thomas Huth wrote:
On 07/01/2026 15.44, Thomas Huth wrote:
On 10/12/2025 21.54, [email protected] wrote:
From: Jared Rossi <[email protected]>
Enable virt-queue PCI configuration and add routines for
virtio-blk-pci devices.
Signed-off-by: Jared Rossi <[email protected]>
---
...
+static int virtio_pci_set_gfeatures(VDev *vdev)
+{
+ int rc;
+
+ rc = pci_bswap32_write(vdev->pci_fh, c_cap.off +
VPCI_C_OFFSET_GFSELECT,
+ c_cap.bar, 0);
+
+ rc |= pci_bswap32_write(vdev->pci_fh, c_cap.off +
VPCI_C_OFFSET_GF,
+ c_cap.bar, vdev->guest_features[1]);
+
+ rc |= pci_bswap32_write(vdev->pci_fh, c_cap.off +
VPCI_C_OFFSET_GFSELECT,
+ c_cap.bar, 1);
+
+ rc |= pci_bswap32_write(vdev->pci_fh, c_cap.off +
VPCI_C_OFFSET_GF,
+ c_cap.bar, vdev->guest_features[0]);
+
+ if (rc) {
+ puts("Failed to set PCI feature bits");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int virtio_pci_get_blk_config(VDev *vdev)
+{
+ return pci_read_flex(vdev->pci_fh, d_cap.off, d_cap.bar, &vdev-
>config.blk,
+ sizeof(VirtioBlkConfig));
I'm a little bit surprised that there does not seem to be any
endianess swapping for the config.blk data anywhere here ... isn't
that config space data supposed to be in little endian?
... oh, wait, you're not negotiating VIRTIO_F_VERSION_1, are you? ...
so the config space is still in big endian for legacy virtio? ...
hmm, I guess it's ok for now, but in the long run, I think we should
rather use VERSION_1 instead.
Thinking about this twice, could you please have a try to use
VIRTIO_F_VERSION_1 right from the start? I already heard from some
people that they'd rather want to get rid of legacy virtio in QEMU
(e.g. for the universal binary project that includes multiple targets
in a single QEMU binary), so I think it would be safer to immediately
go with VERSION_1 here.
Thanks,
Thomas
Hi Thomas,
I touched on this in reply to your other message, but yes, I agree that
it is better to do all of these negotiations in the most compatible way
right from the start. I will fix the feature negotiations and try to
avoid using anything legacy.
Thanks again for your reviews,
Jared Rossi