Skip to content

Commit 25a972e

Browse files
slpjakecorrenti
authored andcommitted
vmm: drop use of rangemap crate
It's not packaged in Fedora and I don't think it adds enough value to justify its addition. Signed-off-by: Sergio Lopez <[email protected]>
1 parent d645ced commit 25a972e

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

Cargo.lock

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/vmm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ libc = ">=0.2.39"
2121
linux-loader = { version = "0.13.0", features = ["bzimage", "elf", "pe"] }
2222
log = "0.4.0"
2323
vm-memory = { version = ">=0.13", features = ["backend-mmap"] }
24-
rangemap = "1.5.1"
2524

2625
arch = { path = "../arch" }
2726
devices = { path = "../devices" }

src/vmm/src/linux/vstate.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use libc::{c_int, c_void, siginfo_t};
1010
use std::cell::Cell;
1111
use std::fmt::{Display, Formatter};
1212
use std::io;
13+
use std::ops::Range;
1314

1415
use std::os::unix::io::RawFd;
1516

@@ -57,8 +58,6 @@ use vm_memory::{
5758
GuestRegionMmap,
5859
};
5960

60-
use rangemap::RangeMap;
61-
6261
#[cfg(feature = "amd-sev")]
6362
use sev::launch::snp;
6463

@@ -457,7 +456,7 @@ pub struct Vm {
457456
#[cfg(feature = "amd-sev")]
458457
pub tee_config: Tee,
459458

460-
pub guest_memfds: RangeMap<u64, (RawFd, u64)>,
459+
pub guest_memfds: Vec<(Range<u64>, RawFd)>,
461460
}
462461

463462
impl Vm {
@@ -482,7 +481,7 @@ impl Vm {
482481
supported_cpuid,
483482
#[cfg(target_arch = "x86_64")]
484483
supported_msrs,
485-
guest_memfds: RangeMap::new(),
484+
guest_memfds: Vec::new(),
486485
})
487486
}
488487

@@ -521,7 +520,7 @@ impl Vm {
521520
supported_msrs,
522521
tee,
523522
tee_config: tee_config.tee,
524-
guest_memfds: RangeMap::new(),
523+
guest_memfds: Vec::new(),
525524
})
526525
}
527526

@@ -560,7 +559,12 @@ impl Vm {
560559
}
561560

562561
pub fn guest_memfd_get(&self, gpa: u64) -> Option<(RawFd, u64)> {
563-
self.guest_memfds.get(&gpa).copied()
562+
for (range, rawfd) in self.guest_memfds.iter() {
563+
if range.contains(&gpa) {
564+
return Some((*rawfd, range.start));
565+
}
566+
}
567+
None
564568
}
565569

566570
#[allow(unused_mut)]
@@ -631,7 +635,7 @@ impl Vm {
631635
.set_memory_attributes(attr)
632636
.map_err(Error::SetMemoryAttributes)?;
633637

634-
self.guest_memfds.insert(start..end, (guest_memfd, start));
638+
self.guest_memfds.push((Range { start, end }, guest_memfd));
635639
}
636640

637641
self.next_mem_slot += 1;

0 commit comments

Comments
 (0)