Can set the number of VCPUs

This commit is contained in:
2023-12-07 17:09:33 +01:00
parent d1a9b6c3bb
commit 5f0f56a9f9
10 changed files with 148 additions and 12 deletions

@ -91,6 +91,23 @@ pub async fn server_info(client: LibVirtReq) -> HttpResult {
}))
}
pub async fn number_vcpus() -> HttpResult {
let mut system = System::new();
system.refresh_cpu();
let number_cpus = system.cpus().len();
assert_ne!(number_cpus, 0, "Got invlid number of CPU!");
let mut possible_numbers = vec![1];
if number_cpus > 1 {
for i in 0..(number_cpus / 2) {
possible_numbers.push(2 + 2 * i);
}
}
Ok(HttpResponse::Ok().json(possible_numbers))
}
pub async fn networks_list() -> HttpResult {
let mut system = System::new();
system.refresh_networks_list();