diff options
author | Alyssa Ross <hi@alyssa.is> | 2022-10-10 23:28:42 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-02-26 15:58:59 +0000 |
commit | 3664233d0f702e7f1c8ba0ae939e097735f87714 (patch) | |
tree | d2a60b879e031e12a22f1d1615a04c7347b1dd18 /host/start-vm/lib.rs | |
parent | c85b5d529a6d4ab28a93aa1e9b3f3f6459daca50 (diff) | |
download | spectrum-3664233d0f702e7f1c8ba0ae939e097735f87714.tar spectrum-3664233d0f702e7f1c8ba0ae939e097735f87714.tar.gz spectrum-3664233d0f702e7f1c8ba0ae939e097735f87714.tar.bz2 spectrum-3664233d0f702e7f1c8ba0ae939e097735f87714.tar.lz spectrum-3664233d0f702e7f1c8ba0ae939e097735f87714.tar.xz spectrum-3664233d0f702e7f1c8ba0ae939e097735f87714.tar.zst spectrum-3664233d0f702e7f1c8ba0ae939e097735f87714.zip |
host/start-vm: implement shared directories
Signed-off-by: Alyssa Ross <hi@alyssa.is> Message-Id: <20221010232909.1953738-3-hi@alyssa.is>
Diffstat (limited to 'host/start-vm/lib.rs')
-rw-r--r-- | host/start-vm/lib.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/host/start-vm/lib.rs b/host/start-vm/lib.rs index 9a92ab7..3959566 100644 --- a/host/start-vm/lib.rs +++ b/host/start-vm/lib.rs @@ -112,6 +112,32 @@ pub fn vm_command(dir: PathBuf, config_root: &Path) -> Result<Command, String> { return Err("no block devices specified".to_string()); } + let shared_dirs_dir = config_dir.join("shared-dirs"); + match shared_dirs_dir.read_dir().map(Iterator::peekable) { + Ok(mut entries) => { + if entries.peek().is_some() { + command.arg("--fs"); + } + + for result in entries { + let entry = result + .map_err(|e| format!("examining directory entry: {}", e))? + .file_name(); + + let mut arg = OsString::from("tag="); + arg.push(&entry); + arg.push(",socket=../"); + arg.push(vm_name); + arg.push("-fs-"); + arg.push(&entry); + arg.push("/env/virtiofsd.sock"); + command.arg(arg); + } + } + Err(e) if e.kind() == ErrorKind::NotFound => {} + Err(e) => return Err(format!("reading directory {:?}: {}", shared_dirs_dir, e)), + } + command.arg("--serial").arg({ let mut serial = OsString::from("file=/run/"); serial.push(&vm_name); |