Skip to content

Commit 90d3c01

Browse files
Jonathan Woollett-LightJonathanWoollett-Light
authored andcommitted
build: Update to Rust 1.70.0
Update the Rust version to 1.70.0 and fix new `ambiguous_glob_reexports` warnings. Signed-off-by: Jonathan Woollett-Light <[email protected]>
1 parent 22ef8b3 commit 90d3c01

File tree

34 files changed

+257
-307
lines changed

34 files changed

+257
-307
lines changed

src/vmm/src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub enum StartMicrovmError {
7171
CreateGuestConfig(#[from] GuestConfigError),
7272
/// Internal errors are due to resource exhaustion.
7373
#[error("Cannot create network device. {}", format!("{:?}", .0).replace('\"', ""))]
74-
CreateNetDevice(crate::devices::virtio::net::Error),
74+
CreateNetDevice(crate::devices::virtio::net::NetError),
7575
/// Failed to create a `RateLimiter` object.
7676
#[error("Cannot create RateLimiter: {0}")]
7777
CreateRateLimiter(io::Error),
@@ -1688,7 +1688,7 @@ pub mod tests {
16881688
let err = AttachBlockDevice(io::Error::from_raw_os_error(0));
16891689
let _ = format!("{}{:?}", err, err);
16901690

1691-
let err = CreateNetDevice(crate::devices::virtio::net::Error::EventFd(
1691+
let err = CreateNetDevice(crate::devices::virtio::net::NetError::EventFd(
16921692
io::Error::from_raw_os_error(0),
16931693
));
16941694
let _ = format!("{}{:?}", err, err);

src/vmm/src/device_manager/persist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use super::mmio::*;
2020
#[cfg(target_arch = "aarch64")]
2121
use crate::arch::DeviceType;
2222
use crate::devices::virtio::balloon::persist::{BalloonConstructorArgs, BalloonState};
23-
use crate::devices::virtio::balloon::{Balloon, Error as BalloonError};
23+
use crate::devices::virtio::balloon::{Balloon, BalloonError};
2424
use crate::devices::virtio::block::persist::{BlockConstructorArgs, BlockState};
25-
use crate::devices::virtio::block::{Block, Error as BlockError};
25+
use crate::devices::virtio::block::{Block, BlockError};
2626
use crate::devices::virtio::net::persist::{Error as NetError, NetConstructorArgs, NetState};
2727
use crate::devices::virtio::net::Net;
2828
use crate::devices::virtio::persist::{MmioTransportConstructorArgs, MmioTransportState};

src/vmm/src/devices/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(crate) fn report_net_event_fail(err: Error) {
2323
METRICS.net.event_fails.inc();
2424
}
2525

26-
pub(crate) fn report_balloon_event_fail(err: virtio::balloon::Error) {
26+
pub(crate) fn report_balloon_event_fail(err: virtio::balloon::BalloonError) {
2727
error!("{:?}", err);
2828
METRICS.balloon.event_fails.inc();
2929
}

src/vmm/src/devices/virtio/balloon/device.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ use virtio_gen::virtio_blk::VIRTIO_F_VERSION_1;
1818
use super::super::{ActivateResult, DeviceState, Queue, VirtioDevice, TYPE_BALLOON};
1919
use super::util::{compact_page_frame_numbers, remove_range};
2020
use super::{
21-
BALLOON_DEV_ID, DEFLATE_INDEX, INFLATE_INDEX, MAX_PAGES_IN_DESC, MAX_PAGE_COMPACT_BUFFER,
22-
MIB_TO_4K_PAGES, NUM_QUEUES, QUEUE_SIZES, STATS_INDEX, VIRTIO_BALLOON_F_DEFLATE_ON_OOM,
23-
VIRTIO_BALLOON_F_STATS_VQ, VIRTIO_BALLOON_PFN_SHIFT, VIRTIO_BALLOON_S_AVAIL,
24-
VIRTIO_BALLOON_S_CACHES, VIRTIO_BALLOON_S_HTLB_PGALLOC, VIRTIO_BALLOON_S_HTLB_PGFAIL,
25-
VIRTIO_BALLOON_S_MAJFLT, VIRTIO_BALLOON_S_MEMFREE, VIRTIO_BALLOON_S_MEMTOT,
26-
VIRTIO_BALLOON_S_MINFLT, VIRTIO_BALLOON_S_SWAP_IN, VIRTIO_BALLOON_S_SWAP_OUT,
21+
BALLOON_DEV_ID, BALLOON_NUM_QUEUES, BALLOON_QUEUE_SIZES, DEFLATE_INDEX, INFLATE_INDEX,
22+
MAX_PAGES_IN_DESC, MAX_PAGE_COMPACT_BUFFER, MIB_TO_4K_PAGES, STATS_INDEX,
23+
VIRTIO_BALLOON_F_DEFLATE_ON_OOM, VIRTIO_BALLOON_F_STATS_VQ, VIRTIO_BALLOON_PFN_SHIFT,
24+
VIRTIO_BALLOON_S_AVAIL, VIRTIO_BALLOON_S_CACHES, VIRTIO_BALLOON_S_HTLB_PGALLOC,
25+
VIRTIO_BALLOON_S_HTLB_PGFAIL, VIRTIO_BALLOON_S_MAJFLT, VIRTIO_BALLOON_S_MEMFREE,
26+
VIRTIO_BALLOON_S_MEMTOT, VIRTIO_BALLOON_S_MINFLT, VIRTIO_BALLOON_S_SWAP_IN,
27+
VIRTIO_BALLOON_S_SWAP_OUT,
2728
};
28-
use crate::devices::virtio::balloon::Error as BalloonError;
29+
use crate::devices::virtio::balloon::BalloonError;
2930
use crate::devices::virtio::{IrqTrigger, IrqType};
3031

3132
const SIZE_OF_U32: usize = std::mem::size_of::<u32>();
@@ -134,7 +135,7 @@ pub struct Balloon {
134135

135136
// Transport related fields.
136137
pub(crate) queues: Vec<Queue>,
137-
pub(crate) queue_evts: [EventFd; NUM_QUEUES],
138+
pub(crate) queue_evts: [EventFd; BALLOON_NUM_QUEUES],
138139
pub(crate) device_state: DeviceState,
139140
pub(crate) irq_trigger: IrqTrigger,
140141

@@ -173,7 +174,7 @@ impl Balloon {
173174
EventFd::new(libc::EFD_NONBLOCK).map_err(BalloonError::EventFd)?,
174175
];
175176

176-
let mut queues: Vec<Queue> = QUEUE_SIZES.iter().map(|&s| Queue::new(s)).collect();
177+
let mut queues: Vec<Queue> = BALLOON_QUEUE_SIZES.iter().map(|&s| Queue::new(s)).collect();
177178

178179
// The VirtIO specification states that the statistics queue should
179180
// not be present at all if the statistics are not enabled.
@@ -589,7 +590,7 @@ pub(crate) mod tests {
589590

590591
use utils::vm_memory::GuestAddress;
591592

592-
use super::super::CONFIG_SPACE_SIZE;
593+
use super::super::BALLOON_CONFIG_SPACE_SIZE;
593594
use super::*;
594595
use crate::check_metric_after_block;
595596
use crate::devices::report_balloon_event_fail;
@@ -716,21 +717,24 @@ pub(crate) mod tests {
716717
};
717718
assert_eq!(balloon.config(), cfg);
718719

719-
let mut actual_config_space = [0u8; CONFIG_SPACE_SIZE];
720+
let mut actual_config_space = [0u8; BALLOON_CONFIG_SPACE_SIZE];
720721
balloon.read_config(0, &mut actual_config_space);
721722
// The first 4 bytes are num_pages, the last 4 bytes are actual_pages.
722723
// The config space is little endian.
723724
// 0x10 MB in the constructor corresponds to 0x1000 pages in the
724725
// config space.
725-
let expected_config_space: [u8; CONFIG_SPACE_SIZE] =
726+
let expected_config_space: [u8; BALLOON_CONFIG_SPACE_SIZE] =
726727
[0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
727728
assert_eq!(actual_config_space, expected_config_space);
728729

729730
// Invalid read.
730-
let expected_config_space: [u8; CONFIG_SPACE_SIZE] =
731+
let expected_config_space: [u8; BALLOON_CONFIG_SPACE_SIZE] =
731732
[0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf];
732733
actual_config_space = expected_config_space;
733-
balloon.read_config(CONFIG_SPACE_SIZE as u64 + 1, &mut actual_config_space);
734+
balloon.read_config(
735+
BALLOON_CONFIG_SPACE_SIZE as u64 + 1,
736+
&mut actual_config_space,
737+
);
734738

735739
// Validate read failed (the config space was not updated).
736740
assert_eq!(actual_config_space, expected_config_space);
@@ -740,11 +744,11 @@ pub(crate) mod tests {
740744
fn test_virtio_write_config() {
741745
let mut balloon = Balloon::new(0, true, 0, false).unwrap();
742746

743-
let expected_config_space: [u8; CONFIG_SPACE_SIZE] =
747+
let expected_config_space: [u8; BALLOON_CONFIG_SPACE_SIZE] =
744748
[0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
745749
balloon.write_config(0, &expected_config_space);
746750

747-
let mut actual_config_space = [0u8; CONFIG_SPACE_SIZE];
751+
let mut actual_config_space = [0u8; BALLOON_CONFIG_SPACE_SIZE];
748752
balloon.read_config(0, &mut actual_config_space);
749753
assert_eq!(actual_config_space, expected_config_space);
750754

@@ -1043,7 +1047,7 @@ pub(crate) mod tests {
10431047
assert_eq!(balloon.num_pages(), 0x100);
10441048
assert!(balloon.update_size(16).is_ok());
10451049

1046-
let mut actual_config = vec![0; CONFIG_SPACE_SIZE];
1050+
let mut actual_config = vec![0; BALLOON_CONFIG_SPACE_SIZE];
10471051
balloon.read_config(0, &mut actual_config);
10481052
assert_eq!(actual_config, vec![0x0, 0x10, 0x0, 0x0, 0x34, 0x12, 0, 0]);
10491053
assert_eq!(balloon.num_pages(), 0x1000);

src/vmm/src/devices/virtio/balloon/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
pub mod device;
5-
pub mod event_handler;
5+
mod event_handler;
66
pub mod persist;
77
pub mod test_utils;
88
mod util;
99

1010
use utils::vm_memory::GuestMemoryError;
1111

1212
pub use self::device::{Balloon, BalloonConfig, BalloonStats};
13-
pub use self::event_handler::*;
1413

1514
/// Device ID used in MMIO device identification.
1615
/// Because Balloon is unique per-vm, this ID can be hardcoded.
1716
pub const BALLOON_DEV_ID: &str = "balloon";
18-
pub const CONFIG_SPACE_SIZE: usize = 8;
19-
pub const QUEUE_SIZE: u16 = 256;
20-
pub const NUM_QUEUES: usize = 3;
21-
pub const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE, QUEUE_SIZE, QUEUE_SIZE];
17+
pub const BALLOON_CONFIG_SPACE_SIZE: usize = 8;
18+
pub const BALLOON_QUEUE_SIZE: u16 = 256;
19+
pub const BALLOON_NUM_QUEUES: usize = 3;
20+
pub const BALLOON_QUEUE_SIZES: [u16; BALLOON_NUM_QUEUES] =
21+
[BALLOON_QUEUE_SIZE, BALLOON_QUEUE_SIZE, BALLOON_QUEUE_SIZE];
2222
// Number of 4K pages in a MiB.
2323
pub const MIB_TO_4K_PAGES: u32 = 256;
2424
// The maximum number of pages that can be received in a single descriptor.
@@ -52,7 +52,7 @@ const VIRTIO_BALLOON_S_HTLB_PGALLOC: u16 = 8;
5252
const VIRTIO_BALLOON_S_HTLB_PGFAIL: u16 = 9;
5353

5454
#[derive(Debug)]
55-
pub enum Error {
55+
pub enum BalloonError {
5656
/// Activation error.
5757
Activate(super::ActivateError),
5858
/// No balloon device found.
@@ -94,4 +94,4 @@ pub enum RemoveRegionError {
9494
RegionNotFound,
9595
}
9696

97-
pub type Result<T> = std::result::Result<T, Error>;
97+
pub type BalloonResult<T> = std::result::Result<T, BalloonError>;

src/vmm/src/devices/virtio/balloon/persist.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub struct BalloonConstructorArgs {
9393
impl Persist<'_> for Balloon {
9494
type State = BalloonState;
9595
type ConstructorArgs = BalloonConstructorArgs;
96-
type Error = super::Error;
96+
type Error = super::BalloonError;
9797

9898
fn save(&self) -> Self::State {
9999
BalloonState {
@@ -116,15 +116,20 @@ impl Persist<'_> for Balloon {
116116
// num_pages because we will overwrite them after.
117117
let mut balloon = Balloon::new(0, false, state.stats_polling_interval_s, true)?;
118118

119-
let mut num_queues = NUM_QUEUES;
119+
let mut num_queues = BALLOON_NUM_QUEUES;
120120
// As per the virtio 1.1 specification, the statistics queue
121121
// should not exist if the statistics are not enabled.
122122
if state.stats_polling_interval_s == 0 {
123123
num_queues -= 1;
124124
}
125125
balloon.queues = state
126126
.virtio_state
127-
.build_queues_checked(&constructor_args.mem, TYPE_BALLOON, num_queues, QUEUE_SIZE)
127+
.build_queues_checked(
128+
&constructor_args.mem,
129+
TYPE_BALLOON,
130+
num_queues,
131+
BALLOON_QUEUE_SIZE,
132+
)
128133
.map_err(|_| Self::Error::QueueRestoreError)?;
129134
balloon.irq_trigger.irq_status =
130135
Arc::new(AtomicUsize::new(state.virtio_state.interrupt_status));

src/vmm/src/devices/virtio/balloon/test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ use std::u32;
88
use crate::devices::virtio::test_utils::VirtQueue;
99
#[cfg(test)]
1010
use crate::devices::virtio::{
11-
balloon::NUM_QUEUES, Balloon, IrqType, DEFLATE_INDEX, INFLATE_INDEX, STATS_INDEX,
11+
balloon::BALLOON_NUM_QUEUES, Balloon, IrqType, DEFLATE_INDEX, INFLATE_INDEX, STATS_INDEX,
1212
};
1313

1414
#[cfg(test)]
1515
pub fn invoke_handler_for_queue_event(b: &mut Balloon, queue_index: usize) {
16-
assert!(queue_index < NUM_QUEUES);
16+
assert!(queue_index < BALLOON_NUM_QUEUES);
1717
// Trigger the queue event.
1818
b.queue_evts[queue_index].write(1).unwrap();
1919
// Handle event.

0 commit comments

Comments
 (0)