Mercurial > hg > Members > anatofuz > ie-virsh
changeset 18:9b24d6767a2f
define other command
author | AnaTofuZ <k198584@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 02 Nov 2020 18:59:52 +0900 |
parents | 5477c26e6984 |
children | d37203a877d9 |
files | src/command.rs src/main.rs |
diffstat | 2 files changed, 31 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/command.rs Mon Nov 02 16:09:53 2020 +0900 +++ b/src/command.rs Mon Nov 02 18:59:52 2020 +0900 @@ -29,6 +29,19 @@ exec_cmd_from_name_or_id(user_name, &vm_name, "vncdisplay") } +pub fn ttyconsole(user_name: &'static str, vm_name: String) { + exec_cmd_from_name_or_id(user_name, &vm_name, "ttyconsole") +} + +pub fn dumpxml(user_name: &'static str, vm_name: String) { + exec_cmd_from_name_or_id(user_name, &vm_name, "dumpxml") +} + +pub fn undefine(user_name: &'static str, vm_name: String) { + exec_cmd_from_name_or_id(user_name, &vm_name, "undefine") +} + + fn exec_cmd_from_name_or_id(user_name: &'static str, name_or_id: &str, command: &str) { if name_or_id.parse::<u8>().is_ok() { let vm_name_or_none = get_vm_name_from_id(user_name, &name_or_id);
--- a/src/main.rs Mon Nov 02 16:09:53 2020 +0900 +++ b/src/main.rs Mon Nov 02 18:59:52 2020 +0900 @@ -38,7 +38,7 @@ /// domain information in XML #[derive(Clap)] struct DumpXML { - name_or_id: String, + name: String, } /// vncdisplay @@ -87,14 +87,6 @@ name: String, } -/* -struct VM { - id: u32, - name: String, - is_vm_running: bool, -} -*/ - fn main() { let opts: Opts = Opts::parse(); @@ -113,6 +105,7 @@ user::set_root_id(); command::start(user_name, arg.name); } + SubCommand::Define(name) => {} SubCommand::Shutdown(arg) => { @@ -135,11 +128,24 @@ command::vncdisplay(user_name, arg.name); } + SubCommand::Ttyconsole(arg) => { + user::set_root_id(); + command::ttyconsole(user_name, arg.name); + } + + SubCommand::DumpXML(arg) => { + user::set_root_id(); + command::ttyconsole(user_name, arg.name); + } + + SubCommand::Undefine(arg) => { + user::set_root_id(); + command::undefine(user_name, arg.name); + } + _ => {} } //set_root_id(); //list_command(user_name); -} - -fn create_new_vm(user_name: &'static str, vm_name: &'static str, debug_kernel: bool) {} +} \ No newline at end of file