runtime-rs: remove all remaining unsafe impl

Fixes: #6307

Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
Tim Zhang 2023-02-20 14:08:14 +08:00
parent 0301194851
commit da8a6417aa
10 changed files with 10 additions and 28 deletions

View File

@ -534,9 +534,9 @@ dependencies = [
[[package]]
name = "crossbeam-channel"
version = "0.5.4"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53"
checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
@ -780,6 +780,7 @@ version = "0.1.0"
dependencies = [
"arc-swap",
"bytes 1.1.0",
"crossbeam-channel",
"dbs-address-space",
"dbs-allocator",
"dbs-arch",
@ -1256,6 +1257,7 @@ dependencies = [
"anyhow",
"async-trait",
"ch-config",
"crossbeam-channel",
"dbs-utils",
"dragonball",
"futures 0.3.26",

View File

@ -15,9 +15,6 @@ use tokio::{
use super::{ConnectConfig, Sock, Stream};
unsafe impl Send for HybridVsock {}
unsafe impl Sync for HybridVsock {}
#[derive(Debug, PartialEq)]
pub struct HybridVsock {
uds: String,

View File

@ -16,9 +16,6 @@ use tokio::net::UnixStream;
use super::{ConnectConfig, Sock, Stream};
unsafe impl Send for Vsock {}
unsafe impl Sync for Vsock {}
#[derive(Debug, PartialEq)]
pub struct Vsock {
vsock_cid: u32,

View File

@ -36,6 +36,7 @@ ch-config = { path = "ch-config", optional = true }
futures = "0.3.25"
safe-path = "0.1.0"
crossbeam-channel = "0.5.6"
[features]
default = []

View File

@ -53,9 +53,6 @@ pub struct CloudHypervisorInner {
pub(crate) tasks: Option<Vec<JoinHandle<Result<()>>>>,
}
unsafe impl Send for CloudHypervisorInner {}
unsafe impl Sync for CloudHypervisorInner {}
const CH_DEFAULT_TIMEOUT_SECS: u32 = 10;
impl CloudHypervisorInner {

View File

@ -33,9 +33,6 @@ pub struct CloudHypervisor {
inner: Arc<RwLock<CloudHypervisorInner>>,
}
unsafe impl Send for CloudHypervisor {}
unsafe impl Sync for CloudHypervisor {}
impl CloudHypervisor {
pub fn new() -> Self {
Self {

View File

@ -27,7 +27,6 @@ use std::{collections::HashSet, fs::create_dir_all, path::PathBuf};
const DRAGONBALL_KERNEL: &str = "vmlinux";
const DRAGONBALL_ROOT_FS: &str = "rootfs";
unsafe impl Sync for DragonballInner {}
pub struct DragonballInner {
/// sandbox id
pub(crate) id: String,

View File

@ -7,14 +7,12 @@
use std::{
fs::{File, OpenOptions},
os::unix::{io::IntoRawFd, prelude::AsRawFd},
sync::{
mpsc::{channel, Receiver, Sender},
Arc, Mutex, RwLock,
},
sync::{Arc, Mutex, RwLock},
thread,
};
use anyhow::{anyhow, Context, Result};
use crossbeam_channel::{unbounded, Receiver, Sender};
use dragonball::{
api::v1::{
BlockDeviceConfigInfo, BootSourceConfig, FsDeviceConfigInfo, FsMountConfigInfo,
@ -86,8 +84,8 @@ impl VmmInstance {
pub fn run_vmm_server(&mut self, id: &str, netns: Option<String>) -> Result<()> {
let kvm = OpenOptions::new().read(true).write(true).open(KVM_DEVICE)?;
let (to_vmm, from_runtime) = channel();
let (to_runtime, from_vmm) = channel();
let (to_vmm, from_runtime) = unbounded();
let (to_runtime, from_vmm) = unbounded();
self.set_instance_id(id);

View File

@ -12,9 +12,6 @@ const VSOCK_SCHEME: &str = "vsock";
const VSOCK_AGENT_CID: u32 = 3;
const VSOCK_AGENT_PORT: u32 = 1024;
unsafe impl Send for QemuInner {}
unsafe impl Sync for QemuInner {}
pub struct QemuInner {
config: HypervisorConfig,
}

View File

@ -17,12 +17,9 @@ pub enum Action {
Start,
Stop,
Shutdown,
Event(Arc<dyn Event>),
Event(Arc<dyn Event + Send + Sync>),
}
unsafe impl Send for Message {}
unsafe impl Sync for Message {}
#[derive(Debug)]
pub struct Message {
pub action: Action,