Mercurial > hg > Members > anatofuz > ie-virsh
view src/main.rs @ 13:56e9763abeef
define start cmd
author | AnaTofuZ <k198584@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 29 Oct 2020 17:12:09 +0900 |
parents | 0df4d067badb |
children | 5477c26e6984 |
line wrap: on
line source
use clap::Clap; use ie_virsh::{command, user}; #[derive(Clap)] #[clap(version = "1.0", author = "AnaTofuZ <anatofuz@cr.ie.u-ryukyu.ac.jp>")] struct Opts { #[clap(subcommand)] subcmd: SubCommand, } #[derive(Clap)] enum SubCommand { List(List), Undefine(UnDefine), Define(Define), Shutdown(Shutdown), Destroy(Destroy), Console(Console), Start(Start), Ttyconsole(TTyConsole), VNCDisplay(VNCDisplay), //todo define-gdb dumpxml } /// define (but don't start) a domain from an template XML file #[derive(Clap)] struct Define { name: String, } // vncdisplay #[derive(Clap)] struct VNCDisplay { name_or_id: String, } /// undefine a domain #[derive(Clap)] struct UnDefine { name: String, } /// start a (previously defined) inactive domain #[derive(Clap)] struct Start { name: String, } /// tty console #[derive(Clap)] struct TTyConsole { name_or_id: String, } /// gracefully shutdown a domain #[derive(Clap)] struct Shutdown { name: String, } /// list domains #[derive(Clap)] struct List {} /// destroy (stop) a domain #[derive(Clap)] struct Destroy { name: String, } /// connect to the guest console #[derive(Clap)] struct Console { name_or_id: String, } /* struct VM { id: u32, name: String, is_vm_running: bool, } */ fn main() { let opts: Opts = Opts::parse(); let uid = user::getuid(); let gid = user::getgid(); let user_name = user::getlogin(uid); println!("uid: {} gid: {} name: {}", uid, gid, user_name); match opts.subcmd { SubCommand::List(_) => { user::set_root_id(); command::list_command(user_name); } SubCommand::Start(arg) => { user::set_root_id(); command::start_command(user_name, arg.name); } SubCommand::Define(name) => {} SubCommand::Shutdown(name) => {} SubCommand::Console(name) => {} SubCommand::Destroy(name_or_id) => {} _ => {} } //set_root_id(); //list_command(user_name); } fn create_new_vm(user_name: &'static str, vm_name: &'static str, debug_kernel: bool) {}