mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
virtio: add feature checking helpers
Add a helper function for checking whether a bit is set in the guest features for a vdev as well as one that works on a feature bit set. Convert code that open-coded this: It cleans up the code and makes it easier to extend the guest feature bits. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
0cd09c3a6c
commit
ef546f1275
8 changed files with 42 additions and 31 deletions
|
@ -231,6 +231,17 @@ static inline void virtio_clear_feature(uint32_t *features, unsigned int fbit)
|
|||
*features &= ~(1 << fbit);
|
||||
}
|
||||
|
||||
static inline bool __virtio_has_feature(uint32_t features, unsigned int fbit)
|
||||
{
|
||||
assert(fbit < 32);
|
||||
return !!(features & (1 << fbit));
|
||||
}
|
||||
|
||||
static inline bool virtio_has_feature(VirtIODevice *vdev, unsigned int fbit)
|
||||
{
|
||||
return __virtio_has_feature(vdev->guest_features, fbit);
|
||||
}
|
||||
|
||||
static inline bool virtio_is_big_endian(VirtIODevice *vdev)
|
||||
{
|
||||
assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue