From ed22f6b611e2623f5836ccf1288adf6b46146088 Mon Sep 17 00:00:00 2001 From: Charles William Dick Date: Wed, 8 Apr 2020 11:05:24 +0900 Subject: crosvm balloon_stats command In preparation for moving balloon sizing logic from crosvm to concierge, expose a balloon_stats command in crosvm. This will allow concierge to query the actual balloon size and available memory of VMs. BUG=b:153134684 TEST=(chroot)$ tast run arc.Boot.vm; (vm)$ crosvm balloon_stats ; See stats are reported. Change-Id: I1f544526ee728a085d842035754a0c17cf41ed3f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2141752 Tested-by: Charles Dueck Tested-by: kokoro Reviewed-by: Chirantan Ekbote Commit-Queue: Charles Dueck --- src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 241334d..6900099 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1474,6 +1474,19 @@ fn balloon_vms(mut args: std::env::Args) -> std::result::Result<(), ()> { vms_request(&VmRequest::BalloonCommand(command), args) } +fn balloon_stats(args: std::env::Args) -> std::result::Result<(), ()> { + if args.len() != 1 { + print_help("crosvm balloon_stats", "VM_SOCKET", &[]); + println!("Prints virtio balloon statistics for a `VM_SOCKET`."); + return Err(()); + } + let command = BalloonControlCommand::Stats {}; + let request = &VmRequest::BalloonCommand(command); + let response = handle_request(request, args)?; + println!("{}", response); + Ok(()) +} + fn create_qcow2(args: std::env::Args) -> std::result::Result<(), ()> { let arguments = [ Argument::positional("PATH", "where to create the qcow2 image"), @@ -1820,6 +1833,7 @@ fn crosvm_main() -> std::result::Result<(), ()> { Some("resume") => resume_vms(args), Some("run") => run_vm(args), Some("balloon") => balloon_vms(args), + Some("balloon_stats") => balloon_stats(args), Some("create_qcow2") => create_qcow2(args), Some("disk") => disk_cmd(args), Some("usb") => modify_usb(args), -- cgit 1.4.1