Reland "Reland "balloon: rename WSS to WS""
This reverts commit 2aea504a65dd37dba0e8060b1c38bdf08d0ee680.
Reason for revert: missed run-time flag migration, fixed this time around and tested more thoroughly
BUG=b/288432539
TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools
TEST=cros deploy && restart vm_concierge on DUT
TEST=cros deploy && vmc start borealis && (borealis) DISPLAY=:0 steam
Original change's description:
> Revert "Reland "balloon: rename WSS to WS""
>
> This reverts commit cf1c3cd755474e61a36bf394193ce084d0df0bdd.
>
> Reason for revert: The command line change will break existing
> usage of the CLI flag
>
> Original change's description:
> > Reland "balloon: rename WSS to WS"
> >
> > This reverts commit 94dc10b57cfb142e7996d17a66e2e29a824f0d9d.
> >
> > Reason for revert: relanding changes with fully implemented types
> >
> > BUG=b/288432539
> > TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> > TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools
> >
> > Original change's description:
> > > Revert "balloon: rename WSS to WS"
> > >
> > > This reverts commit 1eb1106537ed005aac1fea9c57b5e2893058c005.
> > >
> > > Reason for revert: headers generated by cbindgen do not compile as expected downstream
> > >
> > > Original change's description:
> > > > balloon: rename WSS to WS
> > > >
> > > > as the working set feature approaches acceptance at the spec-level, we
> > > > are keeping up with nomenclature changes.
> > > >
> > > > BUG=b/288432539
> > > > TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> > > >
> > > > Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
> > > > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
> > > > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> > > > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > >
> > > BUG=b/288432539
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > >
> > > Change-Id: I46459b4afd428c67436a754b3e62a104a680c68f
> > > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722468
> > > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> >
> > BUG=b/288432539
> >
> > Change-Id: Ifb78acf2914b96306a2d1104e21eff6e67ed45df
> > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722288
> > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
>
> BUG=b/288432539
>
> Change-Id: I3bcb26699fd1d15eab594143490f863941d3eceb
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4730438
> Commit-Queue: Dennis Kempin <denniskempin@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
BUG=b/288432539
Change-Id: I657f648aec0fc4f4551cf3c109c5ecedcdddbcb2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4733877
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
diff --git a/common/balloon_control/src/lib.rs b/common/balloon_control/src/lib.rs
index 8187404..0b70e37 100644
--- a/common/balloon_control/src/lib.rs
+++ b/common/balloon_control/src/lib.rs
@@ -23,10 +23,10 @@
},
// Fetch balloon stats.
Stats,
- // Fetch balloon wss.
- WorkingSetSize,
- // Send balloon wss config to guest.
- WorkingSetSizeConfig {
+ // Fetch balloon ws.
+ WorkingSet,
+ // Send balloon ws config to guest.
+ WorkingSetConfig {
bins: Vec<u64>,
refresh_threshold: u64,
report_threshold: u64,
@@ -53,23 +53,23 @@
pub const VIRTIO_BALLOON_WS_MIN_NUM_BINS: usize = 2;
pub const VIRTIO_BALLOON_WS_MAX_NUM_BINS: usize = 16;
-// WSSBucket stores information about a bucket (or bin) of the working set size.
+// WSBucket stores information about a bucket (or bin) of the working set.
#[derive(Default, Serialize, Deserialize, Debug, Clone, Copy)]
-pub struct WSSBucket {
+pub struct WSBucket {
pub age: u64,
pub bytes: [u64; 2],
}
-// BalloonWSS holds WSS returned from the wss_queue.
+// BalloonWS holds WS returned from the ws_queue.
#[derive(Default, Serialize, Deserialize, Debug, Clone)]
-pub struct BalloonWSS {
- /// working set size, separated per histogram bucket.
- pub wss: Vec<WSSBucket>,
+pub struct BalloonWS {
+ /// working set, separated per histogram bucket.
+ pub ws: Vec<WSBucket>,
}
-impl BalloonWSS {
+impl BalloonWS {
pub fn new() -> Self {
- BalloonWSS { wss: vec![] }
+ BalloonWS { ws: vec![] }
}
}
@@ -83,8 +83,8 @@
Adjusted {
num_bytes: u64,
},
- WorkingSetSize {
- wss: BalloonWSS,
+ WorkingSet {
+ ws: BalloonWS,
/// size of the balloon in bytes.
balloon_actual: u64,
},
diff --git a/crosvm_control/src/lib.rs b/crosvm_control/src/lib.rs
index a6e4524..3f6c745 100644
--- a/crosvm_control/src/lib.rs
+++ b/crosvm_control/src/lib.rs
@@ -28,7 +28,7 @@
use vm_control::client::*;
use vm_control::BalloonControlCommand;
use vm_control::BalloonStats;
-use vm_control::BalloonWSS;
+use vm_control::BalloonWS;
use vm_control::DiskControlCommand;
#[cfg(feature = "registered_events")]
use vm_control::RegisteredEvent;
@@ -36,7 +36,7 @@
use vm_control::UsbControlResult;
use vm_control::VmRequest;
use vm_control::VmResponse;
-use vm_control::WSSBucket;
+use vm_control::WSBucket;
use vm_control::USB_CONTROL_MAX_PORTS;
pub const VIRTIO_BALLOON_WS_MAX_NUM_BINS: usize = 16;
@@ -658,7 +658,33 @@
.unwrap_or(false)
}
-/// Externally exposed variant of BalloonWss/WSSBucket, used for FFI.
+/// Externally exposed variant of BalloonWS/WSBucket, used for FFI.
+#[derive(Clone, Copy, Debug)]
+#[repr(C)]
+pub struct WorkingSetBucketFfi {
+ age: u64,
+ bytes: [u64; 2],
+}
+
+impl WorkingSetBucketFfi {
+ fn new() -> Self {
+ Self {
+ age: 0,
+ bytes: [0, 0],
+ }
+ }
+}
+
+impl From<WSBucket> for WorkingSetBucketFfi {
+ fn from(other: WSBucket) -> Self {
+ Self {
+ age: other.age,
+ bytes: other.bytes,
+ }
+ }
+}
+
+// TODO(b/288432539): remove once concierge is migrated
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct WSSBucketFfi {
@@ -675,8 +701,8 @@
}
}
-impl From<WSSBucket> for WSSBucketFfi {
- fn from(other: WSSBucket) -> Self {
+impl From<WSBucket> for WSSBucketFfi {
+ fn from(other: WSBucket) -> Self {
Self {
age: other.age,
bytes: other.bytes,
@@ -684,6 +710,70 @@
}
}
+impl From<WorkingSetBucketFfi> for WSSBucketFfi {
+ fn from(value: WorkingSetBucketFfi) -> Self {
+ WSSBucketFfi {
+ age: value.age,
+ bytes: value.bytes,
+ }
+ }
+}
+
+impl From<WSSBucketFfi> for WorkingSetBucketFfi {
+ fn from(value: WSSBucketFfi) -> Self {
+ WorkingSetBucketFfi {
+ age: value.age,
+ bytes: value.bytes,
+ }
+ }
+}
+// ^ */ TODO(b/288432539): remove once concierge is migrated
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct BalloonWSFfi {
+ ws: [WorkingSetBucketFfi; VIRTIO_BALLOON_WS_MAX_NUM_BINS],
+ num_bins: u8,
+ _reserved: [u8; 7],
+}
+
+impl TryFrom<&BalloonWS> for BalloonWSFfi {
+ type Error = &'static str;
+
+ fn try_from(value: &BalloonWS) -> Result<Self, Self::Error> {
+ if value.ws.len() > VIRTIO_BALLOON_WS_MAX_NUM_BINS {
+ return Err("too many WS buckets in source object.");
+ }
+
+ let mut ffi = Self {
+ ws: [WorkingSetBucketFfi::new(); VIRTIO_BALLOON_WS_MAX_NUM_BINS],
+ num_bins: value.ws.len() as u8,
+ ..Default::default()
+ };
+ for (ffi_ws, other_ws) in ffi.ws.iter_mut().zip(value.ws.iter()) {
+ *ffi_ws = (*other_ws).into();
+ }
+ Ok(ffi)
+ }
+}
+
+impl BalloonWSFfi {
+ pub fn new() -> Self {
+ Self {
+ ws: [WorkingSetBucketFfi::new(); VIRTIO_BALLOON_WS_MAX_NUM_BINS],
+ num_bins: 0,
+ _reserved: [0; 7],
+ }
+ }
+}
+
+impl Default for BalloonWSFfi {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+// TODO(b/288432539): remove once concierge is migrated
#[repr(C)]
#[derive(Debug)]
pub struct BalloonWSSFfi {
@@ -692,20 +782,54 @@
_reserved: [u8; 7],
}
-impl TryFrom<&BalloonWSS> for BalloonWSSFfi {
+impl From<&mut BalloonWSSFfi> for BalloonWSFfi {
+ fn from(value: &mut BalloonWSSFfi) -> Self {
+ let mut ws = [WorkingSetBucketFfi {
+ age: 0,
+ bytes: [0; 2],
+ }; VIRTIO_BALLOON_WS_MAX_NUM_BINS];
+ for (idx, &bucket) in value.wss.iter().enumerate() {
+ ws[idx] = bucket.into();
+ }
+ BalloonWSFfi {
+ ws,
+ num_bins: value.num_bins,
+ _reserved: value._reserved,
+ }
+ }
+}
+
+impl From<BalloonWSFfi> for BalloonWSSFfi {
+ fn from(value: BalloonWSFfi) -> Self {
+ let mut wss = [WSSBucketFfi {
+ age: 0,
+ bytes: [0; 2],
+ }; VIRTIO_BALLOON_WS_MAX_NUM_BINS];
+ for (idx, &bucket) in value.ws.iter().enumerate() {
+ wss[idx] = bucket.into();
+ }
+ BalloonWSSFfi {
+ wss,
+ num_bins: value.num_bins,
+ _reserved: value._reserved,
+ }
+ }
+}
+
+impl TryFrom<&BalloonWS> for BalloonWSSFfi {
type Error = &'static str;
- fn try_from(value: &BalloonWSS) -> Result<Self, Self::Error> {
- if value.wss.len() > VIRTIO_BALLOON_WS_MAX_NUM_BINS {
- return Err("too many WSS buckets in source object.");
+ fn try_from(value: &BalloonWS) -> Result<Self, Self::Error> {
+ if value.ws.len() > VIRTIO_BALLOON_WS_MAX_NUM_BINS {
+ return Err("too many WS buckets in source object.");
}
let mut ffi = Self {
wss: [WSSBucketFfi::new(); VIRTIO_BALLOON_WS_MAX_NUM_BINS],
- num_bins: value.wss.len() as u8,
+ num_bins: value.ws.len() as u8,
..Default::default()
};
- for (ffi_wss, other_wss) in ffi.wss.iter_mut().zip(value.wss.iter()) {
+ for (ffi_wss, other_wss) in ffi.wss.iter_mut().zip(value.ws.iter()) {
*ffi_wss = (*other_wss).into();
}
Ok(ffi)
@@ -727,8 +851,19 @@
Self::new()
}
}
+// ^ */ TODO(b/288432539): remove once concierge is migrated
#[repr(C)]
+pub struct BalloonWSRConfigFfi {
+ intervals: [u64; VIRTIO_BALLOON_WS_MAX_NUM_INTERVALS],
+ num_intervals: u8,
+ _reserved: [u8; 7],
+ refresh_threshold: u64,
+ report_threshold: u64,
+}
+
+// TODO(b/288432539): remove once concierge is migrated
+#[repr(C)]
pub struct BalloonWssConfigFfi {
intervals: [u64; VIRTIO_BALLOON_WS_MAX_NUM_INTERVALS],
num_intervals: u8,
@@ -737,7 +872,40 @@
report_threshold: u64,
}
-/// Returns balloon working set size of the crosvm instance whose control socket is listening on socket_path.
+impl From<&BalloonWssConfigFfi> for BalloonWSRConfigFfi {
+ fn from(value: &BalloonWssConfigFfi) -> Self {
+ BalloonWSRConfigFfi {
+ intervals: value.intervals,
+ num_intervals: value.num_intervals,
+ _reserved: value._reserved,
+ refresh_threshold: value.refresh_threshold,
+ report_threshold: value.report_threshold,
+ }
+ }
+}
+// ^ */ TODO(b/288432539): remove once concierge is migrated
+
+// TODO(b/288432539): remove once concierge is migrated
+#[no_mangle]
+pub unsafe extern "C" fn crosvm_client_balloon_wss(
+ socket_path: *const c_char,
+ wss: *mut BalloonWSSFfi,
+ actual: *mut u64,
+) -> bool {
+ if wss.is_null() {
+ return false;
+ }
+ let ret;
+ unsafe {
+ let mut ws: BalloonWSFfi = (&mut *wss).into();
+ ret = crosvm_client_balloon_working_set(socket_path, &mut ws, actual);
+ *wss = ws.into();
+ }
+ ret
+}
+// ^ */ TODO(b/288432539): remove once concierge is migrated
+
+/// Returns balloon working set of the crosvm instance whose control socket is listening on socket_path.
///
/// The function returns true on success or false if an error occured.
///
@@ -747,23 +915,23 @@
/// !raw_pointer.is_null() checks should prevent unsafe behavior but the caller should ensure no
/// null pointers are passed.
#[no_mangle]
-pub unsafe extern "C" fn crosvm_client_balloon_wss(
+pub unsafe extern "C" fn crosvm_client_balloon_working_set(
socket_path: *const c_char,
- wss: *mut BalloonWSSFfi,
+ ws: *mut BalloonWSFfi,
actual: *mut u64,
) -> bool {
catch_unwind(|| {
if let Some(socket_path) = validate_socket_path(socket_path) {
- let request = &VmRequest::BalloonCommand(BalloonControlCommand::WorkingSetSize);
- if let Ok(VmResponse::BalloonWSS {
- wss: ref balloon_wss,
+ let request = &VmRequest::BalloonCommand(BalloonControlCommand::WorkingSet);
+ if let Ok(VmResponse::BalloonWS {
+ ws: ref balloon_ws,
balloon_actual,
}) = handle_request(request, socket_path)
{
- if !wss.is_null() {
- // SAFETY: just checked that `wss` is not null.
+ if !ws.is_null() {
+ // SAFETY: just checked that `ws` is not null.
unsafe {
- *wss = match balloon_wss.try_into() {
+ *ws = match balloon_ws.try_into() {
Ok(result) => result,
Err(_) => return false,
};
@@ -795,7 +963,7 @@
pub struct RegisteredEventFfi(u32);
#[cfg(feature = "registered_events")]
-pub const REGISTERED_EVENT_VIRTIO_BALLOON_WSS_REPORT: RegisteredEventFfi = RegisteredEventFfi(0);
+pub const REGISTERED_EVENT_VIRTIO_BALLOON_WS_REPORT: RegisteredEventFfi = RegisteredEventFfi(0);
#[cfg(feature = "registered_events")]
pub const REGISTERED_EVENT_VIRTIO_BALLOON_RESIZE: RegisteredEventFfi = RegisteredEventFfi(1);
#[cfg(feature = "registered_events")]
@@ -807,7 +975,7 @@
fn try_from(value: RegisteredEventFfi) -> Result<Self, Self::Error> {
match value.0 {
- 0 => Ok(RegisteredEvent::VirtioBalloonWssReport),
+ 0 => Ok(RegisteredEvent::VirtioBalloonWsReport),
1 => Ok(RegisteredEvent::VirtioBalloonResize),
2 => Ok(RegisteredEvent::VirtioBalloonOOMDeflation),
_ => Err("RegisteredEventFFi outside of known RegisteredEvent enum range"),
@@ -923,7 +1091,25 @@
.unwrap_or(false)
}
-/// Set Working Set Size config in guest.
+// TODO(b/288432539): remove once concierge is migrated
+#[no_mangle]
+pub unsafe extern "C" fn crosvm_client_balloon_wss_config(
+ socket_path: *const c_char,
+ config: *const BalloonWssConfigFfi,
+) -> bool {
+ if config.is_null() {
+ return false;
+ }
+ let ret;
+ unsafe {
+ let wsr_config = (&*config).into();
+ ret = crosvm_client_balloon_wsr_config(socket_path, &wsr_config);
+ }
+ ret
+}
+// ^ TODO(b/288432539): remove once concierge is migrated
+
+/// Set Working Set Reporting config in guest.
///
/// The function returns true on success or false if an error occured.
///
@@ -933,9 +1119,9 @@
/// !raw_pointer.is_null() checks should prevent unsafe behavior but the caller should ensure no
/// null pointers are passed.
#[no_mangle]
-pub unsafe extern "C" fn crosvm_client_balloon_wss_config(
+pub unsafe extern "C" fn crosvm_client_balloon_wsr_config(
socket_path: *const c_char,
- config: *const BalloonWssConfigFfi,
+ config: *const BalloonWSRConfigFfi,
) -> bool {
catch_unwind(|| {
if let Some(socket_path) = validate_socket_path(socket_path) {
@@ -950,7 +1136,7 @@
actual_bins.push((*config).intervals[idx as usize]);
}
let request =
- VmRequest::BalloonCommand(BalloonControlCommand::WorkingSetSizeConfig {
+ VmRequest::BalloonCommand(BalloonControlCommand::WorkingSetConfig {
bins: actual_bins,
refresh_threshold: (*config).refresh_threshold,
report_threshold: (*config).report_threshold,
diff --git a/devices/src/virtio/balloon.rs b/devices/src/virtio/balloon.rs
index d7fd045..a28301d 100644
--- a/devices/src/virtio/balloon.rs
+++ b/devices/src/virtio/balloon.rs
@@ -14,8 +14,8 @@
use balloon_control::BalloonStats;
use balloon_control::BalloonTubeCommand;
use balloon_control::BalloonTubeResult;
-use balloon_control::BalloonWSS;
-use balloon_control::WSSBucket;
+use balloon_control::BalloonWS;
+use balloon_control::WSBucket;
use balloon_control::VIRTIO_BALLOON_WS_MAX_NUM_BINS;
use balloon_control::VIRTIO_BALLOON_WS_MIN_NUM_BINS;
use base::error;
@@ -101,7 +101,7 @@
}
pub type Result<T> = std::result::Result<T, BalloonError>;
-// Balloon implements six virt IO queues: Inflate, Deflate, Stats, Event, WssData, WssCmd.
+// Balloon implements six virt IO queues: Inflate, Deflate, Stats, Event, WsData, WsCmd.
const QUEUE_SIZE: u16 = 128;
const QUEUE_SIZES: &[u16] = &[
QUEUE_SIZE, QUEUE_SIZE, QUEUE_SIZE, QUEUE_SIZE, QUEUE_SIZE, QUEUE_SIZE,
@@ -116,7 +116,7 @@
const VIRTIO_BALLOON_F_DEFLATE_ON_OOM: u32 = 2; // Deflate balloon on OOM
const VIRTIO_BALLOON_F_PAGE_REPORTING: u32 = 5; // Page reporting virtqueue
// TODO(b/273973298): this should maybe be bit 6? to be changed later
-const VIRTIO_BALLOON_F_WSS_REPORTING: u32 = 8; // Working Set Size reporting virtqueues
+const VIRTIO_BALLOON_F_WS_REPORTING: u32 = 8; // Working Set Reporting virtqueues
#[derive(Copy, Clone)]
#[repr(u32)]
@@ -124,8 +124,8 @@
pub enum BalloonFeatures {
// Page Reporting enabled
PageReporting = VIRTIO_BALLOON_F_PAGE_REPORTING,
- // WSS Reporting enabled
- WSSReporting = VIRTIO_BALLOON_F_WSS_REPORTING,
+ // WS Reporting enabled
+ WSReporting = VIRTIO_BALLOON_F_WS_REPORTING,
}
// These feature bits are part of the proposal:
@@ -141,8 +141,8 @@
actual: Le32,
free_page_hint_cmd_id: Le32,
poison_val: Le32,
- // WSS field is part of proposed spec extension (b/273973298).
- wss_num_bins: u8,
+ // WS field is part of proposed spec extension (b/273973298).
+ ws_num_bins: u8,
_reserved: [u8; 3],
}
@@ -151,7 +151,7 @@
struct BalloonState {
num_pages: u32,
actual_pages: u32,
- expecting_wss: bool,
+ expecting_ws: bool,
// Flag indicating that the balloon is in the process of a failable update. This
// is set by an Adjust command that has allow_failure set, and is cleared when the
// Adjusted success/failure response is sent.
@@ -211,10 +211,10 @@
evt_type: Le32,
}
-// virtio_balloon_wss is used to deserialize from the wss data vq.
+// virtio_balloon_ws is used to deserialize from the ws data vq.
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, AsBytes, FromBytes)]
-struct virtio_balloon_wss {
+struct virtio_balloon_ws {
tag: Le16,
node_id: Le16,
// virtio prefers field members to align on a word boundary so we must pad. see:
@@ -225,25 +225,25 @@
memory_size_bytes: [Le64; 2],
}
-impl virtio_balloon_wss {
- fn update_wss(&self, wss: &mut BalloonWSS) {
- let bucket = WSSBucket {
+impl virtio_balloon_ws {
+ fn update_ws(&self, ws: &mut BalloonWS) {
+ let bucket = WSBucket {
age: self.idle_age_ms.to_native(),
bytes: [
self.memory_size_bytes[0].to_native(),
self.memory_size_bytes[1].to_native(),
],
};
- wss.wss.push(bucket);
+ ws.ws.push(bucket);
}
}
-const _VIRTIO_BALLOON_WSS_OP_INVALID: u16 = 0;
-const VIRTIO_BALLOON_WSS_OP_REQUEST: u16 = 1;
-const VIRTIO_BALLOON_WSS_OP_CONFIG: u16 = 2;
-const _VIRTIO_BALLOON_WSS_OP_DISCARD: u16 = 3;
+const _VIRTIO_BALLOON_WS_OP_INVALID: u16 = 0;
+const VIRTIO_BALLOON_WS_OP_REQUEST: u16 = 1;
+const VIRTIO_BALLOON_WS_OP_CONFIG: u16 = 2;
+const _VIRTIO_BALLOON_WS_OP_DISCARD: u16 = 3;
-// virtio_balloon_op is used to serialize to the wss cmd vq.
+// virtio_balloon_op is used to serialize to the ws cmd vq.
#[repr(C, packed)]
#[derive(Copy, Clone, Debug, Default, AsBytes, FromBytes)]
struct virtio_balloon_op {
@@ -599,31 +599,31 @@
Ok(queue)
}
-enum WSSOp {
- WSSReport,
- WSSConfig {
+enum WSOp {
+ WSReport,
+ WSConfig {
bins: Vec<u64>,
refresh_threshold: u64,
report_threshold: u64,
},
}
-async fn handle_wss_op_queue(
+async fn handle_ws_op_queue(
mem: &GuestMemory,
mut queue: Queue,
mut queue_event: EventAsync,
- mut wss_op_rx: mpsc::Receiver<WSSOp>,
+ mut ws_op_rx: mpsc::Receiver<WSOp>,
state: Arc<AsyncRwLock<BalloonState>>,
interrupt: Interrupt,
mut stop_rx: oneshot::Receiver<()>,
) -> Result<Queue> {
loop {
let op = select_biased! {
- next_op = wss_op_rx.next().fuse() => {
+ next_op = ws_op_rx.next().fuse() => {
match next_op {
Some(op) => op,
None => {
- error!("wss op tube was closed");
+ error!("ws op tube was closed");
break;
}
}
@@ -639,25 +639,25 @@
let writer = &mut avail_desc.writer;
match op {
- WSSOp::WSSReport => {
+ WSOp::WSReport => {
{
let mut state = state.lock().await;
- state.expecting_wss = true;
+ state.expecting_ws = true;
}
- let wss_r = virtio_balloon_op {
- type_: VIRTIO_BALLOON_WSS_OP_REQUEST.into(),
+ let ws_r = virtio_balloon_op {
+ type_: VIRTIO_BALLOON_WS_OP_REQUEST.into(),
};
- writer.write_obj(wss_r).map_err(BalloonError::WriteQueue)?;
+ writer.write_obj(ws_r).map_err(BalloonError::WriteQueue)?;
}
- WSSOp::WSSConfig {
+ WSOp::WSConfig {
bins,
refresh_threshold,
report_threshold,
} => {
let cmd = virtio_balloon_op {
- type_: VIRTIO_BALLOON_WSS_OP_CONFIG.into(),
+ type_: VIRTIO_BALLOON_WS_OP_CONFIG.into(),
};
writer.write_obj(cmd).map_err(BalloonError::WriteQueue)?;
@@ -681,33 +681,32 @@
Ok(queue)
}
-fn parse_balloon_wss(reader: &mut Reader) -> BalloonWSS {
- let mut wss = BalloonWSS::new();
- for res in reader.iter::<virtio_balloon_wss>() {
+fn parse_balloon_ws(reader: &mut Reader) -> BalloonWS {
+ let mut ws = BalloonWS::new();
+ for res in reader.iter::<virtio_balloon_ws>() {
match res {
- Ok(wss_msg) => {
- wss_msg.update_wss(&mut wss);
+ Ok(ws_msg) => {
+ ws_msg.update_ws(&mut ws);
}
Err(e) => {
- error!("error while reading wss: {}", e);
+ error!("error while reading ws: {}", e);
break;
}
}
}
- if wss.wss.len() < VIRTIO_BALLOON_WS_MIN_NUM_BINS
- || wss.wss.len() > VIRTIO_BALLOON_WS_MAX_NUM_BINS
+ if ws.ws.len() < VIRTIO_BALLOON_WS_MIN_NUM_BINS || ws.ws.len() > VIRTIO_BALLOON_WS_MAX_NUM_BINS
{
- error!("unexpected number of WSS buckets: {}", wss.wss.len());
+ error!("unexpected number of WS buckets: {}", ws.ws.len());
}
- wss
+ ws
}
// Async task that handles the stats queue. Note that the arrival of events on
-// the WSS vq may be the result of either a WSS request (WSS-R) command having
+// the WS vq may be the result of either a WS request (WS-R) command having
// been sent to the guest, or an unprompted send due to memory pressue in the
// guest. If the data was requested, we should also send that back on the
// command tube.
-async fn handle_wss_data_queue(
+async fn handle_ws_data_queue(
mem: &GuestMemory,
mut queue: Queue,
mut queue_event: EventAsync,
@@ -727,32 +726,29 @@
None => return Ok(queue),
};
- let wss = parse_balloon_wss(&mut avail_desc.reader);
+ let ws = parse_balloon_ws(&mut avail_desc.reader);
let mut state = state.lock().await;
- // update wss report with balloon pages now that we have a lock on state
+ // update ws report with balloon pages now that we have a lock on state
let balloon_actual = (state.actual_pages as u64) << VIRTIO_BALLOON_PFN_SHIFT;
- if state.expecting_wss {
- let result = BalloonTubeResult::WorkingSetSize {
- wss,
- balloon_actual,
- };
+ if state.expecting_ws {
+ let result = BalloonTubeResult::WorkingSet { ws, balloon_actual };
let send_result = command_tube.send(result).await;
if let Err(e) = send_result {
- error!("failed to send wss result: {}", e);
+ error!("failed to send ws result: {}", e);
}
- state.expecting_wss = false;
+ state.expecting_ws = false;
} else {
#[cfg(feature = "registered_events")]
if let Some(registered_evt_q) = registered_evt_q {
if let Err(e) = registered_evt_q
- .send(RegisteredEventWithData::from_wss(&wss, balloon_actual))
+ .send(RegisteredEventWithData::from_ws(&ws, balloon_actual))
.await
{
- error!("failed to send VirtioBalloonWSSReport event: {}", e);
+ error!("failed to send VirtioBalloonWSReport event: {}", e);
}
}
}
@@ -769,7 +765,7 @@
interrupt: Interrupt,
state: Arc<AsyncRwLock<BalloonState>>,
mut stats_tx: mpsc::Sender<()>,
- mut wss_op_tx: mpsc::Sender<WSSOp>,
+ mut ws_op_tx: mpsc::Sender<WSOp>,
mut stop_rx: oneshot::Receiver<()>,
) -> Result<()> {
loop {
@@ -799,17 +795,17 @@
}
}
}
- BalloonTubeCommand::WorkingSetSizeConfig {
+ BalloonTubeCommand::WorkingSetConfig {
bins,
refresh_threshold,
report_threshold,
} => {
- if let Err(e) = wss_op_tx.try_send(WSSOp::WSSConfig {
+ if let Err(e) = ws_op_tx.try_send(WSOp::WSConfig {
bins,
refresh_threshold,
report_threshold,
}) {
- error!("failed to send config to wss handler: {}", e);
+ error!("failed to send config to ws handler: {}", e);
}
}
BalloonTubeCommand::Stats => {
@@ -817,9 +813,9 @@
error!("failed to signal the stat handler: {}", e);
}
}
- BalloonTubeCommand::WorkingSetSize => {
- if let Err(e) = wss_op_tx.try_send(WSSOp::WSSReport) {
- error!("failed to send report request to wss handler: {}", e);
+ BalloonTubeCommand::WorkingSet => {
+ if let Err(e) = ws_op_tx.try_send(WSOp::WSReport) {
+ error!("failed to send report request to ws handler: {}", e);
}
}
},
@@ -866,7 +862,7 @@
stats: Option<(Queue, Event)>,
reporting: Option<(Queue, Event)>,
events: Option<(Queue, Event)>,
- wss: (Option<(Queue, Event)>, Option<(Queue, Event)>),
+ ws: (Option<(Queue, Event)>, Option<(Queue, Event)>),
}
impl BalloonQueues {
@@ -877,7 +873,7 @@
stats: None,
reporting: None,
events: None,
- wss: (None, None),
+ ws: (None, None),
}
}
}
@@ -889,7 +885,7 @@
stats: Option<Queue>,
reporting: Option<Queue>,
events: Option<Queue>,
- wss: (Option<Queue>, Option<Queue>),
+ ws: (Option<Queue>, Option<Queue>),
}
impl PausedQueues {
@@ -900,7 +896,7 @@
stats: None,
reporting: None,
events: None,
- wss: (None, None),
+ ws: (None, None),
}
}
}
@@ -922,8 +918,8 @@
apply_if_some(queues.stats, |stats| ret.push(stats));
apply_if_some(queues.reporting, |reporting| ret.push(reporting));
apply_if_some(queues.events, |events| ret.push(events));
- apply_if_some(queues.wss.0, |wss_data| ret.push(wss_data));
- apply_if_some(queues.wss.1, |wss_op| ret.push(wss_op));
+ apply_if_some(queues.ws.0, |ws_data| ret.push(ws_data));
+ apply_if_some(queues.ws.1, |ws_op| ret.push(ws_op));
// WARNING: We don't use the indices from the virito spec on purpose, see comment in
// get_queues_from_map for the rationale.
ret.into_iter().enumerate().collect()
@@ -950,7 +946,7 @@
stats_queue: Option<(Queue, Event)>,
reporting_queue: Option<(Queue, Event)>,
events_queue: Option<(Queue, Event)>,
- wss_queues: (Option<(Queue, Event)>, Option<(Queue, Event)>),
+ ws_queues: (Option<(Queue, Event)>, Option<(Queue, Event)>),
command_tube: Tube,
#[cfg(windows)] vm_memory_client: VmMemoryClient,
release_memory_tube: Option<Tube>,
@@ -1070,15 +1066,15 @@
let reporting = reporting.fuse();
pin_mut!(reporting);
- // If VIRTIO_BALLOON_F_WSS_REPORTING is set 2 queues must handled - one for WSS data and one
- // for WSS notifications.
- let has_wss_data_queue = wss_queues.0.is_some();
- let wss_data = if let Some((wss_data_queue, wss_data_queue_evt)) = wss_queues.0 {
+ // If VIRTIO_BALLOON_F_WS_REPORTING is set 2 queues must handled - one for WS data and one
+ // for WS notifications.
+ let has_ws_data_queue = ws_queues.0.is_some();
+ let ws_data = if let Some((ws_data_queue, ws_data_queue_evt)) = ws_queues.0 {
let stop_rx = create_stop_oneshot(&mut stop_queue_oneshots);
- handle_wss_data_queue(
+ handle_ws_data_queue(
&mem,
- wss_data_queue,
- EventAsync::new(wss_data_queue_evt, &ex).expect("failed to create async event"),
+ ws_data_queue,
+ EventAsync::new(ws_data_queue_evt, &ex).expect("failed to create async event"),
&command_tube,
#[cfg(feature = "registered_events")]
registered_evt_q_async.as_ref(),
@@ -1090,18 +1086,18 @@
} else {
std::future::pending().right_future()
};
- let wss_data = wss_data.fuse();
- pin_mut!(wss_data);
+ let ws_data = ws_data.fuse();
+ pin_mut!(ws_data);
- let (wss_op_tx, wss_op_rx) = mpsc::channel::<WSSOp>(1);
- let has_wss_op_queue = wss_queues.1.is_some();
- let wss_op = if let Some((wss_op_queue, wss_op_queue_evt)) = wss_queues.1 {
+ let (ws_op_tx, ws_op_rx) = mpsc::channel::<WSOp>(1);
+ let has_ws_op_queue = ws_queues.1.is_some();
+ let ws_op = if let Some((ws_op_queue, ws_op_queue_evt)) = ws_queues.1 {
let stop_rx = create_stop_oneshot(&mut stop_queue_oneshots);
- handle_wss_op_queue(
+ handle_ws_op_queue(
&mem,
- wss_op_queue,
- EventAsync::new(wss_op_queue_evt, &ex).expect("failed to create async event"),
- wss_op_rx,
+ ws_op_queue,
+ EventAsync::new(ws_op_queue_evt, &ex).expect("failed to create async event"),
+ ws_op_rx,
state.clone(),
interrupt.clone(),
stop_rx,
@@ -1110,8 +1106,8 @@
} else {
std::future::pending().right_future()
};
- let wss_op = wss_op.fuse();
- pin_mut!(wss_op);
+ let ws_op = ws_op.fuse();
+ pin_mut!(ws_op);
// Future to handle command messages that resize the balloon.
let stop_rx = create_stop_oneshot(&mut stop_queue_oneshots);
@@ -1120,7 +1116,7 @@
interrupt.clone(),
state.clone(),
stats_tx,
- wss_op_tx,
+ ws_op_tx,
stop_rx,
);
pin_mut!(command);
@@ -1178,11 +1174,11 @@
_ = stats => return Err(anyhow!("stats stopped unexpectedly")),
_ = reporting => return Err(anyhow!("reporting stopped unexpectedly")),
_ = command.fuse() => return Err(anyhow!("command stopped unexpectedly")),
- _ = wss_op => return Err(anyhow!("wss_op stopped unexpectedly")),
+ _ = ws_op => return Err(anyhow!("ws_op stopped unexpectedly")),
_ = resample.fuse() => return Err(anyhow!("resample stopped unexpectedly")),
_ = events => return Err(anyhow!("events stopped unexpectedly")),
_ = pending_adjusted.fuse() => return Err(anyhow!("pending_adjusted stopped unexpectedly")),
- _ = wss_data => return Err(anyhow!("wss_data stopped unexpectedly")),
+ _ = ws_data => return Err(anyhow!("ws_data stopped unexpectedly")),
_ = target_reached.fuse() => return Err(anyhow!("target_reached stopped unexpectedly")),
}
@@ -1209,11 +1205,11 @@
if has_stats_queue {
paused_queues.stats = Some(stats.await);
}
- if has_wss_op_queue {
- paused_queues.wss.0 = Some(wss_op.await.context("failed to stop wss_op queue")?);
+ if has_ws_op_queue {
+ paused_queues.ws.0 = Some(ws_op.await.context("failed to stop ws_op queue")?);
}
- if has_wss_data_queue {
- paused_queues.wss.1 = Some(wss_data.await.context("failed to stop wss_data queue")?);
+ if has_ws_data_queue {
+ paused_queues.ws.1 = Some(ws_data.await.context("failed to stop ws_data queue")?);
}
Ok(paused_queues)
});
@@ -1282,7 +1278,7 @@
worker_thread: Option<WorkerThread<WorkerReturn>>,
#[cfg(feature = "registered_events")]
registered_evt_q: Option<SendTube>,
- wss_num_bins: u8,
+ ws_num_bins: u8,
target_reached_evt: Option<Event>,
}
@@ -1292,7 +1288,7 @@
state: BalloonState,
features: u64,
acked_features: u64,
- wss_num_bins: u8,
+ ws_num_bins: u8,
}
/// Operation mode of the balloon.
@@ -1319,7 +1315,7 @@
mode: BalloonMode,
enabled_features: u64,
#[cfg(feature = "registered_events")] registered_evt_q: Option<SendTube>,
- wss_num_bins: u8,
+ ws_num_bins: u8,
) -> Result<Balloon> {
let features = base_features
| 1 << VIRTIO_BALLOON_F_MUST_TELL_HOST
@@ -1343,14 +1339,14 @@
actual_pages: 0,
failable_update: false,
pending_adjusted_responses: VecDeque::new(),
- expecting_wss: false,
+ expecting_ws: false,
})),
worker_thread: None,
features,
acked_features: 0,
#[cfg(feature = "registered_events")]
registered_evt_q,
- wss_num_bins,
+ ws_num_bins,
target_reached_evt: None,
})
}
@@ -1366,7 +1362,7 @@
// config correctly.
free_page_hint_cmd_id: 0.into(),
poison_val: 0.into(),
- wss_num_bins: self.wss_num_bins,
+ ws_num_bins: self.ws_num_bins,
_reserved: [0, 0, 0],
}
}
@@ -1386,8 +1382,8 @@
if acked_features & (1 << VIRTIO_BALLOON_F_PAGE_REPORTING) != 0 {
num_queues += 1;
}
- // working set size vqueues
- if acked_features & (1 << VIRTIO_BALLOON_F_WSS_REPORTING) != 0 {
+ // working set vqueues
+ if acked_features & (1 << VIRTIO_BALLOON_F_WS_REPORTING) != 0 {
num_queues += 2;
}
@@ -1449,8 +1445,8 @@
if self.acked_features & (1 << VIRTIO_BALLOON_F_EVENTS_VQ) != 0 {
queue_struct.events = Some(queues.pop_first().unwrap().1);
}
- if self.acked_features & (1 << VIRTIO_BALLOON_F_WSS_REPORTING) != 0 {
- queue_struct.wss = (
+ if self.acked_features & (1 << VIRTIO_BALLOON_F_WS_REPORTING) != 0 {
+ queue_struct.ws = (
Some(queues.pop_first().unwrap().1),
Some(queues.pop_first().unwrap().1),
);
@@ -1490,7 +1486,7 @@
queues.stats,
queues.reporting,
queues.events,
- queues.wss,
+ queues.ws,
command_tube,
#[cfg(windows)]
vm_memory_client,
@@ -1628,7 +1624,7 @@
features: self.features,
acked_features: self.acked_features,
state: state.clone(),
- wss_num_bins: self.wss_num_bins,
+ ws_num_bins: self.ws_num_bins,
})
.context("failed to serialize balloon state")
}
@@ -1649,7 +1645,7 @@
.now_or_never()
.context("failed to acquire balloon lock")?;
*state = snap.state;
- self.wss_num_bins = snap.wss_num_bins;
+ self.ws_num_bins = snap.ws_num_bins;
self.acked_features = snap.acked_features;
Ok(())
}
@@ -1727,7 +1723,7 @@
VIRTIO_BALLOON_F_STATS_VQ,
VIRTIO_BALLOON_F_EVENTS_VQ,
VIRTIO_BALLOON_F_PAGE_REPORTING,
- VIRTIO_BALLOON_F_WSS_REPORTING
+ VIRTIO_BALLOON_F_WS_REPORTING
]))
);
}
diff --git a/protos/src/registered_events.proto b/protos/src/registered_events.proto
index 10f0a03..d0cc089 100644
--- a/protos/src/registered_events.proto
+++ b/protos/src/registered_events.proto
@@ -8,7 +8,7 @@
message VirtioBalloonOOMDeflation {}
-message VirtioWssBucket {
+message VirtioWsBucket {
// age of bucket in milliseconds.
uint64 age = 1;
// file-back memory, in bytes.
@@ -17,9 +17,9 @@
uint64 anon_bytes = 3;
}
-message VirtioBalloonWssReport {
- // 2-16 buckets of memory working set size.
- repeated VirtioWssBucket wss_buckets = 1;
+message VirtioBalloonWsReport {
+ // 2-16 buckets of memory working set.
+ repeated VirtioWsBucket ws_buckets = 1;
// actual size of balloon in bytes.
uint64 balloon_actual = 2;
}
@@ -28,6 +28,6 @@
oneof Event {
VirtioBalloonResize resize = 1;
VirtioBalloonOOMDeflation oom_deflation = 2;
- VirtioBalloonWssReport wss_report = 3;
+ VirtioBalloonWsReport ws_report = 3;
}
}
diff --git a/src/crosvm/cmdline.rs b/src/crosvm/cmdline.rs
index 4af7a68..dfa07cd 100644
--- a/src/crosvm/cmdline.rs
+++ b/src/crosvm/cmdline.rs
@@ -133,7 +133,10 @@
#[cfg(feature = "balloon")]
BalloonStats(BalloonStatsCommand),
#[cfg(feature = "balloon")]
- BalloonWss(BalloonWssCommand),
+ BalloonWs(BalloonWsCommand),
+ // TODO(b/288432539): remove once concierge is migrated
+ #[cfg(feature = "balloon")]
+ BalloonWss(BalloonWsCommand),
Battery(BatteryCommand),
#[cfg(feature = "composite-disk")]
CreateComposite(CreateCompositeCommand),
@@ -189,10 +192,10 @@
}
#[derive(argh::FromArgs)]
-#[argh(subcommand, name = "balloon_wss")]
-/// Prints virtio balloon working set size for a `VM_SOCKET`
-pub struct BalloonWssCommand {
- #[argh(positional, arg_name = "VM_SOOCKET")]
+#[argh(subcommand, name = "balloon_ws")]
+/// Prints virtio balloon working set for a `VM_SOCKET`
+pub struct BalloonWsCommand {
+ #[argh(positional, arg_name = "VM_SOCKET")]
/// VM control socket path.
pub socket_path: String,
}
@@ -954,13 +957,20 @@
#[argh(option)]
#[serde(skip)] // TODO(b/255223604)
#[merge(strategy = overwrite_option)]
- /// set number of WSS bins to use (default = 4).
- pub balloon_wss_num_bins: Option<u8>,
+ /// set number of WS bins to use (default = 4).
+ pub balloon_ws_num_bins: Option<u8>,
#[argh(switch)]
#[serde(skip)] // TODO(b/255223604)
#[merge(strategy = overwrite_option)]
- /// enable working set size reporting in balloon.
+ /// enable working set reporting in balloon.
+ pub balloon_ws_reporting: Option<bool>,
+
+ // TODO(b/288432539): remove once concierge is migrated
+ #[argh(switch)]
+ #[serde(skip)] // TODO(b/255223604)
+ #[merge(strategy = overwrite_option)]
+ /// enable working set reporting in balloon.
pub balloon_wss_reporting: Option<bool>,
#[argh(option)]
@@ -2881,8 +2891,10 @@
cfg.rng = !cmd.no_rng.unwrap_or_default();
cfg.balloon = !cmd.no_balloon.unwrap_or_default();
cfg.balloon_page_reporting = cmd.balloon_page_reporting.unwrap_or_default();
- cfg.balloon_wss_num_bins = cmd.balloon_wss_num_bins.unwrap_or(4);
- cfg.balloon_wss_reporting = cmd.balloon_wss_reporting.unwrap_or_default();
+ cfg.balloon_ws_num_bins = cmd.balloon_ws_num_bins.unwrap_or(4);
+ cfg.balloon_ws_reporting = cmd.balloon_ws_reporting.unwrap_or_default()
+ // TODO(b/288432539): remove once concierge is migrated
+ | cmd.balloon_wss_reporting.unwrap_or_default();
#[cfg(feature = "audio")]
{
cfg.virtio_snds = cmd.virtio_snd;
diff --git a/src/crosvm/config.rs b/src/crosvm/config.rs
index 69da255..c74ee67 100644
--- a/src/crosvm/config.rs
+++ b/src/crosvm/config.rs
@@ -835,8 +835,8 @@
pub balloon_bias: i64,
pub balloon_control: Option<PathBuf>,
pub balloon_page_reporting: bool,
- pub balloon_wss_num_bins: u8,
- pub balloon_wss_reporting: bool,
+ pub balloon_ws_num_bins: u8,
+ pub balloon_ws_reporting: bool,
pub battery_config: Option<BatteryConfig>,
#[cfg(windows)]
pub block_control_tube: Vec<Tube>,
@@ -1040,8 +1040,8 @@
balloon_bias: 0,
balloon_control: None,
balloon_page_reporting: false,
- balloon_wss_num_bins: VIRTIO_BALLOON_WS_DEFAULT_NUM_BINS,
- balloon_wss_reporting: false,
+ balloon_ws_num_bins: VIRTIO_BALLOON_WS_DEFAULT_NUM_BINS,
+ balloon_ws_reporting: false,
battery_config: None,
#[cfg(windows)]
block_control_tube: Vec::new(),
diff --git a/src/crosvm/sys/unix.rs b/src/crosvm/sys/unix.rs
index e81d846..d1ff75c 100644
--- a/src/crosvm/sys/unix.rs
+++ b/src/crosvm/sys/unix.rs
@@ -512,7 +512,7 @@
if let Some(balloon_device_tube) = balloon_device_tube {
let balloon_features = (cfg.balloon_page_reporting as u64)
<< BalloonFeatures::PageReporting as u64
- | (cfg.balloon_wss_reporting as u64) << BalloonFeatures::WSSReporting as u64;
+ | (cfg.balloon_ws_reporting as u64) << BalloonFeatures::WSReporting as u64;
devs.push(create_balloon_device(
cfg.protection_type,
&cfg.jail_config,
@@ -531,7 +531,7 @@
.try_clone()
.context("failed to clone registered_evt_q tube")?,
),
- cfg.balloon_wss_num_bins,
+ cfg.balloon_ws_num_bins,
)?);
}
diff --git a/src/crosvm/sys/unix/device_helpers.rs b/src/crosvm/sys/unix/device_helpers.rs
index e490139..23895c4 100644
--- a/src/crosvm/sys/unix/device_helpers.rs
+++ b/src/crosvm/sys/unix/device_helpers.rs
@@ -755,7 +755,7 @@
init_balloon_size: u64,
enabled_features: u64,
#[cfg(feature = "registered_events")] registered_evt_q: Option<SendTube>,
- wss_num_bins: u8,
+ ws_num_bins: u8,
) -> DeviceResult {
let dev = virtio::Balloon::new(
virtio::base_features(protection_type),
@@ -766,7 +766,7 @@
enabled_features,
#[cfg(feature = "registered_events")]
registered_evt_q,
- wss_num_bins,
+ ws_num_bins,
)
.context("failed to create balloon")?;
diff --git a/src/main.rs b/src/main.rs
index db339f9..73ea8ab 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -253,8 +253,8 @@
}
#[cfg(feature = "balloon")]
-fn balloon_wss(cmd: cmdline::BalloonWssCommand) -> std::result::Result<(), ()> {
- let command = BalloonControlCommand::WorkingSetSize {};
+fn balloon_ws(cmd: cmdline::BalloonWsCommand) -> std::result::Result<(), ()> {
+ let command = BalloonControlCommand::WorkingSet {};
let request = &VmRequest::BalloonCommand(command);
let response = handle_request(request, cmd.socket_path)?;
match serde_json::to_string_pretty(&response) {
@@ -265,7 +265,7 @@
}
}
match response {
- VmResponse::BalloonWSS { .. } => Ok(()),
+ VmResponse::BalloonWS { .. } => Ok(()),
_ => Err(()),
}
}
@@ -731,8 +731,13 @@
balloon_stats(cmd).map_err(|_| anyhow!("balloon_stats subcommand failed"))
}
#[cfg(feature = "balloon")]
+ CrossPlatformCommands::BalloonWs(cmd) => {
+ balloon_ws(cmd).map_err(|_| anyhow!("balloon_ws subcommand failed"))
+ }
+ // TODO(b/288432539): remove once concierge is migrated
+ #[cfg(feature = "balloon")]
CrossPlatformCommands::BalloonWss(cmd) => {
- balloon_wss(cmd).map_err(|_| anyhow!("balloon_wss subcommand failed"))
+ balloon_ws(cmd).map_err(|_| anyhow!("balloon_ws subcommand failed"))
}
CrossPlatformCommands::Battery(cmd) => {
modify_battery(cmd).map_err(|_| anyhow!("battery subcommand failed"))
diff --git a/vm_control/src/balloon_tube.rs b/vm_control/src/balloon_tube.rs
index 442887d..aa7623b 100644
--- a/vm_control/src/balloon_tube.rs
+++ b/vm_control/src/balloon_tube.rs
@@ -12,8 +12,8 @@
pub use balloon_control::BalloonStats;
use balloon_control::BalloonTubeCommand;
pub use balloon_control::BalloonTubeResult;
-pub use balloon_control::BalloonWSS;
-pub use balloon_control::WSSBucket;
+pub use balloon_control::BalloonWS;
+pub use balloon_control::WSBucket;
pub use balloon_control::VIRTIO_BALLOON_WS_MAX_NUM_BINS;
pub use balloon_control::VIRTIO_BALLOON_WS_MIN_NUM_BINS;
use base::Error as SysError;
@@ -31,8 +31,8 @@
num_bytes: u64,
},
Stats,
- WorkingSetSize,
- WorkingSetSizeConfig {
+ WorkingSet,
+ WorkingSetConfig {
bins: Vec<u64>,
refresh_threshold: u64,
report_threshold: u64,
@@ -50,12 +50,12 @@
Err(_) => Some(VmResponse::Err(SysError::last())),
}
}
- BalloonControlCommand::WorkingSetSizeConfig {
+ BalloonControlCommand::WorkingSetConfig {
ref bins,
refresh_threshold,
report_threshold,
} => {
- match tube.send(&BalloonTubeCommand::WorkingSetSizeConfig {
+ match tube.send(&BalloonTubeCommand::WorkingSetConfig {
bins: bins.clone(),
refresh_threshold,
report_threshold,
@@ -68,12 +68,10 @@
Ok(_) => None,
Err(_) => Some(VmResponse::Err(SysError::last())),
},
- BalloonControlCommand::WorkingSetSize => {
- match tube.send(&BalloonTubeCommand::WorkingSetSize) {
- Ok(_) => None,
- Err(_) => Some(VmResponse::Err(SysError::last())),
- }
- }
+ BalloonControlCommand::WorkingSet => match tube.send(&BalloonTubeCommand::WorkingSet) {
+ Ok(_) => None,
+ Err(_) => Some(VmResponse::Err(SysError::last())),
+ },
}
}
@@ -137,15 +135,9 @@
balloon_actual,
},
(
- BalloonControlCommand::WorkingSetSize,
- BalloonTubeResult::WorkingSetSize {
- wss,
- balloon_actual,
- },
- ) => VmResponse::BalloonWSS {
- wss,
- balloon_actual,
- },
+ BalloonControlCommand::WorkingSet,
+ BalloonTubeResult::WorkingSet { ws, balloon_actual },
+ ) => VmResponse::BalloonWS { ws, balloon_actual },
(_, resp) => {
bail!("Unexpected balloon tube result {:?}", resp);
}
diff --git a/vm_control/src/lib.rs b/vm_control/src/lib.rs
index bf9a250..2fc27c4 100644
--- a/vm_control/src/lib.rs
+++ b/vm_control/src/lib.rs
@@ -1296,7 +1296,7 @@
#[cfg(feature = "registered_events")]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum RegisteredEvent {
- VirtioBalloonWssReport,
+ VirtioBalloonWsReport,
VirtioBalloonResize,
VirtioBalloonOOMDeflation,
}
@@ -1304,8 +1304,8 @@
#[cfg(feature = "registered_events")]
#[derive(Serialize, Deserialize, Debug)]
pub enum RegisteredEventWithData {
- VirtioBalloonWssReport {
- wss_buckets: Vec<WSSBucket>,
+ VirtioBalloonWsReport {
+ ws_buckets: Vec<WSBucket>,
balloon_actual: u64,
},
VirtioBalloonResize,
@@ -1316,7 +1316,7 @@
impl RegisteredEventWithData {
pub fn into_event(&self) -> RegisteredEvent {
match self {
- Self::VirtioBalloonWssReport { .. } => RegisteredEvent::VirtioBalloonWssReport,
+ Self::VirtioBalloonWsReport { .. } => RegisteredEvent::VirtioBalloonWsReport,
Self::VirtioBalloonResize => RegisteredEvent::VirtioBalloonResize,
Self::VirtioBalloonOOMDeflation => RegisteredEvent::VirtioBalloonOOMDeflation,
}
@@ -1324,24 +1324,24 @@
pub fn into_proto(&self) -> registered_events::RegisteredEvent {
match self {
- Self::VirtioBalloonWssReport {
- wss_buckets,
+ Self::VirtioBalloonWsReport {
+ ws_buckets,
balloon_actual,
} => {
- let mut report = registered_events::VirtioBalloonWssReport {
+ let mut report = registered_events::VirtioBalloonWsReport {
balloon_actual: *balloon_actual,
- ..registered_events::VirtioBalloonWssReport::new()
+ ..registered_events::VirtioBalloonWsReport::new()
};
- for wss in wss_buckets {
- report.wss_buckets.push(registered_events::VirtioWssBucket {
- age: wss.age,
- file_bytes: wss.bytes[0],
- anon_bytes: wss.bytes[1],
- ..registered_events::VirtioWssBucket::new()
+ for ws in ws_buckets {
+ report.ws_buckets.push(registered_events::VirtioWsBucket {
+ age: ws.age,
+ file_bytes: ws.bytes[0],
+ anon_bytes: ws.bytes[1],
+ ..registered_events::VirtioWsBucket::new()
});
}
let mut event = registered_events::RegisteredEvent::new();
- event.set_wss_report(report);
+ event.set_ws_report(report);
event
}
Self::VirtioBalloonResize => {
@@ -1357,9 +1357,9 @@
}
}
- pub fn from_wss(wss: &BalloonWSS, balloon_actual: u64) -> Self {
- RegisteredEventWithData::VirtioBalloonWssReport {
- wss_buckets: wss.wss.clone(),
+ pub fn from_ws(ws: &BalloonWS, balloon_actual: u64) -> Self {
+ RegisteredEventWithData::VirtioBalloonWsReport {
+ ws_buckets: ws.ws.clone(),
balloon_actual,
}
}
@@ -2130,12 +2130,9 @@
stats: BalloonStats,
balloon_actual: u64,
},
- /// Results of balloon WSS-R command
+ /// Results of balloon WS-R command
#[cfg(feature = "balloon")]
- BalloonWSS {
- wss: BalloonWSS,
- balloon_actual: u64,
- },
+ BalloonWS { ws: BalloonWS, balloon_actual: u64 },
/// Results of PCI hot plug
#[cfg(feature = "pci-hotplug")]
PciHotPlugResponse { bus: u8 },
@@ -2179,14 +2176,11 @@
)
}
#[cfg(feature = "balloon")]
- VmResponse::BalloonWSS {
- wss,
- balloon_actual,
- } => {
+ VmResponse::BalloonWS { ws, balloon_actual } => {
write!(
f,
- "wss: {}, balloon_actual: {}",
- serde_json::to_string_pretty(&wss)
+ "ws: {}, balloon_actual: {}",
+ serde_json::to_string_pretty(&ws)
.unwrap_or_else(|_| "invalid_response".to_string()),
balloon_actual,
)