summaryrefslogtreecommitdiff
path: root/src/cmd/list.rs
blob: ff506a695aac6a30eb6003ea0b7ab20bbd9dd89d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! The `list` sub-command.

use crate::config::Configuration;
use crate::libvirt::{Libvirt, VirtError};
use crate::progress::Progress;

/// The `list` sub-command.
///
/// Return the names of all the virtual machines existing on the
/// libvirt instance.
pub fn list(_config: &Configuration, progress: &Progress) -> Result<(), VirtError> {
    progress.chatty("listing virtual machines");
    let libvirt = Libvirt::connect("qemu:///system")?;
    let mut names = libvirt.names()?;
    names.sort();
    for name in names {
        println!("{}", name);
    }
    Ok(())
}