patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob fcc7c96a7bba7ed6615e7f2e090d3f19427cc5eb 1985 bytes (raw)
name: tools/start-vmm/tests/vm_command-basic.rs 	 # note: path name is non-authoritative(*)

 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
45
46
47
48
49
50
51
52
53
 
// SPDX-License-Identifier: EUPL-1.2+
// SPDX-FileCopyrightText: 2022-2024 Alyssa Ross <hi@alyssa.is>

use std::fs::{File, create_dir_all};
use std::path::PathBuf;

use start_vmm::vm_config;
use test_helper::TempDir;

fn main() -> std::io::Result<()> {
    let tmp_dir = TempDir::new()?;

    let vm_dir = tmp_dir.path().join("testvm");
    let kernel_path = vm_dir.join("config/vmlinux");
    let image_path = vm_dir.join("config/blk/root.img");

    create_dir_all(kernel_path.parent().unwrap())?;
    create_dir_all(image_path.parent().unwrap())?;
    File::create(&kernel_path)?;
    File::create(&image_path)?;

    let mut config = vm_config(&vm_dir).unwrap();

    assert_eq!(config.console.mode, "Pty");
    assert_eq!(config.disks.len(), 1);
    let disk1 = config.disks.pop().unwrap();
    assert_eq!(PathBuf::from(disk1.path), image_path);
    assert!(disk1.readonly);
    assert_eq!(config.fs.len(), 1);
    let fs1 = &config.fs[0];
    assert_eq!(fs1.tag, "host");
    let expected =
        "/run/service/vm-services/instance/testvm/data/service/vhost-user-fs/env/virtiofsd.sock";
    assert_eq!(fs1.socket, expected);
    assert_eq!(config.generic_vhost_user.len(), 1);
    let gpu1 = &config.generic_vhost_user[0];
    let expected =
        "/run/service/vm-services/instance/testvm/data/service/vhost-user-gpu/env/crosvm.sock";
    assert_eq!(gpu1.socket, expected);
    assert_eq!(PathBuf::from(config.payload.kernel), kernel_path);
    #[cfg(target_arch = "x86_64")]
    assert_eq!(config.payload.cmdline, "console=ttyS0 root=PARTLABEL=root");
    #[cfg(not(target_arch = "x86_64"))]
    assert_eq!(config.payload.cmdline, "root=PARTLABEL=root");
    assert_eq!(config.memory.size, 0x40000000);
    assert!(config.memory.shared);
    assert_eq!(config.serial.mode, "File");
    assert_eq!(config.serial.file.unwrap(), "/run/vm/by-id/testvm/serial");
    assert_eq!(config.vsock.cid, 3);
    assert_eq!(config.vsock.socket, "/run/vsock/testvm/vsock");

    Ok(())
}

debug log:

solving fcc7c96 ...
found fcc7c96 in https://inbox.spectrum-os.org/spectrum-devel/20260708154315.678807-2-hi@alyssa.is/
found 80937ef in https://spectrum-os.org/git/spectrum
preparing index
index prepared:
100644 80937ef1bc961da0edefa7e67c7d2ab7e1837f1f	tools/start-vmm/tests/vm_command-basic.rs

applying [1/1] https://inbox.spectrum-os.org/spectrum-devel/20260708154315.678807-2-hi@alyssa.is/
diff --git a/tools/start-vmm/tests/vm_command-basic.rs b/tools/start-vmm/tests/vm_command-basic.rs
index 80937ef..fcc7c96 100644

Checking patch tools/start-vmm/tests/vm_command-basic.rs...
Applied patch tools/start-vmm/tests/vm_command-basic.rs cleanly.

index at:
100644 fcc7c96a7bba7ed6615e7f2e090d3f19427cc5eb	tools/start-vmm/tests/vm_command-basic.rs

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).