Laszlo Ersek
2023-Feb-02 10:29 UTC
[Libguestfs] [p2v PATCH v2 09/11] gui: expose "p2v.output.misc" (-oo)
Introduce a new GTK_ENTRY field in the Output options box. Similarly to "p2v.output.misc" on the kernel cmdline, the contents of this GTK_ENTRY are a comma-separated list of OPTION=VALUE options, where each option is passed to virt-v2v as the argument of a separate "-oo" option. Refresh the manual accordingly. For initially populating the text entry (in case the kernel command line specified "p2v.output.misc"), call the guestfs_int_join_strings() function that we imported previously in this series. For unpacking the contents in start_conversion_clicked(), call guestfs_int_split_string(), just like the generated kernel cmdline parser does, in update_config_from_kernel_cmdline() [kernel-config.c]. Cc: Alban Lecorps <alban.lecorps at ubisoft.com> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1792141 Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- Notes: v2: - highlight "no spaces around commas" in the tooltip [Rich] - repeat the "-oo" notes in the GUI section of the manual [Rich] gui.c | 49 +++++++++++++++++++- virt-p2v.pod | 11 +++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/gui.c b/gui.c index f86cab649785..ce9b2455e666 100644 --- a/gui.c +++ b/gui.c @@ -116,7 +116,7 @@ static GtkWidget *conn_dlg, static GtkWidget *conv_dlg, *guestname_entry, *vcpu_topo, *vcpus_entry, *memory_entry, *vcpus_warning, *memory_warning, *target_warning_label, - *o_combo, *oc_entry, *os_entry, *of_entry, *oa_combo, + *o_combo, *oc_entry, *os_entry, *of_entry, *oa_combo, *oo_entry, *info_label, *disks_list, *removable_list, *interfaces_list; static int vcpus_entry_when_last_sensitive; @@ -674,6 +674,7 @@ static void populate_removable_store (GtkListStore *removable_store, static void populate_removable (GtkTreeView *removable_list_p, const char * const *removable); static void populate_interfaces (GtkTreeView *interfaces_list_p); +static void populate_misc_opts (GtkEntry *entry, char * const *misc); static void toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data); @@ -733,7 +734,7 @@ create_conversion_dialog (struct config *config, GtkWidget *target_frame, *target_vbox, *target_tbl; GtkWidget *guestname_label, *vcpus_label, *memory_label; GtkWidget *output_frame, *output_vbox, *output_tbl; - GtkWidget *o_label, *oa_label, *oc_label, *of_label, *os_label; + GtkWidget *o_label, *oa_label, *oc_label, *of_label, *os_label, *oo_label; GtkWidget *info_frame; GtkWidget *disks_frame, *disks_sw; GtkWidget *removable_frame, *removable_sw; @@ -929,6 +930,25 @@ create_conversion_dialog (struct config *config, table_attach (output_tbl, oa_combo, 1, 2, row, GTK_FILL, GTK_FILL, 1, 1); + row++; + oo_label = gtk_label_new_with_mnemonic (_("M_isc. options (-oo):")); + table_attach (output_tbl, oo_label, + 0, 1, row, GTK_FILL, GTK_FILL, 1, 1); + set_alignment (oo_label, 1., 0.5); + oo_entry = gtk_entry_new (); + gtk_label_set_mnemonic_widget (GTK_LABEL (oo_label), oo_entry); + gtk_widget_set_tooltip_markup (oo_entry, + _("A comma-separated list of " + "<b>OPTION=VALUE</b> output-specific " + "options. Each option is passed to " + "virt-v2v as the argument of a separate " + "<b>-oo</b> option. Do not place a space " + "character at either side of either comma " + "separator.")); + populate_misc_opts (GTK_ENTRY (oo_entry), config->output.misc); + table_attach (output_tbl, oo_entry, + 1, 2, row, GTK_FILL, GTK_FILL, 1, 1); + gtk_box_pack_start (GTK_BOX (output_vbox), output_tbl, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (output_frame), output_vbox); @@ -1356,6 +1376,25 @@ populate_interfaces (GtkTreeView *interfaces_list_p) G_CALLBACK (network_edited_callback), interfaces_store); } +/** + * Populate the C<Misc. options> text entry. + */ +static void +populate_misc_opts (GtkEntry *entry, char * const *misc) +{ + char *joined; + + if (misc == NULL) + return; + + joined = guestfs_int_join_strings (",", misc); + if (joined == NULL) + error (EXIT_FAILURE, errno, "malloc"); + + gtk_entry_set_text (entry, joined); + free(joined); +} + static void toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data) { @@ -2197,6 +2236,12 @@ start_conversion_clicked (GtkWidget *w, gpointer data) else config->output.storage = NULL; + str = gtk_entry_get_text (GTK_ENTRY (oo_entry)); + guestfs_int_free_string_list (config->output.misc); + config->output.misc = guestfs_int_split_string (',', str); + if (config->output.misc == NULL) + error (EXIT_FAILURE, errno, "strdup"); + /* Display the UI for conversion. */ show_running_dialog (); diff --git a/virt-p2v.pod b/virt-p2v.pod index ecdae46eaaf6..6008c25d6159 100644 --- a/virt-p2v.pod +++ b/virt-p2v.pod @@ -175,10 +175,21 @@ first-time virt-p2v user. ? ? Output allocation (-oa): [sparse ?] ? + ? Misc. options (-oo): [___________________] + ? All output options and paths are relative to the conversion server (I<not> to the physical server). +Note that the C<Misc. options> text entry behaves differently from the +other text entries -- its format is identical to that of the +C<p2v.output.misc> L<kernel command line|/KERNEL COMMAND LINE +CONFIGURATION> option. Namely, the text entry contains a +comma-separated list of miscellaneous, output-specific options. (Do +not put spaces around the commas!) Each element in the list is of the +form C<OPTION=VALUE>, and each element is passed to virt-v2v as a +standalone I<-oo OPTION=VALUE> option. + Finally in the left hand column is an information box giving the version of virt-p2v (on the physical server) and virt-v2v (on the conversion server). You should supply this information when reporting
Richard W.M. Jones
2023-Feb-02 10:39 UTC
[Libguestfs] [p2v PATCH v2 09/11] gui: expose "p2v.output.misc" (-oo)
On Thu, Feb 02, 2023 at 11:29:26AM +0100, Laszlo Ersek wrote:> Introduce a new GTK_ENTRY field in the Output options box. Similarly to > "p2v.output.misc" on the kernel cmdline, the contents of this GTK_ENTRY > are a comma-separated list of OPTION=VALUE options, where each option is > passed to virt-v2v as the argument of a separate "-oo" option. > > Refresh the manual accordingly. > > For initially populating the text entry (in case the kernel command line > specified "p2v.output.misc"), call the guestfs_int_join_strings() function > that we imported previously in this series. > > For unpacking the contents in start_conversion_clicked(), call > guestfs_int_split_string(), just like the generated kernel cmdline parser > does, in update_config_from_kernel_cmdline() [kernel-config.c]. > > Cc: Alban Lecorps <alban.lecorps at ubisoft.com> > Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1792141 > Signed-off-by: Laszlo Ersek <lersek at redhat.com> > --- > > Notes: > v2: > > - highlight "no spaces around commas" in the tooltip [Rich] > > - repeat the "-oo" notes in the GUI section of the manual [Rich] > > gui.c | 49 +++++++++++++++++++- > virt-p2v.pod | 11 +++++ > 2 files changed, 58 insertions(+), 2 deletions(-) > > diff --git a/gui.c b/gui.c > index f86cab649785..ce9b2455e666 100644 > --- a/gui.c > +++ b/gui.c > @@ -116,7 +116,7 @@ static GtkWidget *conn_dlg, > static GtkWidget *conv_dlg, > *guestname_entry, *vcpu_topo, *vcpus_entry, *memory_entry, > *vcpus_warning, *memory_warning, *target_warning_label, > - *o_combo, *oc_entry, *os_entry, *of_entry, *oa_combo, > + *o_combo, *oc_entry, *os_entry, *of_entry, *oa_combo, *oo_entry, > *info_label, > *disks_list, *removable_list, *interfaces_list; > static int vcpus_entry_when_last_sensitive; > @@ -674,6 +674,7 @@ static void populate_removable_store (GtkListStore *removable_store, > static void populate_removable (GtkTreeView *removable_list_p, > const char * const *removable); > static void populate_interfaces (GtkTreeView *interfaces_list_p); > +static void populate_misc_opts (GtkEntry *entry, char * const *misc); > static void toggled (GtkCellRendererToggle *cell, > gchar *path_str, > gpointer data); > @@ -733,7 +734,7 @@ create_conversion_dialog (struct config *config, > GtkWidget *target_frame, *target_vbox, *target_tbl; > GtkWidget *guestname_label, *vcpus_label, *memory_label; > GtkWidget *output_frame, *output_vbox, *output_tbl; > - GtkWidget *o_label, *oa_label, *oc_label, *of_label, *os_label; > + GtkWidget *o_label, *oa_label, *oc_label, *of_label, *os_label, *oo_label; > GtkWidget *info_frame; > GtkWidget *disks_frame, *disks_sw; > GtkWidget *removable_frame, *removable_sw; > @@ -929,6 +930,25 @@ create_conversion_dialog (struct config *config, > table_attach (output_tbl, oa_combo, > 1, 2, row, GTK_FILL, GTK_FILL, 1, 1); > > + row++; > + oo_label = gtk_label_new_with_mnemonic (_("M_isc. options (-oo):")); > + table_attach (output_tbl, oo_label, > + 0, 1, row, GTK_FILL, GTK_FILL, 1, 1); > + set_alignment (oo_label, 1., 0.5); > + oo_entry = gtk_entry_new (); > + gtk_label_set_mnemonic_widget (GTK_LABEL (oo_label), oo_entry); > + gtk_widget_set_tooltip_markup (oo_entry, > + _("A comma-separated list of " > + "<b>OPTION=VALUE</b> output-specific " > + "options. Each option is passed to " > + "virt-v2v as the argument of a separate " > + "<b>-oo</b> option. Do not place a space " > + "character at either side of either comma " > + "separator.")); > + populate_misc_opts (GTK_ENTRY (oo_entry), config->output.misc); > + table_attach (output_tbl, oo_entry, > + 1, 2, row, GTK_FILL, GTK_FILL, 1, 1); > + > gtk_box_pack_start (GTK_BOX (output_vbox), output_tbl, TRUE, TRUE, 0); > gtk_container_add (GTK_CONTAINER (output_frame), output_vbox); > > @@ -1356,6 +1376,25 @@ populate_interfaces (GtkTreeView *interfaces_list_p) > G_CALLBACK (network_edited_callback), interfaces_store); > } > > +/** > + * Populate the C<Misc. options> text entry. > + */ > +static void > +populate_misc_opts (GtkEntry *entry, char * const *misc) > +{ > + char *joined; > + > + if (misc == NULL) > + return; > + > + joined = guestfs_int_join_strings (",", misc); > + if (joined == NULL) > + error (EXIT_FAILURE, errno, "malloc"); > + > + gtk_entry_set_text (entry, joined); > + free(joined); > +} > + > static void > toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data) > { > @@ -2197,6 +2236,12 @@ start_conversion_clicked (GtkWidget *w, gpointer data) > else > config->output.storage = NULL; > > + str = gtk_entry_get_text (GTK_ENTRY (oo_entry)); > + guestfs_int_free_string_list (config->output.misc); > + config->output.misc = guestfs_int_split_string (',', str); > + if (config->output.misc == NULL) > + error (EXIT_FAILURE, errno, "strdup"); > + > /* Display the UI for conversion. */ > show_running_dialog (); > > diff --git a/virt-p2v.pod b/virt-p2v.pod > index ecdae46eaaf6..6008c25d6159 100644 > --- a/virt-p2v.pod > +++ b/virt-p2v.pod > @@ -175,10 +175,21 @@ first-time virt-p2v user. > ? > ? Output allocation (-oa): [sparse ?] > ? > + ? Misc. options (-oo): [___________________] > + ? > > All output options and paths are relative to the conversion server > (I<not> to the physical server). > > +Note that the C<Misc. options> text entry behaves differently from theYou can use S<C<Misc. options>> which will add a non-breaking space to prevent the output from being wrapped (not that it's likely to be line-wrapped in the current position, but it might be good practice).> +other text entries -- its format is identical to that of the > +C<p2v.output.misc> L<kernel command line|/KERNEL COMMAND LINE > +CONFIGURATION> option. Namely, the text entry contains a > +comma-separated list of miscellaneous, output-specific options. (Do > +not put spaces around the commas!) Each element in the list is of the > +form C<OPTION=VALUE>, and each element is passed to virt-v2v as a > +standalone I<-oo OPTION=VALUE> option. > + > Finally in the left hand column is an information box giving the > version of virt-p2v (on the physical server) and virt-v2v (on the > conversion server). You should supply this information when reportingReviewed-by: Richard W.M. Jones <rjones at redhat.com> Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top