vmm: Move codebase to GuestMemoryAtomic from vm-memory

Relying on the latest vm-memory version, including the freshly
introduced structure GuestMemoryAtomic, this patch replaces every
occurrence of Arc<ArcSwap<GuestMemoryMmap> with
GuestMemoryAtomic<GuestMemoryMmap>.

The point is to rely on the common RCU-like implementation from
vm-memory so that we don't have to do it from Cloud-Hypervisor.

Fixes #735

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-02-11 17:22:40 +01:00
committed by Rob Bradford
parent ddf6caf955
commit 793d4e7b8d
23 changed files with 116 additions and 147 deletions

View File

@@ -4,7 +4,6 @@
use super::Error as DeviceError;
use super::{DescriptorChain, DeviceEventT, Queue};
use arc_swap::ArcSwap;
use net_util::{MacAddr, Tap, TapError};
use std::cmp;
use std::fs;
@@ -15,7 +14,10 @@ use std::os::unix::io::{AsRawFd, RawFd};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use virtio_bindings::bindings::virtio_net::*;
use vm_memory::{ByteValued, Bytes, GuestAddress, GuestMemoryError, GuestMemoryMmap};
use vm_memory::{
ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryError,
GuestMemoryMmap,
};
use vmm_sys_util::eventfd::EventFd;
type Result<T> = std::result::Result<T, Error>;
@@ -202,7 +204,7 @@ pub fn unregister_listener(
}
pub struct NetCtrlEpollHandler {
pub mem: Arc<ArcSwap<GuestMemoryMmap>>,
pub mem: GuestMemoryAtomic<GuestMemoryMmap>,
pub kill_evt: EventFd,
pub pause_evt: EventFd,
pub ctrl_q: CtrlVirtio,
@@ -254,7 +256,7 @@ impl NetCtrlEpollHandler {
match ev_type {
CTRL_QUEUE_EVENT => {
let mem = self.mem.load();
let mem = self.mem.memory();
if let Err(e) = self.ctrl_q.queue_evt.read() {
error!("failed to get ctl queue event: {:?}", e);
}