diff options
author | Roger Pau Monne <roger.pau@citrix.com> | 2012-05-14 16:17:46 +0100 |
---|---|---|
committer | Roger Pau Monne <roger.pau@citrix.com> | 2012-05-14 16:17:46 +0100 |
commit | 688e95c3b338a33c73ae8493c823a98c3ebe7e86 (patch) | |
tree | 39730e74a600627ad577a857cdd45a6f3a9dd3b9 /tools/libxl/xl.c | |
parent | 98e10364bde098e12104caa4f566b17d05f8b791 (diff) | |
download | xen-688e95c3b338a33c73ae8493c823a98c3ebe7e86.tar.gz xen-688e95c3b338a33c73ae8493c823a98c3ebe7e86.tar.bz2 xen-688e95c3b338a33c73ae8493c823a98c3ebe7e86.zip |
libxl: prevent xl from doing operations on domains if xend is running
Prevent xl from doing any operation if xend daemon is running. That
prevents bugs that happened when xl and xend raced to close a domain.
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-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.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c index d4db1f8b8b..750a61c54c 100644 --- a/tools/libxl/xl.c +++ b/tools/libxl/xl.c @@ -32,8 +32,11 @@ #include "libxlutil.h" #include "xl.h" +#define XEND_LOCK { "/var/lock/subsys/xend", "/var/lock/xend" } + xentoollog_logger_stdiostream *logger; int dryrun_only; +int force_execution; int autoballoon = 1; char *lockfile; char *default_vifscript = NULL; @@ -126,8 +129,9 @@ int main(int argc, char **argv) char *config_file; void *config_data = 0; int config_len = 0; + const char *locks[] = XEND_LOCK; - while ((opt = getopt(argc, argv, "+vN")) >= 0) { + while ((opt = getopt(argc, argv, "+vfN")) >= 0) { switch (opt) { case 'v': if (minmsglevel > 0) minmsglevel--; @@ -135,6 +139,9 @@ int main(int argc, char **argv) case 'N': dryrun_only = 1; break; + case 'f': + force_execution = 1; + break; default: fprintf(stderr, "unknown global option\n"); exit(2); @@ -185,6 +192,19 @@ int main(int argc, char **argv) ret = 1; goto xit; } + if (cspec->modifies && !dryrun_only) { + for (int i = 0; i < sizeof(locks)/sizeof(locks[0]); i++) { + if (!access(locks[i], F_OK) && !force_execution) { + fprintf(stderr, +"xend is running, which prevents xl from working correctly.\n" +"If you still want to force the execution of xl please use the -f\n" +"option.\n" + ); + ret = 1; + goto xit; + } + } + } ret = cspec->cmd_impl(argc, argv); } else if (!strcmp(cmd, "help")) { help(argv[1]); |