blob: b53ebd3912a3e2afc525dde8f2dccc1a87da9331 (
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.shutdown(&spec.name)?;
}
for spec in specs {
debug!("waiting for {} to become inactive", spec.name);
libvirt.wait_for_inactive(&spec.name)?;
}
Ok(())
}
|