mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-03-20 07:58:55 +00:00
tests: Add disk_hotplug test with Landlock
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
This commit is contained in:
parent
034c674c4c
commit
466cc5e043
@ -5210,8 +5210,7 @@ mod common_parallel {
|
|||||||
handle_child_output(r, &output);
|
handle_child_output(r, &output);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
fn _test_disk_hotplug(landlock_enabled: bool) {
|
||||||
fn test_disk_hotplug() {
|
|
||||||
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
||||||
let guest = Guest::new(Box::new(focal));
|
let guest = Guest::new(Box::new(focal));
|
||||||
|
|
||||||
@ -5222,17 +5221,28 @@ mod common_parallel {
|
|||||||
|
|
||||||
let api_socket = temp_api_path(&guest.tmp_dir);
|
let api_socket = temp_api_path(&guest.tmp_dir);
|
||||||
|
|
||||||
let mut child = GuestCommand::new(&guest)
|
let mut blk_file_path = dirs::home_dir().unwrap();
|
||||||
.args(["--api-socket", &api_socket])
|
blk_file_path.push("workloads");
|
||||||
|
blk_file_path.push("blk.img");
|
||||||
|
|
||||||
|
let mut cmd = GuestCommand::new(&guest);
|
||||||
|
if landlock_enabled {
|
||||||
|
cmd.args(["--landlock"]).args([
|
||||||
|
"--landlock-rules",
|
||||||
|
format!("path={:?},access=rw", blk_file_path).as_str(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.args(["--api-socket", &api_socket])
|
||||||
.args(["--cpus", "boot=1"])
|
.args(["--cpus", "boot=1"])
|
||||||
.args(["--memory", "size=512M"])
|
.args(["--memory", "size=512M"])
|
||||||
.args(["--kernel", kernel_path.to_str().unwrap()])
|
.args(["--kernel", kernel_path.to_str().unwrap()])
|
||||||
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
||||||
.default_disks()
|
.default_disks()
|
||||||
.default_net()
|
.default_net()
|
||||||
.capture_output()
|
.capture_output();
|
||||||
.spawn()
|
|
||||||
.unwrap();
|
let mut child = cmd.spawn().unwrap();
|
||||||
|
|
||||||
let r = std::panic::catch_unwind(|| {
|
let r = std::panic::catch_unwind(|| {
|
||||||
guest.wait_vm_boot(None).unwrap();
|
guest.wait_vm_boot(None).unwrap();
|
||||||
@ -5249,9 +5259,6 @@ mod common_parallel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Now let's add the extra disk.
|
// Now let's add the extra disk.
|
||||||
let mut blk_file_path = dirs::home_dir().unwrap();
|
|
||||||
blk_file_path.push("workloads");
|
|
||||||
blk_file_path.push("blk.img");
|
|
||||||
let (cmd_success, cmd_output) = remote_command_w_output(
|
let (cmd_success, cmd_output) = remote_command_w_output(
|
||||||
&api_socket,
|
&api_socket,
|
||||||
"add-disk",
|
"add-disk",
|
||||||
@ -5368,6 +5375,17 @@ mod common_parallel {
|
|||||||
handle_child_output(r, &output);
|
handle_child_output(r, &output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_disk_hotplug() {
|
||||||
|
_test_disk_hotplug(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
fn test_disk_hotplug_with_landlock() {
|
||||||
|
_test_disk_hotplug(true)
|
||||||
|
}
|
||||||
|
|
||||||
fn create_loop_device(backing_file_path: &str, block_size: u32, num_retries: usize) -> String {
|
fn create_loop_device(backing_file_path: &str, block_size: u32, num_retries: usize) -> String {
|
||||||
const LOOP_CONFIGURE: u64 = 0x4c0a;
|
const LOOP_CONFIGURE: u64 = 0x4c0a;
|
||||||
const LOOP_CTL_GET_FREE: u64 = 0x4c82;
|
const LOOP_CTL_GET_FREE: u64 = 0x4c82;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user