8
|
1 use clap::Clap;
|
12
|
2 use ie_virsh::{command, user};
|
1
|
3
|
5
|
4 #[derive(Clap)]
|
7
|
5 #[clap(version = "1.0", author = "AnaTofuZ <anatofuz@cr.ie.u-ryukyu.ac.jp>")]
|
5
|
6 struct Opts {
|
|
7 #[clap(subcommand)]
|
|
8 subcmd: SubCommand,
|
|
9 }
|
|
10
|
|
11 #[derive(Clap)]
|
|
12 enum SubCommand {
|
10
|
13 List(List),
|
|
14 Undefine(UnDefine),
|
|
15 Define(Define),
|
|
16 Shutdown(Shutdown),
|
|
17 Destroy(Destroy),
|
|
18 Console(Console),
|
|
19 Start(Start),
|
|
20 Ttyconsole(TTyConsole),
|
12
|
21 VNCDisplay(VNCDisplay), //todo define-gdb dumpxml
|
5
|
22 }
|
|
23
|
7
|
24 /// define (but don't start) a domain from an template XML file
|
5
|
25 #[derive(Clap)]
|
|
26 struct Define {
|
|
27 name: String,
|
|
28 }
|
|
29
|
11
|
30 // vncdisplay
|
|
31 #[derive(Clap)]
|
|
32 struct VNCDisplay {
|
|
33 name_or_id: String,
|
|
34 }
|
|
35
|
10
|
36 /// undefine a domain
|
|
37 #[derive(Clap)]
|
|
38 struct UnDefine {
|
|
39 name: String,
|
|
40 }
|
|
41
|
|
42 /// start a (previously defined) inactive domain
|
|
43 #[derive(Clap)]
|
|
44 struct Start {
|
|
45 name: String,
|
|
46 }
|
|
47
|
|
48 /// tty console
|
|
49 #[derive(Clap)]
|
|
50 struct TTyConsole {
|
|
51 name_or_id: String,
|
|
52 }
|
|
53
|
7
|
54 /// gracefully shutdown a domain
|
5
|
55 #[derive(Clap)]
|
|
56 struct Shutdown {
|
|
57 name: String,
|
|
58 }
|
|
59
|
7
|
60 /// list domains
|
|
61 #[derive(Clap)]
|
|
62 struct List {}
|
|
63
|
10
|
64 /// destroy (stop) a domain
|
|
65 #[derive(Clap)]
|
|
66 struct Destroy {
|
|
67 name: String,
|
|
68 }
|
|
69
|
|
70 /// connect to the guest console
|
|
71 #[derive(Clap)]
|
|
72 struct Console {
|
|
73 name_or_id: String,
|
|
74 }
|
|
75
|
5
|
76 struct VM {
|
|
77 id: u32,
|
|
78 name: String,
|
|
79 is_vm_running: bool,
|
|
80 }
|
|
81
|
0
|
82 fn main() {
|
7
|
83 let opts: Opts = Opts::parse();
|
|
84
|
12
|
85 let uid = user::getuid();
|
|
86 let gid = user::getgid();
|
|
87 let user_name = user::getlogin(uid);
|
3
|
88 println!("uid: {} gid: {} name: {}", uid, gid, user_name);
|
5
|
89
|
7
|
90 match opts.subcmd {
|
10
|
91 SubCommand::List(_) => {
|
12
|
92 user::set_root_id();
|
|
93 command::list_command(user_name);
|
5
|
94 }
|
10
|
95 SubCommand::Define(name) => {}
|
|
96 SubCommand::Shutdown(name) => {}
|
|
97 SubCommand::Console(name) => {}
|
|
98
|
|
99 SubCommand::Destroy(name_or_id) => {}
|
|
100 _ => {}
|
5
|
101 }
|
|
102
|
|
103 //set_root_id();
|
|
104 //list_command(user_name);
|
0
|
105 }
|
1
|
106
|
6
|
107 fn create_new_vm(user_name: &'static str, vm_name: &'static str, debug_kernel: bool) {}
|