On Wed, 18 Feb 2026, Pierrick Bouvier wrote:
On 2/18/26 2:17 PM, Pierrick Bouvier wrote:
On 2/18/26 1:00 PM, Philippe Mathieu-Daudé wrote:
On 13/2/26 00:46, Pierrick Bouvier wrote:
This simplifies code compared to having
virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) or
!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1).
Signed-off-by: Pierrick Bouvier <[email protected]>
---
include/hw/virtio/virtio-access.h | 3 +--
include/hw/virtio/virtio.h | 12 +++++++++++-
hw/net/virtio-net.c | 2 +-
hw/virtio/vhost.c | 2 +-
hw/virtio/virtio-pci.c | 2 +-
hw/virtio/virtio.c | 16 ++++++++--------
6 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 27cd98d2fe1..8f1e4323599 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -468,9 +468,19 @@ static inline bool
virtio_host_has_feature(VirtIODevice *vdev,
return virtio_has_feature(vdev->host_features, fbit);
}
+static inline bool virtio_vdev_is_modern(const VirtIODevice *vdev)
+{
+ return virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1);
+}
+
+static inline bool virtio_vdev_is_legacy(const VirtIODevice *vdev)
+{
+ return !virtio_vdev_is_modern(vdev);
+}
With retrospective, mentioning 'modern' was a mistake IMHO. But I
understand it was simpler to add 'modern' code without updating the
'legacy' code base. Today I'd rather have 'legacy' explicit in function
names, everything else being the normal / current / modern version,
without having to clarify it.
Agree.
Thus back to this series I'd rather not introduce virtio_vdev_is_modern
and use !virtio_vdev_is_legacy instead.
Sounds good. I feel it's still easier and clearer to read than
"!has_feature(1.0)". But as said in my previous answer to Zoltan, I
don't mind this patch too much, only 3rd one really matter.
s/!has_feature(1.0)/has_feature(1.0), thus showing I've been confused once
more :).
The has_feature(1.0) is more specific though. What if 1.0 becomes legacy
too? Then modern and legacy is more confusing than testing for a specific
feature. I still think not touching this would be the easiest as the
introduced legacy/modern does not seem to make it much clearer.
Regards,
BALATON Zoltan