mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
vfio_user: Improve flags for DMA_MAP command
Replace the use of an enum with a bitfield representation which means that is now possible to logical OR flags together. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
01900e3c2b
commit
91e2601523
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1384,6 +1384,7 @@ dependencies = [
|
||||
name = "vfio_user"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
"log",
|
||||
"serde",
|
||||
|
@ -5,6 +5,7 @@ authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bitflags = "1.3.2"
|
||||
libc = "0.2.139"
|
||||
log = "0.4.17"
|
||||
serde = { version = "1.0.151", features = ["rc"] }
|
||||
|
@ -3,6 +3,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use bitflags::bitflags;
|
||||
use std::ffi::CString;
|
||||
use std::fs::File;
|
||||
use std::io::{IoSlice, Read, Write};
|
||||
@ -90,19 +91,11 @@ const fn default_migration_capabilities() -> MigrationCapabilities {
|
||||
MigrationCapabilities { pgsize: 4096 }
|
||||
}
|
||||
|
||||
#[repr(u32)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[allow(dead_code)]
|
||||
enum DmaMapFlags {
|
||||
Unknown = 0,
|
||||
ReadOnly = 1,
|
||||
WriteOnly = 2,
|
||||
ReadWrite = 3,
|
||||
}
|
||||
|
||||
impl Default for DmaMapFlags {
|
||||
fn default() -> Self {
|
||||
Self::Unknown
|
||||
bitflags! {
|
||||
struct DmaMapFlags: u32 {
|
||||
const READ_ONLY = 1 << 0;
|
||||
const WRITE_ONLY = 1 << 1;
|
||||
const READ_WRITE = Self::READ_ONLY.bits | Self::WRITE_ONLY.bits;
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +104,7 @@ impl Default for DmaMapFlags {
|
||||
struct DmaMap {
|
||||
header: Header,
|
||||
argsz: u32,
|
||||
flags: DmaMapFlags,
|
||||
flags: u32,
|
||||
offset: u64,
|
||||
address: u64,
|
||||
size: u64,
|
||||
@ -367,7 +360,7 @@ impl Client {
|
||||
..Default::default()
|
||||
},
|
||||
argsz: (size_of::<DmaMap>() - size_of::<Header>()) as u32,
|
||||
flags: DmaMapFlags::ReadWrite,
|
||||
flags: DmaMapFlags::READ_WRITE.bits,
|
||||
offset,
|
||||
address,
|
||||
size,
|
||||
|
Loading…
Reference in New Issue
Block a user