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.
Thus back to this series I'd rather not introduce virtio_vdev_is_modern
and use !virtio_vdev_is_legacy instead.