[Pkg-libvirt-commits] [libguestfs] 07/63: p2v: Add GUI controls for -o, -oc etc options on virt-v2v command line.

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:43:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.39-1
in repository libguestfs.

commit 750e8190348a88a7daf861e1162e5812faead059
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Tue Sep 2 08:53:31 2014 +0100

    p2v: Add GUI controls for -o, -oc etc options on virt-v2v command line.
---
 p2v/gui.c | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 v2v/TODO  |   1 -
 2 files changed, 144 insertions(+), 16 deletions(-)

diff --git a/p2v/gui.c b/p2v/gui.c
index 96c020e..bf463b4 100644
--- a/p2v/gui.c
+++ b/p2v/gui.c
@@ -54,7 +54,9 @@ static GtkWidget *conn_dlg,
 
 /* The conversion dialog. */
 static GtkWidget *conv_dlg,
-  *guestname_entry, *vcpus_entry, *memory_entry, *debug_button,
+  *guestname_entry, *vcpus_entry, *memory_entry,
+  *o_combo, *oc_entry, *os_entry, *of_entry, *oa_combo,
+  *debug_button,
   *disks_list, *removable_list, *interfaces_list,
   *start_button;
 
@@ -389,9 +391,11 @@ static void
 create_conversion_dialog (struct config *config)
 {
   GtkWidget *back;
-  GtkWidget *hbox, *right_vbox;
-  GtkWidget *target, *target_vbox, *target_tbl;
+  GtkWidget *hbox, *left_vbox, *right_vbox;
+  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 *disks_frame, *disks_sw;
   GtkWidget *removable_frame, *removable_sw;
   GtkWidget *interfaces_frame, *interfaces_sw;
@@ -408,10 +412,11 @@ create_conversion_dialog (struct config *config)
 
   /* The main dialog area. */
   hbox = gtk_hbox_new (TRUE, 1);
+  left_vbox = gtk_vbox_new (TRUE, 1);
   right_vbox = gtk_vbox_new (TRUE, 1);
 
-  /* The left column: target properties. */
-  target = gtk_frame_new (_("Target properties"));
+  /* The left column: target properties and output options. */
+  target_frame = gtk_frame_new (_("Target properties"));
 
   target_vbox = gtk_vbox_new (FALSE, 1);
 
@@ -447,15 +452,100 @@ create_conversion_dialog (struct config *config)
   gtk_table_attach (GTK_TABLE (target_tbl), memory_entry,
                     1, 2, 2, 3, GTK_FILL, GTK_FILL, 1, 1);
 
+  gtk_box_pack_start (GTK_BOX (target_vbox), target_tbl, TRUE, TRUE, 0);
+  gtk_container_add (GTK_CONTAINER (target_frame), target_vbox);
+
+  output_frame = gtk_frame_new (_("Virt-v2v output options"));
+
+  output_vbox = gtk_vbox_new (FALSE, 1);
+
+  output_tbl = gtk_table_new (5, 2, FALSE);
+  o_label = gtk_label_new (_("Output to (-o):"));
+  gtk_misc_set_alignment (GTK_MISC (o_label), 1., 0.5);
+  gtk_table_attach (GTK_TABLE (output_tbl), o_label,
+                    0, 1, 0, 1, GTK_FILL, GTK_FILL, 1, 1);
+  o_combo = gtk_combo_box_new_text ();
+  gtk_widget_set_tooltip_markup (o_combo, _("<b>libvirt</b> means send the converted guest to libvirt-managed KVM on the conversion server.  <b>local</b> means put it in a directory on the conversion server.  <b>rhev</b> means write it to RHEV-M/oVirt.  <b>glance</b> means write it to OpenStack Glance.  See the virt-v2v(1) manual page for more information about output options."));
+  /* XXX Add list of input and output drivers to virt-v2v --machine-readable
+   * and pick them up for this list.
+   */
+  gtk_combo_box_append_text (GTK_COMBO_BOX (o_combo), "libvirt");
+  gtk_combo_box_append_text (GTK_COMBO_BOX (o_combo), "local");
+  gtk_combo_box_append_text (GTK_COMBO_BOX (o_combo), "rhev");
+  gtk_combo_box_append_text (GTK_COMBO_BOX (o_combo), "glance");
+  if (config->output) {
+    if (STREQ (config->output, "libvirt"))
+      gtk_combo_box_set_active (GTK_COMBO_BOX (o_combo), 0);
+    else if (STREQ (config->output, "local") || STREQ (config->output, "disk"))
+      gtk_combo_box_set_active (GTK_COMBO_BOX (o_combo), 1);
+    else if (STREQ (config->output, "rhev") || STREQ (config->output, "ovirt"))
+      gtk_combo_box_set_active (GTK_COMBO_BOX (o_combo), 2);
+    else if (STREQ (config->output, "glance"))
+      gtk_combo_box_set_active (GTK_COMBO_BOX (o_combo), 3);
+  }
+  gtk_table_attach (GTK_TABLE (output_tbl), o_combo,
+                    1, 2, 0, 1, GTK_FILL, GTK_FILL, 1, 1);
+
+  oc_label = gtk_label_new (_("Output conn. (-oc):"));
+  gtk_misc_set_alignment (GTK_MISC (oc_label), 1., 0.5);
+  gtk_table_attach (GTK_TABLE (output_tbl), oc_label,
+                    0, 1, 1, 2, GTK_FILL, GTK_FILL, 1, 1);
+  oc_entry = gtk_entry_new ();
+  gtk_widget_set_tooltip_markup (oc_entry, _("For <b>libvirt</b> only, the libvirt connection URI, or leave blank to add the guest to the default libvirt instance on the conversion server.  For others, leave this field blank."));
+  if (config->output_connection != NULL)
+    gtk_entry_set_text (GTK_ENTRY (oc_entry), config->output_connection);
+  gtk_table_attach (GTK_TABLE (output_tbl), oc_entry,
+                    1, 2, 1, 2, GTK_FILL, GTK_FILL, 1, 1);
+
+  os_label = gtk_label_new (_("Output storage (-os):"));
+  gtk_misc_set_alignment (GTK_MISC (os_label), 1., 0.5);
+  gtk_table_attach (GTK_TABLE (output_tbl), os_label,
+                    0, 1, 2, 3, GTK_FILL, GTK_FILL, 1, 1);
+  os_entry = gtk_entry_new ();
+  gtk_widget_set_tooltip_markup (os_entry, _("For <b>local</b>, put the directory name on the conversion server.  For <b>rhev</b>, put the Export Storage Domain (server:/mountpoint).  For others, leave this field blank."));
+  if (config->output_storage != NULL)
+    gtk_entry_set_text (GTK_ENTRY (os_entry), config->output_storage);
+  gtk_table_attach (GTK_TABLE (output_tbl), os_entry,
+                    1, 2, 2, 3, GTK_FILL, GTK_FILL, 1, 1);
+
+  of_label = gtk_label_new (_("Output format (-of):"));
+  gtk_misc_set_alignment (GTK_MISC (of_label), 1., 0.5);
+  gtk_table_attach (GTK_TABLE (output_tbl), of_label,
+                    0, 1, 3, 4, GTK_FILL, GTK_FILL, 1, 1);
+  of_entry = gtk_entry_new ();
+  gtk_widget_set_tooltip_markup (of_entry, _("The output disk format, typically <b>raw</b> or <b>qcow2</b>.  If blank, defaults to <b>raw</b>."));
+  if (config->output_format != NULL)
+    gtk_entry_set_text (GTK_ENTRY (of_entry), config->output_format);
+  gtk_table_attach (GTK_TABLE (output_tbl), of_entry,
+                    1, 2, 3, 4, GTK_FILL, GTK_FILL, 1, 1);
+
+  oa_label = gtk_label_new (_("Output allocation (-oa):"));
+  gtk_misc_set_alignment (GTK_MISC (oa_label), 1., 0.5);
+  gtk_table_attach (GTK_TABLE (output_tbl), oa_label,
+                    0, 1, 4, 5, GTK_FILL, GTK_FILL, 1, 1);
+  oa_combo = gtk_combo_box_new_text ();
+  gtk_combo_box_append_text (GTK_COMBO_BOX (oa_combo), "sparse");
+  gtk_combo_box_append_text (GTK_COMBO_BOX (oa_combo), "preallocated");
+  switch (config->output_allocation) {
+  case OUTPUT_ALLOCATION_PREALLOCATED:
+    gtk_combo_box_set_active (GTK_COMBO_BOX (oa_combo), 1);
+    break;
+  default:
+    gtk_combo_box_set_active (GTK_COMBO_BOX (oa_combo), 0);
+    break;
+  }
+  gtk_table_attach (GTK_TABLE (output_tbl), oa_combo,
+                    1, 2, 4, 5, GTK_FILL, GTK_FILL, 1, 1);
+
   debug_button =
     gtk_check_button_new_with_label (_("Enable server-side debugging\n"
                                        "(This is saved in /tmp on the conversion server)"));
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (debug_button),
                                 config->verbose);
 
