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
| | // SPDX-License-Identifier: EUPL-1.2+
// SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
use std::fs::{create_dir, create_dir_all, File};
use std::os::unix::fs::symlink;
use start_vm::fs::Root;
use start_vm::vm_command;
use test_helper::TempDir;
fn main() -> std::io::Result<()> {
let tmp_dir = TempDir::new().unwrap();
let root = Root::open(tmp_dir.path()).unwrap();
let service_dir = tmp_dir.path().join("testvm");
create_dir(&service_dir).unwrap();
create_dir(tmp_dir.path().join("svc"))?;
create_dir(tmp_dir.path().join("svc/data"))?;
symlink("/config-1/testvm", tmp_dir.path().join("svc/data/testvm"))?;
let vm_config = tmp_dir.path().join("config-1/testvm");
create_dir_all(&vm_config)?;
File::create(vm_config.join("vmlinux"))?;
create_dir(vm_config.join("blk"))?;
symlink("/dev/null", vm_config.join("blk/root.img"))?;
vm_command(service_dir, &root).unwrap();
Ok(())
}
|