virtio-queue: Add an is_read_only() method for DescriptorChain

Add an is_read_only method to the DescriptorChain struct.  This is
easier to read at a glance than `!is_write_only()`, which looks almost
the same as `is_write_only()`.

BUG=chromium:703939
TEST=none

Change-Id: I0cb3b17c30e38804a21d3e63e975157c96879cb4
Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1067703
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
This commit is contained in:
Chirantan Ekbote 2018-05-21 14:28:42 -07:00 committed by chrome-bot
parent 6452eaf902
commit dd19b2e28a

View file

@ -103,6 +103,14 @@ impl<'a> DescriptorChain<'a> {
self.flags & VIRTQ_DESC_F_WRITE != 0
}
/// If the driver designated this as a read only descriptor.
///
/// If this is false, this descriptor is write only.
/// Read only means the emulated device can read and the driver can write.
pub fn is_read_only(&self) -> bool {
self.flags & VIRTQ_DESC_F_WRITE == 0
}
/// Gets the next descriptor in this descriptor chain, if there is one.
///
/// Note that this is distinct from the next descriptor chain returned by `AvailIter`, which is