diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-03-13 14:51:19 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-03-14 09:11:07 +0200 |
commit | b8119579a246727805a03c5a8e60fb44109410f6 (patch) | |
tree | b4e0698ae9f50b8757530f2332cb1c40872d4a5c /src/install.rs | |
parent | d4cba41b5674e6ca1cbd5669aeb42d5f7d62e8bd (diff) | |
download | vmadm-b8119579a246727805a03c5a8e60fb44109410f6.tar.gz |
fix: VMs can be restarted
Previously, the temporary file for the cloud-init configuration ISO
was left attached to the VM. This meant the VM couldn't be turned off
and back on again: the temporary no longer existed.
Now we detach the ISO file after the VM has booted.
As a side effect, vmadm has gained start and shutdown subcommands, so
that the fix can be tested.
Diffstat (limited to 'src/install.rs')
-rw-r--r-- | src/install.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/install.rs b/src/install.rs index 7506e0d..dce0fea 100644 --- a/src/install.rs +++ b/src/install.rs @@ -6,9 +6,9 @@ use crate::cloudinit::{CloudInitConfig, CloudInitError}; use crate::image::VirtualMachineImage; +use std::path::{Path, PathBuf}; use std::process::Command; use std::result::Result; -use tempfile::tempdir; /// Errors from this module #[derive(Debug, thiserror::Error)] @@ -91,9 +91,7 @@ impl VirtInstallArgs { } /// Create new VM with virt-install. -pub fn virt_install(args: &VirtInstallArgs) -> Result<(), VirtInstallError> { - let dir = tempdir()?; - let iso = dir.path().join("cloudinit.iso"); +pub fn virt_install(args: &VirtInstallArgs, iso: &Path) -> Result<PathBuf, VirtInstallError> { args.init().create_iso(&iso)?; let r = Command::new("virt-install") @@ -122,5 +120,5 @@ pub fn virt_install(args: &VirtInstallArgs) -> Result<(), VirtInstallError> { let stderr = String::from_utf8(r.stderr)?; return Err(VirtInstallError::VirtInstallFailed(stderr)); } - Ok(()) + Ok(iso.to_path_buf()) } |