cloud-hypervisor/flake.nix
Davíð Steinn Geirsson 480bfb7095 virtio-devices: balloon: add statistics virtqueue support
Implement the virtio balloon statistics virtqueue per the VIRTIO spec,
exposing guest memory statistics through a new /vm.balloon-statistics
API endpoint.

Device layer: add stats virtqueue constants and types, wire up the
stats queue in the balloon handler, implement stats request/response
handlers, and expose a public request_balloon_statistics function.

VMM layer: plumb statistics through device manager, VM, and VMM,
add HTTP and D-Bus API endpoints, add ServiceUnavailable (503) to
api_client, add balloon-statistics subcommand to ch-remote, and add
the endpoint to the OpenAPI spec.

The response includes both guest-reported stats and host-known values
(balloon_actual_bytes, balloon_target_bytes, balloon_total_ram_bytes)
so consumers can understand balloon utilization without querying
/vm.info separately.

Also fixes pre-existing rustfmt issues and adds clippy+rustfmt to the
flake devShell.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 10:05:19 +00:00

100 lines
2.9 KiB
Nix

{
description = "Cloud Hypervisor DSG fork";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs =
{ self, nixpkgs }:
let
supportedSystems = [
"aarch64-linux"
"riscv64-linux"
"x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in
{
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
in
{
default = self.packages.${system}.cloud-hypervisor;
cloud-hypervisor = pkgs.rustPlatform.buildRustPackage (finalAttrs: {
pname = "cloud-hypervisor";
version = "50.0.0";
src = self;
# After updating Cargo.lock with `cargo update`, fill in the hashes
# for the git-sourced vhost packages by running `nix build` and
# replacing lib.fakeHash with the hash reported in the error message.
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"micro_http-0.1.0" = "sha256-XemdzwS25yKWEXJcRX2l6QzD7lrtroMeJNOUEWGR7WQ=";
"vhost-0.15.0" = "sha256-iH5Zr9lSlkWhhdOQTSiPQ/mHBaKJ/oamTJZgY68tnGg=";
"vhost-user-backend-0.21.0" = "sha256-iH5Zr9lSlkWhhdOQTSiPQ/mHBaKJ/oamTJZgY68tnGg=";
};
};
separateDebugInfo = true;
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs =
[ pkgs.openssl ]
++ lib.optional pkgs.stdenv.hostPlatform.isAarch64 pkgs.dtc;
env.OPENSSL_NO_VENDOR = true;
cargoTestFlags = [
"--workspace"
"--exclude"
"hypervisor" # /dev/kvm
"--exclude"
"net_util" # /dev/net/tun
"--exclude"
"virtio-devices" # seccomp
"--exclude"
"vmm" # /dev/kvm
];
meta = {
homepage = "https://git.dsg.is/dsg/cloud-hypervisor";
description = "Open source Virtual Machine Monitor (VMM) that runs on top of KVM";
license = with lib.licenses; [
asl20
bsd3
];
mainProgram = "cloud-hypervisor";
platforms = [
"aarch64-linux"
"riscv64-linux"
"x86_64-linux"
];
};
});
}
);
devShells = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
in
{
default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.cloud-hypervisor ];
nativeBuildInputs = with pkgs; [
clippy
rustfmt
];
};
}
);
};
}