-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathvsock.rs
More file actions
44 lines (34 loc) · 1.51 KB
/
vsock.rs
File metadata and controls
44 lines (34 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
use phd_testcase::*;
const GUEST_CID: u64 = 16;
const PCI_DEV_NUM: u8 = 26;
#[phd_testcase]
async fn vsock_smoke_test(ctx: &TestCtx) {
let mut cfg = ctx.vm_config_builder("vsock_smoke_test");
cfg.vsock(GUEST_CID, PCI_DEV_NUM);
let mut vm = ctx.spawn_vm(&cfg, None).await?;
vm.launch().await?;
vm.wait_to_boot().await?;
// This doesn't tell the whole story since linux will sometimes make this
// device available even if the hypervisor does not present the virtio
// device itself. Either way, it would be an error if it's not present.
vm.run_shell_command("test -e /dev/vsock").await?;
}
#[phd_testcase]
async fn vsock_get_cid(ctx: &TestCtx) {
const GET_CID: &str = "/usr/local/bin/getcid";
let mut cfg = ctx.vm_config_builder("vsock_get_cid");
cfg.vsock(GUEST_CID, PCI_DEV_NUM);
let mut vm = ctx.spawn_vm(&cfg, None).await?;
vm.launch().await?;
vm.wait_to_boot().await?;
// If we are not using a modified alpine image with our additional tooling
// we should skip this test entirely.
if vm.run_shell_command(&format!("test -e {GET_CID}")).await.is_err() {
phd_skip!("guest doesn't have getcid installed");
}
let cid = vm.run_shell_command(GET_CID).await?.parse::<u64>()?;
assert_eq!(cid, GUEST_CID, "guest cid matches what was configured");
}