aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/xl.c
diff options
context:
space:
mode:
authorIan Jackson <ian.jackson@eu.citrix.com>2011-06-28 12:19:15 +0100
committerIan Jackson <ian.jackson@eu.citrix.com>2011-06-28 12:19:15 +0100
commit4369b25867a0a05aa0b1e89d3c3ab1e942b4daeb (patch)
tree5a372be09b2c18caa1c39123cce007ccfd6f72f5 /tools/libxl/xl.c
parent74f917afa34d2e2699fc9fee7fe43c3fe81768ae (diff)
downloadxen-4369b25867a0a05aa0b1e89d3c3ab1e942b4daeb.tar.gz
xen-4369b25867a0a05aa0b1e89d3c3ab1e942b4daeb.tar.bz2
xen-4369b25867a0a05aa0b1e89d3c3ab1e942b4daeb.zip
xl: new global -N option for dry run
This sets a global dryrun_only variable, which individual commands are expected to honour. To avoid accidents, we introduce a new can_dryrun member in the command table, which is initially set to 0 for each command. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/xl.c')
-rw-r--r--tools/libxl/xl.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index 5bab2ff1b8..1f231a83c2 100644
--- a/tools/libxl/xl.c
+++ b/tools/libxl/xl.c
@@ -34,6 +34,7 @@
#include "xl.h"
xentoollog_logger_stdiostream *logger;
+int dryrun_only;
int autoballoon = 1;
char *lockfile;
char *default_vifscript = NULL;
@@ -90,11 +91,14 @@ int main(int argc, char **argv)
void *config_data = 0;
int config_len = 0;
- while ((opt = getopt(argc, argv, "+v")) >= 0) {
+ while ((opt = getopt(argc, argv, "+vN")) >= 0) {
switch (opt) {
case 'v':
if (minmsglevel > 0) minmsglevel--;
break;
+ case 'N':
+ dryrun_only = 1;
+ break;
default:
fprintf(stderr, "unknown global option\n");
exit(2);
@@ -138,9 +142,14 @@ int main(int argc, char **argv)
optind = 1;
cspec = cmdtable_lookup(cmd);
- if (cspec)
+ if (cspec) {
+ if (dryrun_only && !cspec->can_dryrun) {
+ fprintf(stderr, "command does not implement -N (dryrun) option\n");
+ ret = 1;
+ goto xit;
+ }
ret = cspec->cmd_impl(argc, argv);
- else if (!strcmp(cmd, "help")) {
+ } else if (!strcmp(cmd, "help")) {
help(argv[1]);
ret = 0;
} else {
@@ -148,8 +157,8 @@ int main(int argc, char **argv)
ret = 1;
}
+ xit:
libxl_ctx_free(ctx);
xtl_logger_destroy((xentoollog_logger*)logger);
-
return ret;
}