mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
vm-virtio, virtio-devices: Address Rust 1.51.0 clippy issue (upper_case_acronyms)
error: name `TYPE_UNKNOWN` contains a capitalized acronym --> vm-virtio/src/lib.rs:48:5 | 48 | TYPE_UNKNOWN = 0xFF, | ^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `Type_Unknown` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
261c039831
commit
aa34d545f6
@ -328,7 +328,7 @@ impl Balloon {
|
||||
|
||||
Ok(Balloon {
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_BALLOON as u32,
|
||||
device_type: VirtioDeviceType::Balloon as u32,
|
||||
avail_features,
|
||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||
|
@ -430,7 +430,7 @@ impl Block {
|
||||
|
||||
Ok(Block {
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_BLOCK as u32,
|
||||
device_type: VirtioDeviceType::Block as u32,
|
||||
avail_features,
|
||||
paused_sync: Some(Arc::new(Barrier::new(num_queues + 1))),
|
||||
queue_sizes: vec![queue_size; num_queues],
|
||||
|
@ -344,7 +344,7 @@ impl Console {
|
||||
Ok((
|
||||
Console {
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_CONSOLE as u32,
|
||||
device_type: VirtioDeviceType::Console as u32,
|
||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||
avail_features,
|
||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||
|
@ -769,7 +769,7 @@ impl Iommu {
|
||||
Iommu {
|
||||
id,
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_IOMMU as u32,
|
||||
device_type: VirtioDeviceType::Iommu as u32,
|
||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||
avail_features: 1u64 << VIRTIO_F_VERSION_1
|
||||
| 1u64 << VIRTIO_IOMMU_F_MAP_UNMAP
|
||||
|
@ -816,7 +816,7 @@ impl Mem {
|
||||
|
||||
Ok(Mem {
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_MEM as u32,
|
||||
device_type: VirtioDeviceType::Mem as u32,
|
||||
avail_features,
|
||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||
|
@ -251,7 +251,7 @@ impl Net {
|
||||
|
||||
Ok(Net {
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_NET as u32,
|
||||
device_type: VirtioDeviceType::Net as u32,
|
||||
avail_features,
|
||||
queue_sizes: vec![queue_size; queue_num],
|
||||
paused_sync: Some(Arc::new(Barrier::new((num_queues / 2) + 1))),
|
||||
|
@ -300,7 +300,7 @@ impl Pmem {
|
||||
|
||||
Ok(Pmem {
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_PMEM as u32,
|
||||
device_type: VirtioDeviceType::Pmem as u32,
|
||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||
avail_features,
|
||||
|
@ -154,7 +154,7 @@ impl Rng {
|
||||
|
||||
Ok(Rng {
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_RNG as u32,
|
||||
device_type: VirtioDeviceType::Rng as u32,
|
||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||
avail_features,
|
||||
|
@ -384,11 +384,11 @@ impl VirtioPciDevice {
|
||||
// to firmware without requiring excessive identity mapping.
|
||||
let mut use_64bit_bar = true;
|
||||
let (class, subclass) = match VirtioDeviceType::from(locked_device.device_type()) {
|
||||
VirtioDeviceType::TYPE_NET => (
|
||||
VirtioDeviceType::Net => (
|
||||
PciClassCode::NetworkController,
|
||||
&PciNetworkControllerSubclass::EthernetController as &dyn PciSubclass,
|
||||
),
|
||||
VirtioDeviceType::TYPE_BLOCK => {
|
||||
VirtioDeviceType::Block => {
|
||||
use_64bit_bar = false;
|
||||
(
|
||||
PciClassCode::MassStorage,
|
||||
|
@ -139,7 +139,7 @@ impl Blk {
|
||||
|
||||
Ok(Blk {
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_BLOCK as u32,
|
||||
device_type: VirtioDeviceType::Block as u32,
|
||||
queue_sizes: vec![vu_cfg.queue_size; vu_cfg.num_queues],
|
||||
avail_features,
|
||||
acked_features,
|
||||
|
@ -356,7 +356,7 @@ impl Fs {
|
||||
|
||||
Ok(Fs {
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_FS as u32,
|
||||
device_type: VirtioDeviceType::Fs as u32,
|
||||
avail_features,
|
||||
acked_features,
|
||||
queue_sizes: vec![queue_size; num_queues],
|
||||
|
@ -151,7 +151,7 @@ impl Net {
|
||||
Ok(Net {
|
||||
id,
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_NET as u32,
|
||||
device_type: VirtioDeviceType::Net as u32,
|
||||
queue_sizes: vec![vu_cfg.queue_size; queue_num],
|
||||
avail_features,
|
||||
acked_features,
|
||||
|
@ -333,7 +333,7 @@ where
|
||||
|
||||
Ok(Vsock {
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_VSOCK as u32,
|
||||
device_type: VirtioDeviceType::Vsock as u32,
|
||||
avail_features,
|
||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||
@ -566,10 +566,7 @@ mod tests {
|
||||
(driver_features & 0xffff_ffff) as u32,
|
||||
(driver_features >> 32) as u32,
|
||||
];
|
||||
assert_eq!(
|
||||
ctx.device.device_type(),
|
||||
VirtioDeviceType::TYPE_VSOCK as u32
|
||||
);
|
||||
assert_eq!(ctx.device.device_type(), VirtioDeviceType::Vsock as u32);
|
||||
assert_eq!(ctx.device.queue_max_sizes(), QUEUE_SIZES);
|
||||
assert_eq!(ctx.device.features() as u32, device_pages[0]);
|
||||
assert_eq!((ctx.device.features() >> 32) as u32, device_pages[1]);
|
||||
|
@ -189,7 +189,7 @@ impl Watchdog {
|
||||
let timer = unsafe { File::from_raw_fd(timer_fd) };
|
||||
Ok(Watchdog {
|
||||
common: VirtioCommon {
|
||||
device_type: VirtioDeviceType::TYPE_WATCHDOG as u32,
|
||||
device_type: VirtioDeviceType::Watchdog as u32,
|
||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||
avail_features,
|
||||
|
@ -31,41 +31,41 @@ pub const VIRTIO_MSI_NO_VECTOR: u16 = 0xffff;
|
||||
#[allow(non_camel_case_types)]
|
||||
#[repr(C)]
|
||||
pub enum VirtioDeviceType {
|
||||
TYPE_NET = 1,
|
||||
TYPE_BLOCK = 2,
|
||||
TYPE_CONSOLE = 3,
|
||||
TYPE_RNG = 4,
|
||||
TYPE_BALLOON = 5,
|
||||
TYPE_9P = 9,
|
||||
TYPE_GPU = 16,
|
||||
TYPE_INPUT = 18,
|
||||
TYPE_VSOCK = 19,
|
||||
TYPE_IOMMU = 23,
|
||||
TYPE_MEM = 24,
|
||||
TYPE_FS = 26,
|
||||
TYPE_PMEM = 27,
|
||||
TYPE_WATCHDOG = 35, // Temporary until official number allocated
|
||||
TYPE_UNKNOWN = 0xFF,
|
||||
Net = 1,
|
||||
Block = 2,
|
||||
Console = 3,
|
||||
Rng = 4,
|
||||
Balloon = 5,
|
||||
Fs9P = 9,
|
||||
Gpu = 16,
|
||||
Input = 18,
|
||||
Vsock = 19,
|
||||
Iommu = 23,
|
||||
Mem = 24,
|
||||
Fs = 26,
|
||||
Pmem = 27,
|
||||
Watchdog = 35, // Temporary until official number allocated
|
||||
Unknown = 0xFF,
|
||||
}
|
||||
|
||||
impl From<u32> for VirtioDeviceType {
|
||||
fn from(t: u32) -> Self {
|
||||
match t {
|
||||
1 => VirtioDeviceType::TYPE_NET,
|
||||
2 => VirtioDeviceType::TYPE_BLOCK,
|
||||
3 => VirtioDeviceType::TYPE_CONSOLE,
|
||||
4 => VirtioDeviceType::TYPE_RNG,
|
||||
5 => VirtioDeviceType::TYPE_BALLOON,
|
||||
9 => VirtioDeviceType::TYPE_9P,
|
||||
16 => VirtioDeviceType::TYPE_GPU,
|
||||
18 => VirtioDeviceType::TYPE_INPUT,
|
||||
19 => VirtioDeviceType::TYPE_VSOCK,
|
||||
23 => VirtioDeviceType::TYPE_IOMMU,
|
||||
24 => VirtioDeviceType::TYPE_MEM,
|
||||
26 => VirtioDeviceType::TYPE_FS,
|
||||
27 => VirtioDeviceType::TYPE_PMEM,
|
||||
35 => VirtioDeviceType::TYPE_WATCHDOG,
|
||||
_ => VirtioDeviceType::TYPE_UNKNOWN,
|
||||
1 => VirtioDeviceType::Net,
|
||||
2 => VirtioDeviceType::Block,
|
||||
3 => VirtioDeviceType::Console,
|
||||
4 => VirtioDeviceType::Rng,
|
||||
5 => VirtioDeviceType::Balloon,
|
||||
9 => VirtioDeviceType::Fs9P,
|
||||
16 => VirtioDeviceType::Gpu,
|
||||
18 => VirtioDeviceType::Input,
|
||||
19 => VirtioDeviceType::Vsock,
|
||||
23 => VirtioDeviceType::Iommu,
|
||||
24 => VirtioDeviceType::Mem,
|
||||
26 => VirtioDeviceType::Fs,
|
||||
27 => VirtioDeviceType::Pmem,
|
||||
35 => VirtioDeviceType::Watchdog,
|
||||
_ => VirtioDeviceType::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,21 +76,21 @@ impl fmt::Display for VirtioDeviceType {
|
||||
// This trait requires `fmt` with this exact signature.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let output = match *self {
|
||||
VirtioDeviceType::TYPE_NET => "net",
|
||||
VirtioDeviceType::TYPE_BLOCK => "block",
|
||||
VirtioDeviceType::TYPE_CONSOLE => "console",
|
||||
VirtioDeviceType::TYPE_RNG => "rng",
|
||||
VirtioDeviceType::TYPE_BALLOON => "balloon",
|
||||
VirtioDeviceType::TYPE_GPU => "gpu",
|
||||
VirtioDeviceType::TYPE_9P => "9p",
|
||||
VirtioDeviceType::TYPE_INPUT => "input",
|
||||
VirtioDeviceType::TYPE_VSOCK => "vsock",
|
||||
VirtioDeviceType::TYPE_IOMMU => "iommu",
|
||||
VirtioDeviceType::TYPE_MEM => "mem",
|
||||
VirtioDeviceType::TYPE_FS => "fs",
|
||||
VirtioDeviceType::TYPE_PMEM => "pmem",
|
||||
VirtioDeviceType::TYPE_WATCHDOG => "watchdog",
|
||||
VirtioDeviceType::TYPE_UNKNOWN => "UNKNOWN",
|
||||
VirtioDeviceType::Net => "net",
|
||||
VirtioDeviceType::Block => "block",
|
||||
VirtioDeviceType::Console => "console",
|
||||
VirtioDeviceType::Rng => "rng",
|
||||
VirtioDeviceType::Balloon => "balloon",
|
||||
VirtioDeviceType::Gpu => "gpu",
|
||||
VirtioDeviceType::Fs9P => "9p",
|
||||
VirtioDeviceType::Input => "input",
|
||||
VirtioDeviceType::Vsock => "vsock",
|
||||
VirtioDeviceType::Iommu => "iommu",
|
||||
VirtioDeviceType::Mem => "mem",
|
||||
VirtioDeviceType::Fs => "fs",
|
||||
VirtioDeviceType::Pmem => "pmem",
|
||||
VirtioDeviceType::Watchdog => "watchdog",
|
||||
VirtioDeviceType::Unknown => "UNKNOWN",
|
||||
};
|
||||
write!(f, "{}", output)
|
||||
}
|
||||
|
@ -3283,11 +3283,11 @@ impl DeviceManager {
|
||||
.device_type(),
|
||||
);
|
||||
match device_type {
|
||||
VirtioDeviceType::TYPE_NET
|
||||
| VirtioDeviceType::TYPE_BLOCK
|
||||
| VirtioDeviceType::TYPE_PMEM
|
||||
| VirtioDeviceType::TYPE_FS
|
||||
| VirtioDeviceType::TYPE_VSOCK => {}
|
||||
VirtioDeviceType::Net
|
||||
| VirtioDeviceType::Block
|
||||
| VirtioDeviceType::Pmem
|
||||
| VirtioDeviceType::Fs
|
||||
| VirtioDeviceType::Vsock => {}
|
||||
_ => return Err(DeviceManagerError::RemovalNotAllowed(device_type)),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user