debuggers.hg

changeset 20655:8fbc74d40739

libxenlight: add a cli option to exit right after domain creation

This patch adds a command line option in xl to exit right after domain
creation and not wait in background for the death of the domain.
Users should be aware that if they use this option, they always have
to destroy the domain manually after the guest shuts down.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Dec 11 08:46:02 2009 +0000 (2009-12-11)
parents 9575425fdebd
children b2ccd48f2f9b
files tools/libxl/xl.c
line diff
     1.1 --- a/tools/libxl/xl.c	Fri Dec 11 08:45:26 2009 +0000
     1.2 +++ b/tools/libxl/xl.c	Fri Dec 11 08:46:02 2009 +0000
     1.3 @@ -581,7 +581,7 @@ skip_pci:
     1.4          }                                                               \
     1.5      })
     1.6  
     1.7 -static void create_domain(int debug, const char *config_file, const char *restore_file, int paused)
     1.8 +static void create_domain(int debug, int daemonize, const char *config_file, const char *restore_file, int paused)
     1.9  {
    1.10      struct libxl_ctx ctx;
    1.11      uint32_t domid;
    1.12 @@ -664,6 +664,9 @@ start:
    1.13      if (!paused)
    1.14          libxl_domain_unpause(&ctx, domid);
    1.15  
    1.16 +    if (!daemonize)
    1.17 +        exit(0);
    1.18 +
    1.19      if (need_daemon) {
    1.20          char *fullname, *name;
    1.21  
    1.22 @@ -764,6 +767,7 @@ static void help(char *command)
    1.23          printf("Options:\n\n");
    1.24          printf("-h                     Print this help.\n");
    1.25          printf("-d                     Enable debug messages.\n");
    1.26 +        printf("-e                     Do not wait in the background for the death of the domain.\n");
    1.27      } else if(!strcmp(command, "list")) {
    1.28          printf("Usage: xl list [Domain]\n\n");
    1.29          printf("List information about all/some domains.\n\n");
    1.30 @@ -794,6 +798,7 @@ static void help(char *command)
    1.31          printf("Options:\n\n");
    1.32          printf("-h                     Print this help.\n");
    1.33          printf("-p                     Do not unpause domain after restoring it.\n");
    1.34 +        printf("-e                     Do not wait in the background for the death of the domain.\n");
    1.35      } else if(!strcmp(command, "destroy")) {
    1.36          printf("Usage: xl destroy <Domain>\n\n");
    1.37          printf("Terminate a domain immediately.\n\n");
    1.38 @@ -1259,10 +1264,10 @@ int main_restore(int argc, char **argv)
    1.39  {
    1.40      char *checkpoint_file = NULL;
    1.41      char *config_file = NULL;
    1.42 -    int paused = 0, debug = 0;
    1.43 +    int paused = 0, debug = 0, daemonize = 1;
    1.44      int opt;
    1.45  
    1.46 -    while ((opt = getopt(argc, argv, "hpd")) != -1) {
    1.47 +    while ((opt = getopt(argc, argv, "hpde")) != -1) {
    1.48          switch (opt) {
    1.49          case 'p':
    1.50              paused = 1;
    1.51 @@ -1270,6 +1275,9 @@ int main_restore(int argc, char **argv)
    1.52          case 'd':
    1.53              debug = 1;
    1.54              break;
    1.55 +        case 'e':
    1.56 +            daemonize = 0;
    1.57 +            break;
    1.58          case 'h':
    1.59              help("restore");
    1.60              exit(0);
    1.61 @@ -1286,7 +1294,7 @@ int main_restore(int argc, char **argv)
    1.62  
    1.63      config_file = argv[optind];
    1.64      checkpoint_file = argv[optind + 1];
    1.65 -    create_domain(debug, config_file, checkpoint_file, paused);
    1.66 +    create_domain(debug, daemonize, config_file, checkpoint_file, paused);
    1.67      exit(0);
    1.68  }
    1.69  
    1.70 @@ -1423,14 +1431,17 @@ int main_list(int argc, char **argv)
    1.71  int main_create(int argc, char **argv)
    1.72  {
    1.73      char *filename = NULL;
    1.74 -    int debug = 0;
    1.75 +    int debug = 0, daemonize = 1;
    1.76      int opt;
    1.77  
    1.78 -    while ((opt = getopt(argc, argv, "hd")) != -1) {
    1.79 +    while ((opt = getopt(argc, argv, "hde")) != -1) {
    1.80          switch (opt) {
    1.81          case 'd':
    1.82              debug = 1;
    1.83              break;
    1.84 +        case 'e':
    1.85 +            daemonize = 0;
    1.86 +            break;
    1.87          case 'h':
    1.88              help("create");
    1.89              exit(0);
    1.90 @@ -1446,7 +1457,7 @@ int main_create(int argc, char **argv)
    1.91      }
    1.92  
    1.93      filename = argv[optind];
    1.94 -    create_domain(debug, filename, NULL, 0);
    1.95 +    create_domain(debug, daemonize, filename, NULL, 0);
    1.96      exit(0);
    1.97  }
    1.98