debuggers.hg

view tools/libxl/xl_cmdtable.c @ 21947:9f49667fec71

xl: remove duplicate -d option from create help message

Signed-off-by: Zhigang Wang <zhigang.x.wang@oracle.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Zhigang Wang <zhigang.x.wang@oracle.com>
date Fri Jul 30 15:22:39 2010 +0100 (2010-07-30)
parents 9ced33b68bd8
children 8500a5eb41af
line source
1 /*
2 * Author Yang Hongyang <yanghy@cn.fujitsu.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation; version 2.1 only. with the special
7 * exception on linking described in file LICENSE.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 */
15 #include <string.h>
17 #include "libxl.h"
18 #include "xl.h"
20 struct cmd_spec cmd_table[] = {
21 { "create",
22 &main_create,
23 "Create a domain from config file <filename>",
24 "<ConfigFile> [options] [vars]",
25 "-h Print this help.\n"
26 "-p Leave the domain paused after it is created.\n"
27 "-c Connect to the console after the domain is created.\n"
28 "-f=FILE, --defconfig=FILE\n Use the given configuration file.\n"
29 "-q, --quiet Quiet.\n"
30 "-n, --dryrun Dry run - prints the resulting configuration.\n"
31 "-d Enable debug messages.\n"
32 "-e Do not wait in the background for the death of the domain."
33 },
34 { "list",
35 &main_list,
36 "List information about all/some domains",
37 "[options] [Domain]\n",
38 "-l, --long Output all VM details"
39 "-v, --verbose Prints out UUIDs",
40 },
41 { "destroy",
42 &main_destroy,
43 "Terminate a domain immediately",
44 "<Domain>",
45 },
46 { "shutdown",
47 &main_shutdown,
48 "Issue a shutdown signal to a domain",
49 "<Domain>",
50 },
51 { "reboot",
52 &main_reboot,
53 "Issue a reboot signal to a domain",
54 "<Domain>",
55 },
56 { "pci-attach",
57 &main_pciattach,
58 "Insert a new pass-through pci device",
59 "<Domain> <BDF> [Virtual Slot]",
60 },
61 { "pci-detach",
62 &main_pcidetach,
63 "Remove a domain's pass-through pci device",
64 "<Domain> <BDF>",
65 },
66 { "pci-list",
67 &main_pcilist,
68 "List pass-through pci devices for a domain",
69 "<Domain>",
70 },
71 { "pci-list-assignable-devices",
72 &main_pcilist_assignable,
73 "List all the assignable pci devices",
74 "",
75 },
76 { "pause",
77 &main_pause,
78 "Pause execution of a domain",
79 "<Domain>",
80 },
81 { "unpause",
82 &main_unpause,
83 "Unpause a paused domain",
84 "<Domain>",
85 },
86 { "console",
87 &main_console,
88 "Attach to domain's console",
89 "<Domain>",
90 },
91 { "vncviewer",
92 &main_vncviewer,
93 "Attach to domain's VNC server.",
94 "[options] <Domain>\n"
95 "--autopass Pass VNC password to viewer via stdin and\n"
96 " -autopass\n"
97 "--vncviewer-autopass (consistency alias for --autopass)"
98 },
99 { "save",
100 &main_save,
101 "Save a domain state to restore later",
102 "[options] <Domain> <CheckpointFile> [<ConfigFile>]",
103 "-h Print this help.\n"
104 "-c Leave domain running after creating the snapshot."
105 },
106 { "migrate",
107 &main_migrate,
108 "Save a domain state to restore later",
109 "[options] <Domain> <host>",
110 "-h Print this help.\n"
111 "-C <config> Send <config> instead of config file from creation.\n"
112 "-s <sshcommand> Use <sshcommand> instead of ssh. String will be passed\n"
113 " to sh. If empty, run <host> instead of ssh <host> xl\n"
114 " migrate-receive [-d -e]\n"
115 "-e Do not wait in the background (on <host>) for the death\n"
116 " of the domain."
117 },
118 { "dump-core",
119 &main_dump_core,
120 "Core dump a domain",
121 "<Domain> <filename>"
122 },
123 { "restore",
124 &main_restore,
125 "Restore a domain from a saved state",
126 "[options] [<ConfigFile>] <CheckpointFile>",
127 "-h Print this help.\n"
128 "-p Do not unpause domain after restoring it.\n"
129 "-e Do not wait in the background for the death of the domain.\n"
130 "-d Enable debug messages."
131 },
132 { "migrate-receive",
133 &main_migrate_receive,
134 "Restore a domain from a saved state",
135 "- for internal use only",
136 },
137 { "cd-insert",
138 &main_cd_insert,
139 "Insert a cdrom into a guest's cd drive",
140 "<Domain> <VirtualDevice> <type:path>",
141 },
142 { "cd-eject",
143 &main_cd_eject,
144 "Eject a cdrom from a guest's cd drive",
145 "<Domain> <VirtualDevice>",
146 },
147 { "mem-max",
148 &main_memmax,
149 "Set the maximum amount reservation for a domain",
150 "<Domain> <MemMB['b'[bytes]|'k'[KB]|'m'[MB]|'g'[GB]|'t'[TB]]>",
151 },
152 { "mem-set",
153 &main_memset,
154 "Set the current memory usage for a domain",
155 "<Domain> <MemMB['b'[bytes]|'k'[KB]|'m'[MB]|'g'[GB]|'t'[TB]]>",
156 },
157 { "button-press",
158 &main_button_press,
159 "Indicate an ACPI button press to the domain",
160 "<Domain> <Button>",
161 "<Button> may be 'power' or 'sleep'."
162 },
163 { "vcpu-list",
164 &main_vcpulist,
165 "List the VCPUs for all/some domains",
166 "[Domain, ...]",
167 },
168 { "vcpu-pin",
169 &main_vcpupin,
170 "Set which CPUs a VCPU can use",
171 "<Domain> <VCPU|all> <CPUs|all>",
172 },
173 { "vcpu-set",
174 &main_vcpuset,
175 "Set the number of active VCPUs allowed for the domain",
176 "<Domain> <vCPUs>",
177 },
178 { "list-vm",
179 &main_list_vm,
180 "List the VMs,without DOM0",
181 "",
182 },
183 { "info",
184 &main_info,
185 "Get information about Xen host",
186 "",
187 },
188 { "sched-credit",
189 &main_sched_credit,
190 "Get/set credit scheduler parameters",
191 "[-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]",
192 "-d DOMAIN, --domain=DOMAIN Domain to modify\n"
193 "-w WEIGHT, --weight=WEIGHT Weight (int)\n"
194 "-c CAP, --cap=CAP Cap (int)"
195 },
196 { "domid",
197 &main_domid,
198 "Convert a domain name to domain id",
199 "<DomainName>",
200 },
201 { "domname",
202 &main_domname,
203 "Convert a domain id to domain name",
204 "<DomainId>",
205 },
206 { "rename",
207 &main_rename,
208 "Rename a domain",
209 "<Domain> <NewDomainName>",
210 },
211 { "trigger",
212 &main_trigger,
213 "Send a trigger to a domain",
214 "<Domain> <nmi|reset|init|power|sleep> [<VCPU>]",
215 },
216 { "sysrq",
217 &main_sysrq,
218 "Send a sysrq to a domain",
219 "<Domain> <letter>",
220 },
221 { "debug-keys",
222 &main_debug_keys,
223 "Send debug keys to Xen",
224 "<Keys>",
225 },
226 { "dmesg",
227 &main_dmesg,
228 "Read and/or clear dmesg buffer",
229 "[-c]",
230 " -c Clear dmesg buffer as well as printing it",
231 },
232 { "top",
233 &main_top,
234 "Monitor a host and the domains in real time",
235 "",
236 },
237 { "network-attach",
238 &main_networkattach,
239 "Create a new virtual network device",
240 "<Domain> [type=<type>] [mac=<mac>] [bridge=<bridge>] "
241 "[ip=<ip>] [script=<script>] [backend=<BackDomain>] [vifname=<name>] "
242 "[rate=<rate>] [model=<model>][accel=<accel>]",
243 },
244 { "network-list",
245 &main_networklist,
246 "List virtual network interfaces for a domain",
247 "<Domain(s)>",
248 },
249 { "network-detach",
250 &main_networkdetach,
251 "Destroy a domain's virtual network device",
252 "<Domain> <DevId|mac>",
253 },
254 { "block-attach",
255 &main_blockattach,
256 "Create a new virtual block device",
257 "<Domain> <BackDev> <FrontDev> [<Mode>] [BackDomain]",
258 },
259 { "block-list",
260 &main_blocklist,
261 "List virtual block devices for a domain",
262 "<Domain(s)>",
263 },
264 { "block-detach",
265 &main_blockdetach,
266 "Destroy a domain's virtual block device",
267 "<Domain> <DevId>",
268 },
269 { "uptime",
270 &main_uptime,
271 "Print uptime for all/some domains",
272 "[-s] [Domain]",
273 },
274 { "tmem-list",
275 &main_tmem_list,
276 "List tmem pools",
277 "[-l] [<Domain>|-a]",
278 " -l List tmem stats",
279 },
280 { "tmem-freeze",
281 &main_tmem_freeze,
282 "Freeze tmem pools",
283 "[<Domain>|-a]",
284 " -a Freeze all tmem",
285 },
286 { "tmem-destroy",
287 &main_tmem_destroy,
288 "Destroy tmem pools",
289 "[<Domain>|-a]",
290 " -a Destroy all tmem",
291 },
292 { "tmem-thaw",
293 &main_tmem_thaw,
294 "Thaw tmem pools",
295 "[<Domain>|-a]",
296 " -a Thaw all tmem",
297 },
298 { "tmem-set",
299 &main_tmem_set,
300 "Change tmem settings",
301 "[<Domain>|-a] [-w[=WEIGHT]|-c[=CAP]|-p[=COMPRESS]]",
302 " -a Operate on all tmem\n"
303 " -w WEIGHT Weight (int)\n"
304 " -c CAP Cap (int)\n"
305 " -p COMPRESS Compress (int)",
306 },
307 { "tmem-shared-auth",
308 &main_tmem_shared_auth,
309 "De/authenticate shared tmem pool",
310 "[<Domain>|-a] [-u[=UUID] [-A[=AUTH]",
311 " -a Authenticate for all tmem pools\n"
312 " -u UUID Specify uuid\n"
313 " (abcdef01-2345-6789-1234-567890abcdef)\n"
314 " -A AUTH 0=auth,1=deauth",
315 },
316 { "tmem-freeable",
317 &main_tmem_freeable,
318 "Get information about how much freeable memory (MB) is in-use by tmem",
319 "",
320 },
321 { "network2-attach",
322 &main_network2attach,
323 "Create a new version 2 virtual network device",
324 "<Domain> [front_mac=<mac>] [back_mac=<mac>] [backend=<BackDomain>]"
325 " [trusted=<0|1>] [back_trusted=<0|1>] [bridge=<bridge>]"
326 " [filter_mac=<0|1>] [front_filter_mac=<0|1>] [pdev=<PDEV>]"
327 " [max_bypasses=n]",
328 },
329 { "network2-list",
330 &main_network2list,
331 "list version 2 virtual network interfaces for a domain",
332 "<Domain(s)>",
333 },
334 { "network2-detach",
335 &main_network2detach,
336 "destroy a domain's version 2 virtual network device",
337 "<Domain> <DevId>",
338 },
339 };
341 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
343 /* Look up a command in the table, allowing unambiguous truncation */
344 struct cmd_spec *cmdtable_lookup(const char *s)
345 {
346 struct cmd_spec *cmd = NULL;
347 size_t len;
348 int i, count = 0;
350 if (!s)
351 return NULL;
352 len = strlen(s);
353 for (i = 0; i < cmdtable_len; i++) {
354 if (!strncmp(s, cmd_table[i].cmd_name, len)) {
355 cmd = &cmd_table[i];
356 /* Take an exact match, even if it also prefixes another command */
357 if (len == strlen(cmd->cmd_name))
358 return cmd;
359 count++;
360 }
361 }
362 return (count == 1) ? cmd : NULL;
363 }