-  gtk_box_pack_start (GTK_BOX (target_vbox), target_tbl, TRUE, TRUE, 0);
-  gtk_box_pack_start (GTK_BOX (target_vbox), debug_button, TRUE, TRUE, 0);
-  gtk_container_add (GTK_CONTAINER (target), target_vbox);
+  gtk_box_pack_start (GTK_BOX (output_vbox), output_tbl, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (output_vbox), debug_button, TRUE, TRUE, 0);
+  gtk_container_add (GTK_CONTAINER (output_frame), output_vbox);
 
   /* The right column: select devices to be converted. */
   disks_frame = gtk_frame_new (_("Fixed hard disks"));
@@ -488,11 +578,15 @@ create_conversion_dialog (struct config *config)
                                          interfaces_list);
   gtk_container_add (GTK_CONTAINER (interfaces_frame), interfaces_sw);
 
+  /* Pack the top level dialog. */
+  gtk_box_pack_start (GTK_BOX (left_vbox), target_frame, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (left_vbox), output_frame, TRUE, TRUE, 0);
+
   gtk_box_pack_start (GTK_BOX (right_vbox), disks_frame, TRUE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX (right_vbox), removable_frame, TRUE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX (right_vbox), interfaces_frame, TRUE, TRUE, 0);
 
