Goncalo Gomes
2012-May-15 02:39 UTC
[PATCH 0 of 2 v2] Add vncviewer xm compatibility options
Changes since v1: - Removed libxl vncviewer related dependencies - The vncviewer function was modified to accept a domid instead of domspec; - main_vncviewer was updated to reflect the new use. - A domain_create structure is now passed to the parse_config_data where required/feasible (NULL otherwise) - xl restore now have long options for vncviewer/vncviewer-autopass; docs updated. - Updated vnc logic to depend on create_domain tools/libxl/xl_cmdimpl.c | 50 ++++++++++++++++--------------- docs/man/xl.cfg.pod.5 | 4 ++ docs/man/xl.pod.1 | 18 +++++++++++ tools/libxl/xl_cmdimpl.c | 73 ++++++++++++++++++++++++++++++++++++++-------- tools/libxl/xl_cmdtable.c | 15 ++++++--- 5 files changed, 118 insertions(+), 42 deletions(-)
Goncalo Gomes
2012-May-15 02:39 UTC
[PATCH 1 of 2 v2] xl: code motion of vncviewer() and `struct domain_create`
tools/libxl/xl_cmdimpl.c | 50 ++++++++++++++++++++++++----------------------- 1 files changed, 26 insertions(+), 24 deletions(-) Signed-off-by: Goncalo Gomes <Goncalo.Gomes@EU.CITRIX.COM> diff -r cd4dd23a831d -r 380d5f86dfdd tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Fri May 11 18:59:07 2012 +0100 +++ b/tools/libxl/xl_cmdimpl.c Tue May 15 02:26:51 2012 +0000 @@ -120,6 +120,24 @@ static const char *action_on_shutdown_na #define SAVEFILE_BYTEORDER_VALUE ((uint32_t)0x01020304UL) +struct domain_create { + int debug; + int daemonize; + int monitor; /* handle guest reboots etc */ + int paused; + int dryrun; + int quiet; + int console_autoconnect; + const char *config_file; + const char *extra_config; /* extra config string */ + const char *restore_file; + int migrate_fd; /* -1 means none */ + char **migration_domname_r; /* from malloc */ + int incr_generationid; +}; + + + static int qualifier_to_id(const char *p, uint32_t *id_r) { int i, alldigit; @@ -186,6 +204,14 @@ static void find_domain(const char *p) common_domname = was_name ? p : libxl_domid_to_name(ctx, domid); } +static int vncviewer(const char *domain_spec, int autopass) +{ + find_domain(domain_spec); + libxl_vncviewer_exec(ctx, domid, autopass); + fprintf(stderr, "Unable to execute vncviewer\n"); + return 1; +} + static int acquire_lock(void) { int rc; @@ -1399,22 +1425,6 @@ static int preserve_domain(libxl_ctx *ct return rc == 0 ? 1 : 0; } -struct domain_create { - int debug; - int daemonize; - int monitor; /* handle guest reboots etc */ - int paused; - int dryrun; - int quiet; - int console_autoconnect; - const char *config_file; - const char *extra_config; /* extra config string */ - const char *restore_file; - int migrate_fd; /* -1 means none */ - char **migration_domname_r; /* from malloc */ - int incr_generationid; -}; - static int freemem(libxl_domain_build_info *b_info) { int rc, retries = 3; @@ -2175,14 +2185,6 @@ int main_console(int argc, char **argv) return 1; } -static int vncviewer(const char *domain_spec, int autopass) -{ - find_domain(domain_spec); - libxl_vncviewer_exec(ctx, domid, autopass); - fprintf(stderr, "Unable to execute vncviewer\n"); - return 1; -} - int main_vncviewer(int argc, char **argv) { static const struct option long_options[] = {
Goncalo Gomes
2012-May-15 02:39 UTC
[PATCH 2 of 2 v2] Introduce vncviewer xm compatibility options
docs/man/xl.cfg.pod.5 | 4 ++ docs/man/xl.pod.1 | 18 +++++++++++ tools/libxl/xl_cmdimpl.c | 73 ++++++++++++++++++++++++++++++++++++++-------- tools/libxl/xl_cmdtable.c | 15 ++++++--- 4 files changed, 92 insertions(+), 18 deletions(-) Signed-off-by: Goncalo Gomes <Goncalo.Gomes@EU.CITRIX.COM> diff -r 380d5f86dfdd -r d1c195e989cc docs/man/xl.cfg.pod.5 --- a/docs/man/xl.cfg.pod.5 Tue May 15 02:26:51 2012 +0000 +++ b/docs/man/xl.cfg.pod.5 Tue May 15 02:26:53 2012 +0000 @@ -91,6 +91,10 @@ The following options apply to guests of Specifies the UUID of the domain. If not specified, a fresh unique UUID will be generated. +=item B<vncviewer=BOOLEAN> + +Automatically spawn a vncviewer when creating/restoring a guest + =item B<pool="CPUPOOLNAME"> Put the guest''s vcpus into the named cpu pool. diff -r 380d5f86dfdd -r d1c195e989cc docs/man/xl.pod.1 --- a/docs/man/xl.pod.1 Tue May 15 02:26:51 2012 +0000 +++ b/docs/man/xl.pod.1 Tue May 15 02:26:53 2012 +0000 @@ -120,6 +120,14 @@ Use the given configuration file. Leave the domain paused after it is created. +=item B<-V>, B<--vncviewer> + +Attach to domain''s VNC server, forking a vncviewer process. + +=item B<-A>, B<--vncviewer-autopass> + +Pass VNC password to vncviewer via stdin. + =item B<-c> Attach console to the domain as soon as it has started. This is @@ -433,6 +441,16 @@ See the corresponding option of the I<cr Enable debug messages. +=item B<-V>, B<--vncviewer> + +Attach to domain''s VNC server, forking a vncviewer process. + +=item B<-A>, B<--vncviewer-autopass> + +Pass VNC password to vncviewer via stdin. + + + =back =item B<save> [I<OPTIONS>] I<domain-id> I<CheckpointFile> [I<ConfigFile>] diff -r 380d5f86dfdd -r d1c195e989cc tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Tue May 15 02:26:51 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Tue May 15 02:26:53 2012 +0000 @@ -127,6 +127,8 @@ struct domain_create { int paused; int dryrun; int quiet; + int vnc; + int vncautopass; int console_autoconnect; const char *config_file; const char *extra_config; /* extra config string */ @@ -204,9 +206,8 @@ static void find_domain(const char *p) common_domname = was_name ? p : libxl_domid_to_name(ctx, domid); } -static int vncviewer(const char *domain_spec, int autopass) +static int vncviewer(uint32_t domid, int autopass) { - find_domain(domain_spec); libxl_vncviewer_exec(ctx, domid, autopass); fprintf(stderr, "Unable to execute vncviewer\n"); return 1; @@ -549,7 +550,9 @@ vcpp_out: static void parse_config_data(const char *configfile_filename_report, const char *configfile_data, int configfile_len, - libxl_domain_config *d_config) + libxl_domain_config *d_config, + struct domain_create *dom_info) + { const char *buf; long l; @@ -754,6 +757,13 @@ static void parse_config_data(const char if (!xlu_cfg_get_long(config, "rtc_timeoffset", &l, 0)) b_info->rtc_timeoffset = l; + if (dom_info && !xlu_cfg_get_long(config, "vncviewer", &l, 0)) { + /* Command line arguments must take precedence over what''s + * specified in the configuration file. */ + if (!dom_info->vnc) + dom_info->vnc = l; + } + xlu_cfg_get_defbool(config, "localtime", &b_info->localtime, 0); if (!xlu_cfg_get_long (config, "videoram", &l, 0)) @@ -1531,6 +1541,7 @@ static int create_domain(struct domain_c int daemonize = dom_info->daemonize; int monitor = dom_info->monitor; int paused = dom_info->paused; + int vncautopass = dom_info->vncautopass; const char *config_file = dom_info->config_file; const char *extra_config = dom_info->extra_config; const char *restore_file = dom_info->restore_file; @@ -1654,7 +1665,7 @@ static int create_domain(struct domain_c if (!dom_info->quiet) printf("Parsing config file %s\n", config_file); - parse_config_data(config_file, config_data, config_len, &d_config); + parse_config_data(config_file, config_data, config_len, &d_config, dom_info); if (migrate_fd >= 0) { if (d_config.c_info.name) { @@ -1741,6 +1752,9 @@ start: if (!daemonize && !monitor) goto out; + if (dom_info->vnc) + vncviewer(domid, vncautopass); + if (need_daemon) { char *fullname, *name; pid_t child1, got_child; @@ -1867,7 +1881,7 @@ start: libxl_domain_config_dispose(&d_config); libxl_domain_config_init(&d_config); parse_config_data(config_file, config_data, config_len, - &d_config); + &d_config, dom_info); /* * XXX FIXME: If this sleep is not there then domain @@ -2218,7 +2232,9 @@ int main_vncviewer(int argc, char **argv return 2; } - if (vncviewer(argv[optind], autopass)) + find_domain(argv[optind]); + + if (vncviewer(domid, autopass)) return 1; return 0; } @@ -2493,7 +2509,7 @@ static void list_domains_details(const l continue; CHK_ERRNO(asprintf(&config_file, "<domid %d data>", info[i].domid)); libxl_domain_config_init(&d_config); - parse_config_data(config_file, (char *)data, len, &d_config); + parse_config_data(config_file, (char *)data, len, &d_config, NULL); printf_info(default_output_format, info[i].domid, &d_config); libxl_domain_config_dispose(&d_config); free(data); @@ -3043,13 +3059,26 @@ int main_restore(int argc, char **argv) const char *config_file = NULL; struct domain_create dom_info; int paused = 0, debug = 0, daemonize = 1, monitor = 1, - console_autoconnect = 0; + console_autoconnect = 0, vnc = 0, vncautopass = 0; int opt, rc; - - while ((opt = def_getopt(argc, argv, "Fcpde", "restore", 1)) != -1) { + int option_index = 0; + static struct option long_options[] = { + {"vncviewer", 0, 0, ''V''}, + {"vncviewer-autopass", 0, 0, ''A''}, + {0, 0, 0, 0} + }; + + while (1) { + opt = getopt_long(argc, argv, "FhcpdeVA", long_options, &option_index); + if (opt == -1) + break; + switch (opt) { case 0: case 2: return opt; + case ''h'': + help("restore"); + return 2; case ''c'': console_autoconnect = 1; break; @@ -3066,6 +3095,12 @@ int main_restore(int argc, char **argv) daemonize = 0; monitor = 0; break; + case ''V'': + vnc = 1; + break; + case ''A'': + vnc = vncautopass = 1; + break; } } @@ -3087,6 +3122,8 @@ int main_restore(int argc, char **argv) dom_info.config_file = config_file; dom_info.restore_file = checkpoint_file; dom_info.migrate_fd = -1; + dom_info.vnc = vnc; + dom_info.vncautopass = vncautopass; dom_info.console_autoconnect = console_autoconnect; dom_info.incr_generationid = 1; @@ -3394,7 +3431,7 @@ int main_create(int argc, char **argv) char extra_config[1024]; struct domain_create dom_info; int paused = 0, debug = 0, daemonize = 1, console_autoconnect = 0, - quiet = 0, monitor = 1; + quiet = 0, monitor = 1, vnc = 0, vncautopass = 0; int opt, rc; int option_index = 0; static struct option long_options[] = { @@ -3402,6 +3439,8 @@ int main_create(int argc, char **argv) {"quiet", 0, 0, ''q''}, {"help", 0, 0, ''h''}, {"defconfig", 1, 0, ''f''}, + {"vncviewer", 0, 0, ''V''}, + {"vncviewer-autopass", 0, 0, ''A''}, {0, 0, 0, 0} }; @@ -3411,7 +3450,7 @@ int main_create(int argc, char **argv) } while (1) { - opt = getopt_long(argc, argv, "Fhnqf:pcde", long_options, &option_index); + opt = getopt_long(argc, argv, "Fhnqf:pcdeVA", long_options, &option_index); if (opt == -1) break; @@ -3444,6 +3483,12 @@ int main_create(int argc, char **argv) case ''q'': quiet = 1; break; + case ''V'': + vnc = 1; + break; + case ''A'': + vnc = vncautopass = 1; + break; default: fprintf(stderr, "option `%c'' not supported.\n", optopt); break; @@ -3473,6 +3518,8 @@ int main_create(int argc, char **argv) dom_info.config_file = filename; dom_info.extra_config = extra_config; dom_info.migrate_fd = -1; + dom_info.vnc = vnc; + dom_info.vncautopass = vncautopass; dom_info.console_autoconnect = console_autoconnect; dom_info.incr_generationid = 0; @@ -3575,7 +3622,7 @@ int main_config_update(int argc, char ** libxl_domain_config_init(&d_config); - parse_config_data(filename, config_data, config_len, &d_config); + parse_config_data(filename, config_data, config_len, &d_config, NULL); if (debug || dryrun_only) printf_info(default_output_format, -1, &d_config); diff -r 380d5f86dfdd -r d1c195e989cc tools/libxl/xl_cmdtable.c --- a/tools/libxl/xl_cmdtable.c Tue May 15 02:26:51 2012 +0000 +++ b/tools/libxl/xl_cmdtable.c Tue May 15 02:26:53 2012 +0000 @@ -30,7 +30,10 @@ struct cmd_spec cmd_table[] = { "-n, --dryrun Dry run - prints the resulting configuration\n" " (deprecated in favour of global -N option).\n" "-d Enable debug messages.\n" - "-e Do not wait in the background for the death of the domain." + "-e Do not wait in the background for the death of the domain.\n" + "-V, --vncviewer Connect to the VNC display after the domain is created.\n" + "-A, --vncviewer-autopass\n" + " Pass VNC password to viewer via stdin." }, { "config-update", &main_config_update, 1, @@ -144,10 +147,12 @@ struct cmd_spec cmd_table[] = { &main_restore, 0, "Restore a domain from a saved state", "[options] [<ConfigFile>] <CheckpointFile>", - "-h Print this help.\n" - "-p Do not unpause domain after restoring it.\n" - "-e Do not wait in the background for the death of the domain.\n" - "-d Enable debug messages." + "-h Print this help.\n" + "-p Do not unpause domain after restoring it.\n" + "-e Do not wait in the background for the death of the domain.\n" + "-d Enable debug messages.\n" + "-V, --vncviewer Connect to the VNC display after the domain is created.\n" + "-A, --vncviewer-autopass Pass VNC password to viewer via stdin." }, { "migrate-receive", &main_migrate_receive, 0,
Ian Campbell
2012-May-15 14:43 UTC
Re: [PATCH 2 of 2 v2] Introduce vncviewer xm compatibility options
On Tue, 2012-05-15 at 03:39 +0100, Goncalo Gomes wrote:> docs/man/xl.cfg.pod.5 | 4 ++ > docs/man/xl.pod.1 | 18 +++++++++++ > tools/libxl/xl_cmdimpl.c | 73 ++++++++++++++++++++++++++++++++++++++-------- > tools/libxl/xl_cmdtable.c | 15 ++++++--- > 4 files changed, 92 insertions(+), 18 deletions(-) > > > Signed-off-by: Goncalo Gomes <Goncalo.Gomes@EU.CITRIX.COM>Committed-by: Ian Campbell <ian.campbell@citrix.com> Thanks! I fixed up a context reject in xl_cmdtable.c, relating to the addition of the "modifies" flag, please do check I did the right thing. Also I stripped some trailing whitespace.> > diff -r 380d5f86dfdd -r d1c195e989cc docs/man/xl.cfg.pod.5 > --- a/docs/man/xl.cfg.pod.5 Tue May 15 02:26:51 2012 +0000 > +++ b/docs/man/xl.cfg.pod.5 Tue May 15 02:26:53 2012 +0000 > @@ -91,6 +91,10 @@ The following options apply to guests of > Specifies the UUID of the domain. If not specified, a fresh unique > UUID will be generated. > > +=item B<vncviewer=BOOLEAN> > + > +Automatically spawn a vncviewer when creating/restoring a guest > + > =item B<pool="CPUPOOLNAME"> > > Put the guest''s vcpus into the named cpu pool. > diff -r 380d5f86dfdd -r d1c195e989cc docs/man/xl.pod.1 > --- a/docs/man/xl.pod.1 Tue May 15 02:26:51 2012 +0000 > +++ b/docs/man/xl.pod.1 Tue May 15 02:26:53 2012 +0000 > @@ -120,6 +120,14 @@ Use the given configuration file. > > Leave the domain paused after it is created. > > +=item B<-V>, B<--vncviewer> > + > +Attach to domain''s VNC server, forking a vncviewer process. > + > +=item B<-A>, B<--vncviewer-autopass> > + > +Pass VNC password to vncviewer via stdin. > + > =item B<-c> > > Attach console to the domain as soon as it has started. This is > @@ -433,6 +441,16 @@ See the corresponding option of the I<cr > > Enable debug messages. > > +=item B<-V>, B<--vncviewer> > + > +Attach to domain''s VNC server, forking a vncviewer process. > + > +=item B<-A>, B<--vncviewer-autopass> > + > +Pass VNC password to vncviewer via stdin. > + > + > + > =back > > =item B<save> [I<OPTIONS>] I<domain-id> I<CheckpointFile> [I<ConfigFile>] > diff -r 380d5f86dfdd -r d1c195e989cc tools/libxl/xl_cmdimpl.c > --- a/tools/libxl/xl_cmdimpl.c Tue May 15 02:26:51 2012 +0000 > +++ b/tools/libxl/xl_cmdimpl.c Tue May 15 02:26:53 2012 +0000 > @@ -127,6 +127,8 @@ struct domain_create { > int paused; > int dryrun; > int quiet; > + int vnc; > + int vncautopass; > int console_autoconnect; > const char *config_file; > const char *extra_config; /* extra config string */ > @@ -204,9 +206,8 @@ static void find_domain(const char *p) > common_domname = was_name ? p : libxl_domid_to_name(ctx, domid); > } > > -static int vncviewer(const char *domain_spec, int autopass) > +static int vncviewer(uint32_t domid, int autopass) > { > - find_domain(domain_spec); > libxl_vncviewer_exec(ctx, domid, autopass); > fprintf(stderr, "Unable to execute vncviewer\n"); > return 1; > @@ -549,7 +550,9 @@ vcpp_out: > static void parse_config_data(const char *configfile_filename_report, > const char *configfile_data, > int configfile_len, > - libxl_domain_config *d_config) > + libxl_domain_config *d_config, > + struct domain_create *dom_info) > + > { > const char *buf; > long l; > @@ -754,6 +757,13 @@ static void parse_config_data(const char > if (!xlu_cfg_get_long(config, "rtc_timeoffset", &l, 0)) > b_info->rtc_timeoffset = l; > > + if (dom_info && !xlu_cfg_get_long(config, "vncviewer", &l, 0)) { > + /* Command line arguments must take precedence over what''s > + * specified in the configuration file. */ > + if (!dom_info->vnc) > + dom_info->vnc = l; > + } > + > xlu_cfg_get_defbool(config, "localtime", &b_info->localtime, 0); > > if (!xlu_cfg_get_long (config, "videoram", &l, 0)) > @@ -1531,6 +1541,7 @@ static int create_domain(struct domain_c > int daemonize = dom_info->daemonize; > int monitor = dom_info->monitor; > int paused = dom_info->paused; > + int vncautopass = dom_info->vncautopass; > const char *config_file = dom_info->config_file; > const char *extra_config = dom_info->extra_config; > const char *restore_file = dom_info->restore_file; > @@ -1654,7 +1665,7 @@ static int create_domain(struct domain_c > if (!dom_info->quiet) > printf("Parsing config file %s\n", config_file); > > - parse_config_data(config_file, config_data, config_len, &d_config); > + parse_config_data(config_file, config_data, config_len, &d_config, dom_info); > > if (migrate_fd >= 0) { > if (d_config.c_info.name) { > @@ -1741,6 +1752,9 @@ start: > if (!daemonize && !monitor) > goto out; > > + if (dom_info->vnc) > + vncviewer(domid, vncautopass); > + > if (need_daemon) { > char *fullname, *name; > pid_t child1, got_child; > @@ -1867,7 +1881,7 @@ start: > libxl_domain_config_dispose(&d_config); > libxl_domain_config_init(&d_config); > parse_config_data(config_file, config_data, config_len, > - &d_config); > + &d_config, dom_info); > > /* > * XXX FIXME: If this sleep is not there then domain > @@ -2218,7 +2232,9 @@ int main_vncviewer(int argc, char **argv > return 2; > } > > - if (vncviewer(argv[optind], autopass)) > + find_domain(argv[optind]); > + > + if (vncviewer(domid, autopass)) > return 1; > return 0; > } > @@ -2493,7 +2509,7 @@ static void list_domains_details(const l > continue; > CHK_ERRNO(asprintf(&config_file, "<domid %d data>", info[i].domid)); > libxl_domain_config_init(&d_config); > - parse_config_data(config_file, (char *)data, len, &d_config); > + parse_config_data(config_file, (char *)data, len, &d_config, NULL); > printf_info(default_output_format, info[i].domid, &d_config); > libxl_domain_config_dispose(&d_config); > free(data); > @@ -3043,13 +3059,26 @@ int main_restore(int argc, char **argv) > const char *config_file = NULL; > struct domain_create dom_info; > int paused = 0, debug = 0, daemonize = 1, monitor = 1, > - console_autoconnect = 0; > + console_autoconnect = 0, vnc = 0, vncautopass = 0; > int opt, rc; > - > - while ((opt = def_getopt(argc, argv, "Fcpde", "restore", 1)) != -1) { > + int option_index = 0; > + static struct option long_options[] = { > + {"vncviewer", 0, 0, ''V''}, > + {"vncviewer-autopass", 0, 0, ''A''}, > + {0, 0, 0, 0} > + }; > + > + while (1) { > + opt = getopt_long(argc, argv, "FhcpdeVA", long_options, &option_index); > + if (opt == -1) > + break; > + > switch (opt) { > case 0: case 2: > return opt; > + case ''h'': > + help("restore"); > + return 2; > case ''c'': > console_autoconnect = 1; > break; > @@ -3066,6 +3095,12 @@ int main_restore(int argc, char **argv) > daemonize = 0; > monitor = 0; > break; > + case ''V'': > + vnc = 1; > + break; > + case ''A'': > + vnc = vncautopass = 1; > + break; > } > } > > @@ -3087,6 +3122,8 @@ int main_restore(int argc, char **argv) > dom_info.config_file = config_file; > dom_info.restore_file = checkpoint_file; > dom_info.migrate_fd = -1; > + dom_info.vnc = vnc; > + dom_info.vncautopass = vncautopass; > dom_info.console_autoconnect = console_autoconnect; > dom_info.incr_generationid = 1; > > @@ -3394,7 +3431,7 @@ int main_create(int argc, char **argv) > char extra_config[1024]; > struct domain_create dom_info; > int paused = 0, debug = 0, daemonize = 1, console_autoconnect = 0, > - quiet = 0, monitor = 1; > + quiet = 0, monitor = 1, vnc = 0, vncautopass = 0; > int opt, rc; > int option_index = 0; > static struct option long_options[] = { > @@ -3402,6 +3439,8 @@ int main_create(int argc, char **argv) > {"quiet", 0, 0, ''q''}, > {"help", 0, 0, ''h''}, > {"defconfig", 1, 0, ''f''}, > + {"vncviewer", 0, 0, ''V''}, > + {"vncviewer-autopass", 0, 0, ''A''}, > {0, 0, 0, 0} > }; > > @@ -3411,7 +3450,7 @@ int main_create(int argc, char **argv) > } > > while (1) { > - opt = getopt_long(argc, argv, "Fhnqf:pcde", long_options, &option_index); > + opt = getopt_long(argc, argv, "Fhnqf:pcdeVA", long_options, &option_index); > if (opt == -1) > break; > > @@ -3444,6 +3483,12 @@ int main_create(int argc, char **argv) > case ''q'': > quiet = 1; > break; > + case ''V'': > + vnc = 1; > + break; > + case ''A'': > + vnc = vncautopass = 1; > + break; > default: > fprintf(stderr, "option `%c'' not supported.\n", optopt); > break; > @@ -3473,6 +3518,8 @@ int main_create(int argc, char **argv) > dom_info.config_file = filename; > dom_info.extra_config = extra_config; > dom_info.migrate_fd = -1; > + dom_info.vnc = vnc; > + dom_info.vncautopass = vncautopass; > dom_info.console_autoconnect = console_autoconnect; > dom_info.incr_generationid = 0; > > @@ -3575,7 +3622,7 @@ int main_config_update(int argc, char ** > > libxl_domain_config_init(&d_config); > > - parse_config_data(filename, config_data, config_len, &d_config); > + parse_config_data(filename, config_data, config_len, &d_config, NULL); > > if (debug || dryrun_only) > printf_info(default_output_format, -1, &d_config); > diff -r 380d5f86dfdd -r d1c195e989cc tools/libxl/xl_cmdtable.c > --- a/tools/libxl/xl_cmdtable.c Tue May 15 02:26:51 2012 +0000 > +++ b/tools/libxl/xl_cmdtable.c Tue May 15 02:26:53 2012 +0000 > @@ -30,7 +30,10 @@ struct cmd_spec cmd_table[] = { > "-n, --dryrun Dry run - prints the resulting configuration\n" > " (deprecated in favour of global -N option).\n" > "-d Enable debug messages.\n" > - "-e Do not wait in the background for the death of the domain." > + "-e Do not wait in the background for the death of the domain.\n" > + "-V, --vncviewer Connect to the VNC display after the domain is created.\n" > + "-A, --vncviewer-autopass\n" > + " Pass VNC password to viewer via stdin." > }, > { "config-update", > &main_config_update, 1, > @@ -144,10 +147,12 @@ struct cmd_spec cmd_table[] = { > &main_restore, 0, > "Restore a domain from a saved state", > "[options] [<ConfigFile>] <CheckpointFile>", > - "-h Print this help.\n" > - "-p Do not unpause domain after restoring it.\n" > - "-e Do not wait in the background for the death of the domain.\n" > - "-d Enable debug messages." > + "-h Print this help.\n" > + "-p Do not unpause domain after restoring it.\n" > + "-e Do not wait in the background for the death of the domain.\n" > + "-d Enable debug messages.\n" > + "-V, --vncviewer Connect to the VNC display after the domain is created.\n" > + "-A, --vncviewer-autopass Pass VNC password to viewer via stdin." > }, > { "migrate-receive", > &main_migrate_receive, 0,
Ian Campbell
2012-May-15 14:45 UTC
Re: [PATCH 1 of 2 v2] xl: code motion of vncviewer() and `struct domain_create`
On Tue, 2012-05-15 at 03:39 +0100, Goncalo Gomes wrote:> tools/libxl/xl_cmdimpl.c | 50 ++++++++++++++++++++++++----------------------- > 1 files changed, 26 insertions(+), 24 deletions(-) > > > Signed-off-by: Goncalo Gomes <Goncalo.Gomes@EU.CITRIX.COM>Committed-by: Ian Campbell <ian.campbell@citrix.com> Thanks! Not sure what tool you use to send, but it is usual to put the diffstat after the commit + s-o-b and a "---" marker. This way the standard tools (e.g. git am) knows not to include it in the commit message. In this case I''ve done it by hand. I think hg email is a bit broken in this regard (puts the diffstat at the top), in which case feel free not to use the corresponding option next time. Ian.> > diff -r cd4dd23a831d -r 380d5f86dfdd tools/libxl/xl_cmdimpl.c > --- a/tools/libxl/xl_cmdimpl.c Fri May 11 18:59:07 2012 +0100 > +++ b/tools/libxl/xl_cmdimpl.c Tue May 15 02:26:51 2012 +0000 > @@ -120,6 +120,24 @@ static const char *action_on_shutdown_na > > #define SAVEFILE_BYTEORDER_VALUE ((uint32_t)0x01020304UL) > > +struct domain_create { > + int debug; > + int daemonize; > + int monitor; /* handle guest reboots etc */ > + int paused; > + int dryrun; > + int quiet; > + int console_autoconnect; > + const char *config_file; > + const char *extra_config; /* extra config string */ > + const char *restore_file; > + int migrate_fd; /* -1 means none */ > + char **migration_domname_r; /* from malloc */ > + int incr_generationid; > +}; > + > + > + > static int qualifier_to_id(const char *p, uint32_t *id_r) > { > int i, alldigit; > @@ -186,6 +204,14 @@ static void find_domain(const char *p) > common_domname = was_name ? p : libxl_domid_to_name(ctx, domid); > } > > +static int vncviewer(const char *domain_spec, int autopass) > +{ > + find_domain(domain_spec); > + libxl_vncviewer_exec(ctx, domid, autopass); > + fprintf(stderr, "Unable to execute vncviewer\n"); > + return 1; > +} > + > static int acquire_lock(void) > { > int rc; > @@ -1399,22 +1425,6 @@ static int preserve_domain(libxl_ctx *ct > return rc == 0 ? 1 : 0; > } > > -struct domain_create { > - int debug; > - int daemonize; > - int monitor; /* handle guest reboots etc */ > - int paused; > - int dryrun; > - int quiet; > - int console_autoconnect; > - const char *config_file; > - const char *extra_config; /* extra config string */ > - const char *restore_file; > - int migrate_fd; /* -1 means none */ > - char **migration_domname_r; /* from malloc */ > - int incr_generationid; > -}; > - > static int freemem(libxl_domain_build_info *b_info) > { > int rc, retries = 3; > @@ -2175,14 +2185,6 @@ int main_console(int argc, char **argv) > return 1; > } > > -static int vncviewer(const char *domain_spec, int autopass) > -{ > - find_domain(domain_spec); > - libxl_vncviewer_exec(ctx, domid, autopass); > - fprintf(stderr, "Unable to execute vncviewer\n"); > - return 1; > -} > - > int main_vncviewer(int argc, char **argv) > { > static const struct option long_options[] = {
Goncalo Gomes
2012-May-15 16:07 UTC
Re: [PATCH 1 of 2 v2] xl: code motion of vncviewer() and `struct domain_create`
On Tue, 15 May 2012, Ian Campbell wrote:> On Tue, 2012-05-15 at 03:39 +0100, Goncalo Gomes wrote: > > tools/libxl/xl_cmdimpl.c | 50 ++++++++++++++++++++++++----------------------- > > 1 files changed, 26 insertions(+), 24 deletions(-) > > > > > > Signed-off-by: Goncalo Gomes <Goncalo.Gomes@EU.CITRIX.COM> > > Committed-by: Ian Campbell <ian.campbell@citrix.com> > > Thanks! > > Not sure what tool you use to send, but it is usual to put the diffstat > after the commit + s-o-b and a "---" marker. This way the standard tools > (e.g. git am) knows not to include it in the commit message. In this > case I''ve done it by hand. I think hg email is a bit broken in this > regard (puts the diffstat at the top), in which case feel free not to > use the corresponding option next time.Thanks for fixing this by hand, I used hg email, with the ''-d'' switch to add the diffstat. I will defer from using it next time. Goncalo> Ian. > > > > > diff -r cd4dd23a831d -r 380d5f86dfdd tools/libxl/xl_cmdimpl.c > > --- a/tools/libxl/xl_cmdimpl.c Fri May 11 18:59:07 2012 +0100 > > +++ b/tools/libxl/xl_cmdimpl.c Tue May 15 02:26:51 2012 +0000 > > @@ -120,6 +120,24 @@ static const char *action_on_shutdown_na > > > > #define SAVEFILE_BYTEORDER_VALUE ((uint32_t)0x01020304UL) > > > > +struct domain_create { > > + int debug; > > + int daemonize; > > + int monitor; /* handle guest reboots etc */ > > + int paused; > > + int dryrun; > > + int quiet; > > + int console_autoconnect; > > + const char *config_file; > > + const char *extra_config; /* extra config string */ > > + const char *restore_file; > > + int migrate_fd; /* -1 means none */ > > + char **migration_domname_r; /* from malloc */ > > + int incr_generationid; > > +}; > > + > > + > > + > > static int qualifier_to_id(const char *p, uint32_t *id_r) > > { > > int i, alldigit; > > @@ -186,6 +204,14 @@ static void find_domain(const char *p) > > common_domname = was_name ? p : libxl_domid_to_name(ctx, domid); > > } > > > > +static int vncviewer(const char *domain_spec, int autopass) > > +{ > > + find_domain(domain_spec); > > + libxl_vncviewer_exec(ctx, domid, autopass); > > + fprintf(stderr, "Unable to execute vncviewer\n"); > > + return 1; > > +} > > + > > static int acquire_lock(void) > > { > > int rc; > > @@ -1399,22 +1425,6 @@ static int preserve_domain(libxl_ctx *ct > > return rc == 0 ? 1 : 0; > > } > > > > -struct domain_create { > > - int debug; > > - int daemonize; > > - int monitor; /* handle guest reboots etc */ > > - int paused; > > - int dryrun; > > - int quiet; > > - int console_autoconnect; > > - const char *config_file; > > - const char *extra_config; /* extra config string */ > > - const char *restore_file; > > - int migrate_fd; /* -1 means none */ > > - char **migration_domname_r; /* from malloc */ > > - int incr_generationid; > > -}; > > - > > static int freemem(libxl_domain_build_info *b_info) > > { > > int rc, retries = 3; > > @@ -2175,14 +2185,6 @@ int main_console(int argc, char **argv) > > return 1; > > } > > > > -static int vncviewer(const char *domain_spec, int autopass) > > -{ > > - find_domain(domain_spec); > > - libxl_vncviewer_exec(ctx, domid, autopass); > > - fprintf(stderr, "Unable to execute vncviewer\n"); > > - return 1; > > -} > > - > > int main_vncviewer(int argc, char **argv) > > { > > static const struct option long_options[] = { > >
Goncalo Gomes
2012-May-15 16:13 UTC
Re: [PATCH 2 of 2 v2] Introduce vncviewer xm compatibility options
On Tue, 15 May 2012, Ian Campbell wrote:> On Tue, 2012-05-15 at 03:39 +0100, Goncalo Gomes wrote: > > docs/man/xl.cfg.pod.5 | 4 ++ > > docs/man/xl.pod.1 | 18 +++++++++++ > > tools/libxl/xl_cmdimpl.c | 73 ++++++++++++++++++++++++++++++++++++++-------- > > tools/libxl/xl_cmdtable.c | 15 ++++++--- > > 4 files changed, 92 insertions(+), 18 deletions(-) > > > > > > Signed-off-by: Goncalo Gomes <Goncalo.Gomes@EU.CITRIX.COM> > > Committed-by: Ian Campbell <ian.campbell@citrix.com> > > Thanks! I fixed up a context reject in xl_cmdtable.c, relating to the > addition of the "modifies" flag, please do check I did the right thing. > > Also I stripped some trailing whitespace.Thanks for stripping the whitespace/fixing the reject in xl_cmdtable.c. Looks fine to me! Goncalo> > > > diff -r 380d5f86dfdd -r d1c195e989cc docs/man/xl.cfg.pod.5 > > --- a/docs/man/xl.cfg.pod.5 Tue May 15 02:26:51 2012 +0000 > > +++ b/docs/man/xl.cfg.pod.5 Tue May 15 02:26:53 2012 +0000 > > @@ -91,6 +91,10 @@ The following options apply to guests of > > Specifies the UUID of the domain. If not specified, a fresh unique > > UUID will be generated. > > > > +=item B<vncviewer=BOOLEAN> > > + > > +Automatically spawn a vncviewer when creating/restoring a guest > > + > > =item B<pool="CPUPOOLNAME"> > > > > Put the guest''s vcpus into the named cpu pool. > > diff -r 380d5f86dfdd -r d1c195e989cc docs/man/xl.pod.1 > > --- a/docs/man/xl.pod.1 Tue May 15 02:26:51 2012 +0000 > > +++ b/docs/man/xl.pod.1 Tue May 15 02:26:53 2012 +0000 > > @@ -120,6 +120,14 @@ Use the given configuration file. > > > > Leave the domain paused after it is created. > > > > +=item B<-V>, B<--vncviewer> > > + > > +Attach to domain''s VNC server, forking a vncviewer process. > > + > > +=item B<-A>, B<--vncviewer-autopass> > > + > > +Pass VNC password to vncviewer via stdin. > > + > > =item B<-c> > > > > Attach console to the domain as soon as it has started. This is > > @@ -433,6 +441,16 @@ See the corresponding option of the I<cr > > > > Enable debug messages. > > > > +=item B<-V>, B<--vncviewer> > > + > > +Attach to domain''s VNC server, forking a vncviewer process. > > + > > +=item B<-A>, B<--vncviewer-autopass> > > + > > +Pass VNC password to vncviewer via stdin. > > + > > + > > + > > =back > > > > =item B<save> [I<OPTIONS>] I<domain-id> I<CheckpointFile> [I<ConfigFile>] > > diff -r 380d5f86dfdd -r d1c195e989cc tools/libxl/xl_cmdimpl.c > > --- a/tools/libxl/xl_cmdimpl.c Tue May 15 02:26:51 2012 +0000 > > +++ b/tools/libxl/xl_cmdimpl.c Tue May 15 02:26:53 2012 +0000 > > @@ -127,6 +127,8 @@ struct domain_create { > > int paused; > > int dryrun; > > int quiet; > > + int vnc; > > + int vncautopass; > > int console_autoconnect; > > const char *config_file; > > const char *extra_config; /* extra config string */ > > @@ -204,9 +206,8 @@ static void find_domain(const char *p) > > common_domname = was_name ? p : libxl_domid_to_name(ctx, domid); > > } > > > > -static int vncviewer(const char *domain_spec, int autopass) > > +static int vncviewer(uint32_t domid, int autopass) > > { > > - find_domain(domain_spec); > > libxl_vncviewer_exec(ctx, domid, autopass); > > fprintf(stderr, "Unable to execute vncviewer\n"); > > return 1; > > @@ -549,7 +550,9 @@ vcpp_out: > > static void parse_config_data(const char *configfile_filename_report, > > const char *configfile_data, > > int configfile_len, > > - libxl_domain_config *d_config) > > + libxl_domain_config *d_config, > > + struct domain_create *dom_info) > > + > > { > > const char *buf; > > long l; > > @@ -754,6 +757,13 @@ static void parse_config_data(const char > > if (!xlu_cfg_get_long(config, "rtc_timeoffset", &l, 0)) > > b_info->rtc_timeoffset = l; > > > > + if (dom_info && !xlu_cfg_get_long(config, "vncviewer", &l, 0)) { > > + /* Command line arguments must take precedence over what''s > > + * specified in the configuration file. */ > > + if (!dom_info->vnc) > > + dom_info->vnc = l; > > + } > > + > > xlu_cfg_get_defbool(config, "localtime", &b_info->localtime, 0); > > > > if (!xlu_cfg_get_long (config, "videoram", &l, 0)) > > @@ -1531,6 +1541,7 @@ static int create_domain(struct domain_c > > int daemonize = dom_info->daemonize; > > int monitor = dom_info->monitor; > > int paused = dom_info->paused; > > + int vncautopass = dom_info->vncautopass; > > const char *config_file = dom_info->config_file; > > const char *extra_config = dom_info->extra_config; > > const char *restore_file = dom_info->restore_file; > > @@ -1654,7 +1665,7 @@ static int create_domain(struct domain_c > > if (!dom_info->quiet) > > printf("Parsing config file %s\n", config_file); > > > > - parse_config_data(config_file, config_data, config_len, &d_config); > > + parse_config_data(config_file, config_data, config_len, &d_config, dom_info); > > > > if (migrate_fd >= 0) { > > if (d_config.c_info.name) { > > @@ -1741,6 +1752,9 @@ start: > > if (!daemonize && !monitor) > > goto out; > > > > + if (dom_info->vnc) > > + vncviewer(domid, vncautopass); > > + > > if (need_daemon) { > > char *fullname, *name; > > pid_t child1, got_child; > > @@ -1867,7 +1881,7 @@ start: > > libxl_domain_config_dispose(&d_config); > > libxl_domain_config_init(&d_config); > > parse_config_data(config_file, config_data, config_len, > > - &d_config); > > + &d_config, dom_info); > > > > /* > > * XXX FIXME: If this sleep is not there then domain > > @@ -2218,7 +2232,9 @@ int main_vncviewer(int argc, char **argv > > return 2; > > } > > > > - if (vncviewer(argv[optind], autopass)) > > + find_domain(argv[optind]); > > + > > + if (vncviewer(domid, autopass)) > > return 1; > > return 0; > > } > > @@ -2493,7 +2509,7 @@ static void list_domains_details(const l > > continue; > > CHK_ERRNO(asprintf(&config_file, "<domid %d data>", info[i].domid)); > > libxl_domain_config_init(&d_config); > > - parse_config_data(config_file, (char *)data, len, &d_config); > > + parse_config_data(config_file, (char *)data, len, &d_config, NULL); > > printf_info(default_output_format, info[i].domid, &d_config); > > libxl_domain_config_dispose(&d_config); > > free(data); > > @@ -3043,13 +3059,26 @@ int main_restore(int argc, char **argv) > > const char *config_file = NULL; > > struct domain_create dom_info; > > int paused = 0, debug = 0, daemonize = 1, monitor = 1, > > - console_autoconnect = 0; > > + console_autoconnect = 0, vnc = 0, vncautopass = 0; > > int opt, rc; > > - > > - while ((opt = def_getopt(argc, argv, "Fcpde", "restore", 1)) != -1) { > > + int option_index = 0; > > + static struct option long_options[] = { > > + {"vncviewer", 0, 0, ''V''}, > > + {"vncviewer-autopass", 0, 0, ''A''}, > > + {0, 0, 0, 0} > > + }; > > + > > + while (1) { > > + opt = getopt_long(argc, argv, "FhcpdeVA", long_options, &option_index); > > + if (opt == -1) > > + break; > > + > > switch (opt) { > > case 0: case 2: > > return opt; > > + case ''h'': > > + help("restore"); > > + return 2; > > case ''c'': > > console_autoconnect = 1; > > break; > > @@ -3066,6 +3095,12 @@ int main_restore(int argc, char **argv) > > daemonize = 0; > > monitor = 0; > > break; > > + case ''V'': > > + vnc = 1; > > + break; > > + case ''A'': > > + vnc = vncautopass = 1; > > + break; > > } > > } > > > > @@ -3087,6 +3122,8 @@ int main_restore(int argc, char **argv) > > dom_info.config_file = config_file; > > dom_info.restore_file = checkpoint_file; > > dom_info.migrate_fd = -1; > > + dom_info.vnc = vnc; > > + dom_info.vncautopass = vncautopass; > > dom_info.console_autoconnect = console_autoconnect; > > dom_info.incr_generationid = 1; > > > > @@ -3394,7 +3431,7 @@ int main_create(int argc, char **argv) > > char extra_config[1024]; > > struct domain_create dom_info; > > int paused = 0, debug = 0, daemonize = 1, console_autoconnect = 0, > > - quiet = 0, monitor = 1; > > + quiet = 0, monitor = 1, vnc = 0, vncautopass = 0; > > int opt, rc; > > int option_index = 0; > > static struct option long_options[] = { > > @@ -3402,6 +3439,8 @@ int main_create(int argc, char **argv) > > {"quiet", 0, 0, ''q''}, > > {"help", 0, 0, ''h''}, > > {"defconfig", 1, 0, ''f''}, > > + {"vncviewer", 0, 0, ''V''}, > > + {"vncviewer-autopass", 0, 0, ''A''}, > > {0, 0, 0, 0} > > }; > > > > @@ -3411,7 +3450,7 @@ int main_create(int argc, char **argv) > > } > > > > while (1) { > > - opt = getopt_long(argc, argv, "Fhnqf:pcde", long_options, &option_index); > > + opt = getopt_long(argc, argv, "Fhnqf:pcdeVA", long_options, &option_index); > > if (opt == -1) > > break; > > > > @@ -3444,6 +3483,12 @@ int main_create(int argc, char **argv) > > case ''q'': > > quiet = 1; > > break; > > + case ''V'': > > + vnc = 1; > > + break; > > + case ''A'': > > + vnc = vncautopass = 1; > > + break; > > default: > > fprintf(stderr, "option `%c'' not supported.\n", optopt); > > break; > > @@ -3473,6 +3518,8 @@ int main_create(int argc, char **argv) > > dom_info.config_file = filename; > > dom_info.extra_config = extra_config; > > dom_info.migrate_fd = -1; > > + dom_info.vnc = vnc; > > + dom_info.vncautopass = vncautopass; > > dom_info.console_autoconnect = console_autoconnect; > > dom_info.incr_generationid = 0; > > > > @@ -3575,7 +3622,7 @@ int main_config_update(int argc, char ** > > > > libxl_domain_config_init(&d_config); > > > > - parse_config_data(filename, config_data, config_len, &d_config); > > + parse_config_data(filename, config_data, config_len, &d_config, NULL); > > > > if (debug || dryrun_only) > > printf_info(default_output_format, -1, &d_config); > > diff -r 380d5f86dfdd -r d1c195e989cc tools/libxl/xl_cmdtable.c > > --- a/tools/libxl/xl_cmdtable.c Tue May 15 02:26:51 2012 +0000 > > +++ b/tools/libxl/xl_cmdtable.c Tue May 15 02:26:53 2012 +0000 > > @@ -30,7 +30,10 @@ struct cmd_spec cmd_table[] = { > > "-n, --dryrun Dry run - prints the resulting configuration\n" > > " (deprecated in favour of global -N option).\n" > > "-d Enable debug messages.\n" > > - "-e Do not wait in the background for the death of the domain." > > + "-e Do not wait in the background for the death of the domain.\n" > > + "-V, --vncviewer Connect to the VNC display after the domain is created.\n" > > + "-A, --vncviewer-autopass\n" > > + " Pass VNC password to viewer via stdin." > > }, > > { "config-update", > > &main_config_update, 1, > > @@ -144,10 +147,12 @@ struct cmd_spec cmd_table[] = { > > &main_restore, 0, > > "Restore a domain from a saved state", > > "[options] [<ConfigFile>] <CheckpointFile>", > > - "-h Print this help.\n" > > - "-p Do not unpause domain after restoring it.\n" > > - "-e Do not wait in the background for the death of the domain.\n" > > - "-d Enable debug messages." > > + "-h Print this help.\n" > > + "-p Do not unpause domain after restoring it.\n" > > + "-e Do not wait in the background for the death of the domain.\n" > > + "-d Enable debug messages.\n" > > + "-V, --vncviewer Connect to the VNC display after the domain is created.\n" > > + "-A, --vncviewer-autopass Pass VNC password to viewer via stdin." > > }, > > { "migrate-receive", > > &main_migrate_receive, 0, > >
Apparently Analagous Threads
- [PATCH] Add vncviewer xm compatibility options the 'xl create' command
- [PATCH] tools: xl: on create, if debug && !daemonize, wait for domain destroy in the foreground
- [PATCH 0/9] libxl: disk configuration handling
- [PATCH 0 of 4] Support for VM generation ID save/restore and migrate
- [PATCH 0 of 3] Support for VM generation ID save/restore and migrate