mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone
Blob Blame History Raw
From 9b713219612d9ad012729a98d58f033c2bb40ccf Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 6 Jul 2016 12:58:49 -0400
Subject: [PATCH] p2v: Remove the Enable debugging option, -v, p2v.debug.

This is now enabled by default and cannot be changed/disabled by the
user.  The output is saved into /tmp/.../virt-v2v-conversion-log.txt
on the conversion server.

(cherry picked from commit 0c04919f50685c583842b48ca035626753e959e5)
---
 p2v/config.c     |  5 -----
 p2v/conversion.c |  4 +---
 p2v/gui.c        | 11 -----------
 p2v/kernel.c     | 22 +++++++++-------------
 p2v/main.c       |  4 +++-
 p2v/p2v.h        |  7 -------
 p2v/ssh.c        |  7 +++----
 p2v/utils.c      | 10 +++++-----
 p2v/virt-p2v.pod | 19 ++-----------------
 9 files changed, 23 insertions(+), 66 deletions(-)

diff --git a/p2v/config.c b/p2v/config.c
index 79b7e4d..40c758e 100644
--- a/p2v/config.c
+++ b/p2v/config.c
@@ -40,9 +40,6 @@ new_config (void)
     exit (EXIT_FAILURE);
   }
 
-#if FORCE_REMOTE_DEBUG
-  c->verbose = 1;
-#endif
   c->port = 22;
 
   c->output_allocation = OUTPUT_ALLOCATION_NONE;
@@ -119,8 +116,6 @@ print_config (struct config *config, FILE *fp)
   fprintf (fp, "local version   .  %s\n", PACKAGE_VERSION_FULL);
   fprintf (fp, "remote version  .  %s\n",
            v2v_version ? v2v_version : "unknown");
-  fprintf (fp, "remote debugging   %s\n",
-           config->verbose ? "true" : "false");
   fprintf (fp, "conversion server  %s\n",
            config->server ? config->server : "none");
   fprintf (fp, "port . . . . . .   %d\n", config->port);
diff --git a/p2v/conversion.c b/p2v/conversion.c
index 484c0e4..2d125a8 100644
--- a/p2v/conversion.c
+++ b/p2v/conversion.c
@@ -960,9 +960,7 @@ generate_wrapper_script (struct config *config, const char *remote_dir,
   fprintf (fp, "{\n");
   if (config->sudo)
     fprintf (fp, "sudo -n ");
-  fprintf (fp, "virt-v2v");
-  if (config->verbose)
-    fprintf (fp, " -v -x");
+  fprintf (fp, "virt-v2v -v -x");
   if (feature_colours_option)
     fprintf (fp, " --colours");
   fprintf (fp, " -i libvirtxml");
diff --git a/p2v/gui.c b/p2v/gui.c
index 9e9043a..e0b455a 100644
--- a/p2v/gui.c
+++ b/p2v/gui.c
@@ -63,7 +63,6 @@ static GtkWidget *conv_dlg,
   *vcpus_warning, *memory_warning, *target_warning_label,
   *o_combo, *oc_entry, *os_entry, *of_entry, *oa_combo,
   *info_label,
-  *debug_button,
   *disks_list, *removable_list, *interfaces_list,
   *start_button;
 
@@ -674,14 +673,7 @@ create_conversion_dialog (struct config *config)
   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 (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);
 
   info_frame = gtk_frame_new (_("Information"));
@@ -1688,9 +1680,6 @@ start_conversion_clicked (GtkWidget *w, gpointer data)
   config->vcpus = get_vcpus_from_conv_dlg ();
   config->memory = get_memory_from_conv_dlg ();
 
-  config->verbose =
-    gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (debug_button));
-
   /* Get the list of disks to be converted. */
   set_disks_from_ui (config);
 
diff --git a/p2v/kernel.c b/p2v/kernel.c
index 6914ab5..455af3e 100644
--- a/p2v/kernel.c
+++ b/p2v/kernel.c
@@ -35,17 +35,13 @@
 #include "p2v.h"
 
 static void notify_ui_callback (int type, const char *data);
-static void run_command (int verbose, const char *stage, const char *command);
+static void run_command (const char *stage, const char *command);
 
 void
 update_config_from_kernel_cmdline (struct config *config, char **cmdline)
 {
   const char *p;
 
-  p = get_cmdline_key (cmdline, "p2v.debug");
-  if (p)
-    config->verbose = 1;
-
   p = get_cmdline_key (cmdline, "p2v.server");
   if (p) {
     free (config->server);
@@ -212,7 +208,7 @@ kernel_conversion (struct config *config, char **cmdline, int cmdline_source)
   /* Pre-conversion command. */
   p = get_cmdline_key (cmdline, "p2v.pre");
   if (p)
-    run_command (config->verbose, "p2v.pre", p);
+    run_command ("p2v.pre", p);
 
   /* Connect to and interrogate virt-v2v on the conversion server. */
   p = get_cmdline_key (cmdline, "p2v.skip_test_connection");
@@ -245,7 +241,7 @@ kernel_conversion (struct config *config, char **cmdline, int cmdline_source)
 
     p = get_cmdline_key (cmdline, "p2v.fail");
     if (p)
-      run_command (config->verbose, "p2v.fail", p);
+      run_command ("p2v.fail", p);
 
     exit (EXIT_FAILURE);
   }
@@ -261,7 +257,7 @@ kernel_conversion (struct config *config, char **cmdline, int cmdline_source)
       p = "poweroff";
   }
   if (p)
