mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: Make api_create_body() parameterless
Refactor api_create_body() to read cpu_count, kernel_path, and kernel_cmdline from Guest fields instead of taking them as parameters. This makes Guest the single source of truth for VM configuration. Update all call sites in HTTP and DBus API tests to use the new parameterless signature. Switch guest creation to use GuestFactory for consistent 4-CPU configuration. Replace manual CPU and memory assertions with validate_cpu_count() and validate_memory() helpers. Replace thread::sleep with wait_vm_boot() in _test_api_create_boot for proper boot synchronization. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
f443bae9d9
commit
7a0019514f
@@ -1083,11 +1083,11 @@ impl Guest {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn api_create_body(&self, cpu_count: u8, kernel_path: &str, kernel_cmd: &str) -> String {
|
||||
pub fn api_create_body(&self) -> String {
|
||||
let mut body = serde_json::json!({
|
||||
"cpus": {
|
||||
"boot_vcpus": cpu_count,
|
||||
"max_vcpus": cpu_count,
|
||||
"boot_vcpus": self.num_cpu,
|
||||
"max_vcpus": self.num_cpu,
|
||||
},
|
||||
"net": [
|
||||
{
|
||||
@@ -1117,13 +1117,13 @@ impl Guest {
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"cmdline": kernel_cmd,
|
||||
"cmdline": self.kernel_cmdline.as_deref().unwrap(),
|
||||
"host_data": generate_host_data(),
|
||||
});
|
||||
} else {
|
||||
body["payload"] = serde_json::json!({
|
||||
"kernel": kernel_path,
|
||||
"cmdline": kernel_cmd,
|
||||
"kernel": self.kernel_path.as_deref().unwrap(),
|
||||
"cmdline": self.kernel_cmdline.as_deref().unwrap(),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user