-  gtk_box_pack_start (GTK_BOX (hbox), target, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), left_vbox, TRUE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX (hbox), right_vbox, TRUE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (conv_dlg)->vbox),
                       hbox, TRUE, TRUE, 0);
@@ -902,8 +996,8 @@ start_conversion_clicked (GtkWidget *w, gpointer data)
 {
   struct config *config = data;
   int i;
-  const char *vcpus_str;
-  const char *memory_str;
+  const char *str;
+  char *str2;
   GtkWidget *dlg;
   struct config *copy;
   int err;
@@ -927,14 +1021,14 @@ start_conversion_clicked (GtkWidget *w, gpointer data)
     return;
   }
 
-  vcpus_str = gtk_entry_get_text (GTK_ENTRY (vcpus_entry));
-  if (sscanf (vcpus_str, "%d", &i) == 1 && i > 0)
+  str = gtk_entry_get_text (GTK_ENTRY (vcpus_entry));
+  if (sscanf (str, "%d", &i) == 1 && i > 0)
     config->vcpus = i;
   else
     config->vcpus = 1;
 
-  memory_str = gtk_entry_get_text (GTK_ENTRY (memory_entry));
-  if (sscanf (memory_str, "%d", &i) == 1 && i >= 256)
+  str = gtk_entry_get_text (GTK_ENTRY (memory_entry));
+  if (sscanf (str, "%d", &i) == 1 && i >= 256)
     config->memory = (uint64_t) i * 1024 * 1024;
   else
     config->memory = 1024 * 1024 * 1024;
@@ -963,6 +1057,41 @@ start_conversion_clicked (GtkWidget *w, gpointer data)
   set_removable_from_ui (config);
   set_interfaces_from_ui (config);
 
+  /* Output selection. */
+  free (config->output);
+  config->output = gtk_combo_box_get_active_text (GTK_COMBO_BOX (o_combo));
+
+  config->output_allocation = OUTPUT_ALLOCATION_NONE;
+  str2 = gtk_combo_box_get_active_text (GTK_COMBO_BOX (oa_combo));
+  if (str2) {
+    if (STREQ (str2, "sparse"))
+      config->output_allocation = OUTPUT_ALLOCATION_SPARSE;
+    else if (STREQ (str2, "preallocated"))
+      config->output_allocation = OUTPUT_ALLOCATION_PREALLOCATED;
+    free (str2);
+  }
+
+  free (config->output_connection);
+  str = gtk_entry_get_text (GTK_ENTRY (oc_entry));
+  if (str && STRNEQ (str, ""))
+    config->output_connection = strdup (str);
+  else
+    config->output_connection = NULL;
+
+  free (config->output_format);
+  str = gtk_entry_get_text (GTK_ENTRY (of_entry));
+  if (str && STRNEQ (str, ""))
+    config->output_format = strdup (str);
+  else
+    config->output_format = NULL;
+
+  free (config->output_storage);
+  str = gtk_entry_get_text (GTK_ENTRY (os_entry));
+  if (str && STRNEQ (str, ""))
+    config->output_storage = strdup (str);
+  else
+    config->output_storage = NULL;
+
   /* Display the UI for conversion. */
   show_running_dialog ();
 
diff --git a/v2v/TODO b/v2v/TODO
index a4978fc..bacad67 100644
--- a/v2v/TODO
+++ b/v2v/TODO
@@ -13,7 +13,6 @@ p2v:
  - short transfers?
  - network dialog and network configuration
  - GUI controls for network mapping
- - GUI controls for p2v.output, p2v.output_storage, etc.
 
 p2v/conversion.c:                "/tmp/virt-p2v-%04d%02d%02d-XXXXXXXX",
 p2v/conversion.c:                   " -o local -os /tmp" /* XXX */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list