changeset 61:b6e9e473678c

fix console cmd
author AnaTofuZ <anatofuz@gmail.com>
date Fri, 27 Nov 2020 20:20:01 +0900
parents 27bb45204d6d
children aefbef761450
files src/command.rs src/main.rs src/virsh.rs
diffstat 3 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/command.rs	Tue Nov 24 22:09:11 2020 +0900
+++ b/src/command.rs	Fri Nov 27 20:20:01 2020 +0900
@@ -29,7 +29,7 @@
     let vm_name = generate_vm_name(&user_detail.user.name, &vm_name);
     let builder = xml::Builder::new(&user_detail, &vm_name).finalize();
     if let Ok(xml_path) = builder.generate() {
-        virsh::command_require_vm_name(&xml_path, "define")
+        virsh::subshell_virsh_command(&xml_path, "define")
     }
 }
 
@@ -55,21 +55,21 @@
         }
     };
     virsh::generate_qemu_from_template(RENTAL_DIR, &vm_name, &backing_path);
-    virsh::command_require_vm_name(&xml_path, "define");
+    virsh::subshell_virsh_command(&xml_path, "define");
 }
 
 pub fn start(user_name: &str, vm_name: &str) {
-    virsh::command_require_vm_name(&get_vm_name(user_name, vm_name), "start");
+    virsh::subshell_virsh_command(&get_vm_name(user_name, vm_name), "start");
 }
 
 pub fn common(user_name: &str, vm_name: &str, command: &str) {
     let vm_name = exec_cmd_from_name_or_id(user_name, vm_name);
-    virsh::command_require_vm_name(&vm_name, command);
+    virsh::subshell_virsh_command(&vm_name, command);
 }
 
 pub fn console(user_name: &str, vm_name: &str) {
     let vm_name = exec_cmd_from_name_or_id(user_name, vm_name);
-    virsh::exec_virsh_console(&vm_name);
+    virsh::exec_virsh_command(&vm_name, "console");
 }
 
 pub fn dumpvncpasswd(_user_name: &str, _vm_name: &str) {}
--- a/src/main.rs	Tue Nov 24 22:09:11 2020 +0900
+++ b/src/main.rs	Fri Nov 27 20:20:01 2020 +0900
@@ -33,7 +33,7 @@
 /// define the domain in which the gdb port is opened from the template XML file
 #[derive(Clap)]
 struct DefineGDB {
-    name: String,
+    _name: String,
 }
 
 /// define (but don't start) a domain from an template XML file
--- a/src/virsh.rs	Tue Nov 24 22:09:11 2020 +0900
+++ b/src/virsh.rs	Fri Nov 27 20:20:01 2020 +0900
@@ -59,7 +59,7 @@
     )
 }
 
-pub fn command_require_vm_name(vm_name: &str, operation: &str) {
+pub fn subshell_virsh_command(vm_name: &str, operation: &str) {
     let output = Command::new("virsh")
         .arg(operation)
         .arg(vm_name)
@@ -70,8 +70,8 @@
     io::stderr().write_all(&output.stderr).unwrap();
 }
 
-pub fn exec_virsh_console(vm_name: &str) {
-    let err = Command::new("virsh").arg("console").arg(vm_name).exec();
+pub fn exec_virsh_command(vm_name: &str, operation: &str) {
+    let err = Command::new("virsh").arg(operation).arg(vm_name).exec();
     println!("after exec !!{}", err);
 }