-    run_command (config->verbose, "p2v.post", p);
+    run_command ("p2v.post", p);
 }
 
 static void
@@ -300,17 +296,17 @@ notify_ui_callback (int type, const char *data)
 }
 
 static void
-run_command (int verbose, const char *stage, const char *command)
+run_command (const char *stage, const char *command)
 {
   int r;
 
   if (STREQ (command, ""))
     return;
 
-  if (verbose) {
-    printf ("%s\n", command);
-    fflush (stdout);
-  }
+#if DEBUG_STDERR
+  fprintf (stderr, "%s\n", command);
+  fflush (stderr);
+#endif
 
   r = system (command);
   if (r == -1) {
diff --git a/p2v/main.c b/p2v/main.c
index c5ab233..4441b99 100644
--- a/p2v/main.c
+++ b/p2v/main.c
@@ -181,7 +181,9 @@ main (int argc, char *argv[])
       break;
 
     case 'v':
-      config->verbose = 1;
+      /* This option does nothing since 1.33.41.  Verbose is always
+       * enabled.
+       */
       break;
 
     case 'V':
diff --git a/p2v/p2v.h b/p2v/p2v.h
index da30340..1282a17 100644
--- a/p2v/p2v.h
+++ b/p2v/p2v.h
@@ -26,12 +26,6 @@
  */
 #define DEBUG_STDERR 1
 
-/* Force remote debugging even if user doesn't enable it.  Since
- * remote debugging is mostly free, we might as well enable this even
- * in production.
- */
-#define FORCE_REMOTE_DEBUG 1
-
 #include "miniexpect.h"
 
 /* We don't use libguestfs directly here, and we don't link to it
@@ -66,7 +60,6 @@ extern int force_colour;
 
 /* config.c */
 struct config {
-  int verbose;
   char *server;
   int port;
   char *username;
diff --git a/p2v/ssh.c b/p2v/ssh.c
index 4cae732..7507ed6 100644
--- a/p2v/ssh.c
+++ b/p2v/ssh.c
@@ -374,7 +374,7 @@ start_ssh (unsigned spawn_flags, struct config *config,
   args[j++] = NULL;
   assert (j == nr_args);
 
-#if DEBUG_STDERR && 0
+#if DEBUG_STDERR
   fputs ("ssh command: ", stderr);
   for (i = 0; i < nr_args - 1; ++i) {
     if (i > 0) fputc (' ', stderr);
@@ -583,6 +583,7 @@ scp_file (struct config *config, const char *localfile, const char *remotefile)
   const int ovecsize = 12;
   int ovector[ovecsize];
   int using_password_auth;
+  size_t i;
 
   if (cache_ssh_identity (config) == -1)
     return -1;
@@ -631,9 +632,7 @@ scp_file (struct config *config, const char *localfile, const char *remotefile)
   args[j++] = NULL;
   assert (j == nr_args);
 
-#if DEBUG_STDERR && 0
-  size_t i;
-
+#if DEBUG_STDERR
   fputs ("scp command: ", stderr);
   for (i = 0; i < nr_args - 1; ++i) {
     if (i > 0) fputc (' ', stderr);
diff --git a/p2v/utils.c b/p2v/utils.c
index c9fbd2f..71f5916 100644
--- a/p2v/utils.c
+++ b/p2v/utils.c
@@ -247,11 +247,11 @@ get_if_vendor (const char *if_name, int truncate)
 void
 wait_network_online (const struct config *config)
 {
-  if (config->verbose) {
-    printf ("waiting for the network to come online ...\n");
-    printf ("%s\n", NETWORK_ONLINE_COMMAND);
-    fflush (stdout);
-  }
+#ifdef DEBUG_STDERR
+  fprintf (stderr, "waiting for the network to come online ...\n");
+  fprintf (stderr, "%s\n", NETWORK_ONLINE_COMMAND);
+  fflush (stderr);
+#endif
 
   ignore_value (system (NETWORK_ONLINE_COMMAND));
 }
diff --git a/p2v/virt-p2v.pod b/p2v/virt-p2v.pod
index ef6a9db..6532240 100644
--- a/p2v/virt-p2v.pod
+++ b/p2v/virt-p2v.pod
@@ -177,14 +177,6 @@ first-time virt-p2v user.
 All output options and paths are relative to the conversion server
 (I<not> to the physical server).
 
-The final option in this panel enables server-side debugging.  This
-produces a lot of output, but is essential if you are tracking down
-virt-p2v or virt-v2v problems, and can generally be left enabled:
-
- │
- │ [✔] Enable server-side debugging
- │
-
 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
@@ -371,14 +363,6 @@ C<p2v.memory=1G>.
 The default is to use the same amount of RAM as on the physical
 machine.
 
-=item B<p2v.debug>
-
-Use this to enable full debugging of virt-v2v.
-
-If asked to diagnose a problem with virt-p2v, you should add
-C<p2v.debug> to the kernel command line, and examine the log file
-which is left in F</tmp> on the conversion server.
-
 =item B<p2v.disks=sdX,sdY,..>
 
 A list of physical hard disks to convert, for example:
@@ -615,7 +599,8 @@ features such as the Reboot button.
 
 =item B<--verbose>
 
-Enable debugging (on the conversion server).
+In libguestfs E<ge> 1.33.41, debugging is always enabled on the
+conversion server, and this option does nothing.
 
 =item B<-V>
 
-- 
2.7.4