Laszlo Ersek
2022-Sep-19 13:35 UTC
[Libguestfs] [p2v PATCH 14/15] create_conversion_dialog(): add button to refresh disks & removables
Using the previously extracted / reworked representation of disks and removables, introduce a new button in the conversion dialog that repopulates the "disks" and "removables" tree views with freshly collected entries. In case the user issues such commands in the XTerm window that make more disks visible to the kernel, for example iSCSI LUNs, the button allows virt-p2v to learn about those disks. Disable the new button for when "--test-disk" is passed on the command line; that option conflicts with the new feature. (This means the new button is insensitive in "make run-virt-p2v-directly". It is sensitive in the VM tests though.) Update the manual accordingly. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2124538 Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- gui.c | 42 ++++++++++++++++++-- virt-p2v.pod | 21 +++++++--- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/gui.c b/gui.c index f7b7ab25adaa..49301d9a985b 100644 --- a/gui.c +++ b/gui.c @@ -701,6 +701,7 @@ static void set_disks_from_ui (struct config *); static void set_removable_from_ui (struct config *); static void set_interfaces_from_ui (struct config *); static void conversion_back_clicked (GtkWidget *w, gpointer data); +static void refresh_disks_clicked (GtkWidget *w, gpointer data); static void start_conversion_clicked (GtkWidget *w, gpointer data); static void vcpu_topo_toggled (GtkWidget *w, gpointer data); static void vcpus_or_memory_check_callback (GtkWidget *w, gpointer data); @@ -741,7 +742,7 @@ create_conversion_dialog (struct config *config, const char * const *disks, const char * const *removable) { - GtkWidget *back, *start_button; + GtkWidget *back, *refresh_disks, *start_button; GtkWidget *hbox, *left_vbox, *right_vbox; GtkWidget *target_frame, *target_vbox, *target_tbl; GtkWidget *guestname_label, *vcpus_label, *memory_label; @@ -984,16 +985,27 @@ create_conversion_dialog (struct config *config, /* Buttons. */ gtk_dialog_add_buttons (GTK_DIALOG (conv_dlg), _("_Back"), 1, - _("Start _conversion"), 2, + _("_Refresh disks (will reset selection)"), 2, + _("Start _conversion"), 3, NULL); back = gtk_dialog_get_widget_for_response (GTK_DIALOG (conv_dlg), 1); - start_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (conv_dlg), 2); + refresh_disks = gtk_dialog_get_widget_for_response (GTK_DIALOG (conv_dlg), 2); + start_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (conv_dlg), 3); + + /* Disable disk refreshing in case --test-disk was passed. */ + if (disks != NULL && + disks[0] != NULL && + disks[0][0] == '/' && + disks[1] == NULL) + gtk_widget_set_sensitive (refresh_disks, FALSE); /* Signals. */ g_signal_connect_swapped (G_OBJECT (conv_dlg), "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (back), "clicked", G_CALLBACK (conversion_back_clicked), NULL); + g_signal_connect (G_OBJECT (refresh_disks), "clicked", + G_CALLBACK (refresh_disks_clicked), NULL); g_signal_connect (G_OBJECT (start_button), "clicked", G_CALLBACK (start_conversion_clicked), config); g_signal_connect (G_OBJECT (vcpu_topo), "toggled", @@ -1600,6 +1612,30 @@ conversion_back_clicked (GtkWidget *w, gpointer data) gtk_widget_set_sensitive (next_button, FALSE); } +static void +refresh_disks_clicked (GtkWidget *w, gpointer data) +{ + GtkTreeModel *model; + GtkListStore *disks_store, *removable_store; + char **disks, **removable; + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (disks_list)); + disks_store = GTK_LIST_STORE (model); + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (removable_list)); + removable_store = GTK_LIST_STORE (model); + + gtk_list_store_clear (disks_store); + gtk_list_store_clear (removable_store); + + find_all_disks (&disks, &removable); + populate_disks_store (disks_store, (const char **)disks); + populate_removable_store (removable_store, (const char **)removable); + + guestfs_int_free_string_list (removable); + guestfs_int_free_string_list (disks); +} + static char *concat_warning (char *warning, const char *fs, ...) __attribute__((format (printf,2,3))); diff --git a/virt-p2v.pod b/virt-p2v.pod index aec5078f92db..6c9033ca250d 100644 --- a/virt-p2v.pod +++ b/virt-p2v.pod @@ -219,6 +219,15 @@ Removable media panel to create corresponding drives on the guest after conversion. Note that any data CDs/DVDs which are mounted in the drives are I<not> copied over. +At the bottom of the dialog, the C<Refresh disks> button instructs +virt-p2v to re-enumerate the fixed hard disks and the removable media +drives. (Note that the button will also reset the currently active +selections in both of those panels.) This button is useful in +combination with the C<XTerm> button on the L</SSH CONFIGURATION +DIALOG>: in the XTerm window, you can expose further block devices to +the kernel (such as LUNs from iSCSI targets), and the C<Refresh disks> +button allows virt-p2v to learn about all the block devices again. + ? Network interfaces ? ? @@ -239,10 +248,10 @@ the interface to be identified by the operator. When you are ready to begin the conversion, press the C<Start conversion> button: - ? - [ Back ] [ Start conversion ] ? - ? - ? ? ???????????????????????????????????????? + ? + [ Back ] [ Refresh disks ] [ Start conversion ] ? + ? + ? ? ??????????????????????????????????????????????????????????? =head2 CONVERSION RUNNING DIALOG @@ -509,7 +518,9 @@ features such as the Shutdown popup button. =item B<--test-disk=/PATH/TO/DISK.IMG> For testing or debugging purposes, replace F</dev/sda> with a local -file. You must use an absolute path. +file. You must use an absolute path. Note that the C<Refresh disks> +button will be disabled in the L</DISK AND NETWORK CONFIGURATION DIALOG> +of the GUI. =item B<-v>
Richard W.M. Jones
2022-Sep-23 09:42 UTC
[Libguestfs] [p2v PATCH 14/15] create_conversion_dialog(): add button to refresh disks & removables
On Mon, Sep 19, 2022 at 03:35:10PM +0200, Laszlo Ersek wrote:> +At the bottom of the dialog, the C<Refresh disks> button instructs > +virt-p2v to re-enumerate the fixed hard disks and the removable media > +drives. (Note that the button will also reset the currently active > +selections in both of those panels.) This button is useful in > +combination with the C<XTerm> button on the L</SSH CONFIGURATION > +DIALOG>: in the XTerm window, you can expose further block devices to > +the kernel (such as LUNs from iSCSI targets), and the C<Refresh disks> > +button allows virt-p2v to learn about all the block devices again. > + > ? > Network interfaces ? > ?^ Here (and earlier) in the same file ...> @@ -239,10 +248,10 @@ the interface to be identified by the operator. > When you are ready to begin the conversion, press the > C<Start conversion> button: > > - ? > - [ Back ] [ Start conversion ] ? > - ? > - ? ? ???????????????????????????????????????? > + ? > + [ Back ] [ Refresh disks ] [ Start conversion ] ? > + ? > + ? ? ???????????????????????????????????????????????????????????... I think you need to move the ? (vertical line) in the earlier sections over to the right to line up. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html