blob: cdd30696cb47355b567aa00e5c02fe8d0b56039c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
//! The `shutdown` sub-command.
use crate::libvirt::{Libvirt, VirtError};
use crate::spec::Specification;
use log::{debug, info};
/// Shut down VMs corresponding to specifications.
pub fn shutdown(specs: &[Specification]) -> Result<(), VirtError> {
let libvirt = Libvirt::connect("qemu:///system")?;
for spec in specs {
info!("shutting down virtual machine {}", spec.name);
libvirt.trigger_shutdown(&spec.name)?;
}
for spec in specs {
debug!("waiting for {} to become inactive", spec.name);
libvirt.wait_for_inactive(&spec.name)?;
}
Ok(())
}
|