Skip to content

Commit 0d4654b

Browse files
blitzlikebreath
authored andcommitted
vfio-user: make flags more ergonomic
There are two issues with DmaMapFlags: 1. `READ_ONLY` being set doesn't mean that the mapping is read-only. This is confusing in code that uses these constants (same for `WRITE_ONLY`). 2. Due to some bitflags update the type doesn't derive standard traits anymore. Manually annotate those. Fix both of these issues. While I was here, I also added the necessary traits to DmaUnmapFlags. Signed-off-by: Julian Stecklina <[email protected]>
1 parent 91f2c7b commit 0d4654b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

vfio-user/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ fn default_migration_capabilities() -> MigrationCapabilities {
102102
}
103103

104104
bitflags! {
105-
#[derive(Debug)]
105+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
106106
pub struct DmaMapFlags: u32 {
107-
const READ_ONLY = 1 << 0;
108-
const WRITE_ONLY = 1 << 1;
109-
const READ_WRITE = Self::READ_ONLY.bits() | Self::WRITE_ONLY.bits();
107+
const READ = 1 << 0;
108+
const WRITE = 1 << 1;
109+
const READ_WRITE = Self::READ.bits() | Self::WRITE.bits();
110110
}
111111

112-
#[derive(Debug)]
112+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
113113
pub struct DmaUnmapFlags: u32 {
114114
const GET_DIRTY_PAGE_INFO = 1 << 1;
115115
const UNMAP_ALL = 1 << 2;

0 commit comments

Comments
 (0)