mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +00:00
virtio-devices: Move the 'rate_limiter' module to its own crate
To support I/O throttling on virt-net devices, we need to use the 'rate_limiter' module from the 'net_utils' crate. Given the 'virtio-devices' crate has dependency on the 'net_utils', we will need to move the 'rate_limiter' module out of the 'virtio-devices' crate to avoid circular dependency issue. Considering the 'rate_limiter' is not virtio specific and could be reused for non virtio devices, we move it to its own crate. Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
b8311cac38
commit
ee871278ee
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -831,6 +831,15 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rate_limiter"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"log 0.4.14",
|
||||||
|
"vmm-sys-util",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.1.57"
|
version = "0.1.57"
|
||||||
@ -1274,6 +1283,7 @@ dependencies = [
|
|||||||
"net_gen",
|
"net_gen",
|
||||||
"net_util",
|
"net_util",
|
||||||
"pci",
|
"pci",
|
||||||
|
"rate_limiter",
|
||||||
"seccomp",
|
"seccomp",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
|
@ -76,6 +76,7 @@ members = [
|
|||||||
"option_parser",
|
"option_parser",
|
||||||
"pci",
|
"pci",
|
||||||
"qcow",
|
"qcow",
|
||||||
|
"rate_limiter",
|
||||||
"vhost_user_backend",
|
"vhost_user_backend",
|
||||||
"vhost_user_block",
|
"vhost_user_block",
|
||||||
"vhost_user_net",
|
"vhost_user_net",
|
||||||
|
9
rate_limiter/Cargo.toml
Normal file
9
rate_limiter/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "rate_limiter"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
libc = "0.2.91"
|
||||||
|
log = "0.4.14"
|
||||||
|
vmm-sys-util = "0.8.0"
|
@ -43,6 +43,9 @@
|
|||||||
//! It is meant to be used in an external event loop and thus implements the `AsRawFd`
|
//! It is meant to be used in an external event loop and thus implements the `AsRawFd`
|
||||||
//! trait and provides an *event-handler* as part of its API. This *event-handler*
|
//! trait and provides an *event-handler* as part of its API. This *event-handler*
|
||||||
//! needs to be called by the user on every event on the rate limiter's `AsRawFd` FD.
|
//! needs to be called by the user on every event on the rate limiter's `AsRawFd` FD.
|
||||||
|
#[macro_use]
|
||||||
|
extern crate log;
|
||||||
|
|
||||||
use std::os::unix::io::{AsRawFd, RawFd};
|
use std::os::unix::io::{AsRawFd, RawFd};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use std::{fmt, io};
|
use std::{fmt, io};
|
@ -21,6 +21,7 @@ log = "0.4.14"
|
|||||||
net_gen = { path = "../net_gen" }
|
net_gen = { path = "../net_gen" }
|
||||||
net_util = { path = "../net_util" }
|
net_util = { path = "../net_util" }
|
||||||
pci = { path = "../pci" }
|
pci = { path = "../pci" }
|
||||||
|
rate_limiter = { path = "../rate_limiter" }
|
||||||
seccomp = { git = "https://github.com/firecracker-microvm/firecracker", tag = "v0.22.0" }
|
seccomp = { git = "https://github.com/firecracker-microvm/firecracker", tag = "v0.22.0" }
|
||||||
serde = ">=1.0.27"
|
serde = ">=1.0.27"
|
||||||
serde_derive = ">=1.0.27"
|
serde_derive = ">=1.0.27"
|
||||||
|
@ -14,7 +14,6 @@ use super::{
|
|||||||
RateLimiterConfig, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterruptType,
|
RateLimiterConfig, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterruptType,
|
||||||
EPOLL_HELPER_EVENT_LAST,
|
EPOLL_HELPER_EVENT_LAST,
|
||||||
};
|
};
|
||||||
use crate::rate_limiter::{RateLimiter, TokenType};
|
|
||||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||||
use crate::VirtioInterrupt;
|
use crate::VirtioInterrupt;
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
@ -22,6 +21,7 @@ use block_util::{
|
|||||||
async_io::AsyncIo, async_io::AsyncIoError, async_io::DiskFile, build_disk_image_id, Request,
|
async_io::AsyncIo, async_io::AsyncIoError, async_io::DiskFile, build_disk_image_id, Request,
|
||||||
RequestType, VirtioBlockConfig,
|
RequestType, VirtioBlockConfig,
|
||||||
};
|
};
|
||||||
|
use rate_limiter::{RateLimiter, TokenType};
|
||||||
use seccomp::{SeccompAction, SeccompFilter};
|
use seccomp::{SeccompAction, SeccompFilter};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::num::Wrapping;
|
use std::num::Wrapping;
|
||||||
|
@ -40,7 +40,6 @@ pub mod mem;
|
|||||||
pub mod net;
|
pub mod net;
|
||||||
pub mod net_util;
|
pub mod net_util;
|
||||||
mod pmem;
|
mod pmem;
|
||||||
mod rate_limiter;
|
|
||||||
mod rng;
|
mod rng;
|
||||||
pub mod seccomp_filters;
|
pub mod seccomp_filters;
|
||||||
pub mod transport;
|
pub mod transport;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user