Blame SOURCES/0188-p2v-Refactor-code-that-dumps-the-configuration-for-d.patch

ffd6ed
From 8c60ca8a5593415c93dc5e82ee15a4b5a8cd0423 Mon Sep 17 00:00:00 2001
ffd6ed
From: "Richard W.M. Jones" <rjones@redhat.com>
ffd6ed
Date: Wed, 10 Jun 2015 14:03:43 +0100
ffd6ed
Subject: [PATCH] p2v: Refactor code that dumps the configuration for
ffd6ed
 debugging.
ffd6ed
ffd6ed
This is just code motion.
ffd6ed
ffd6ed
(cherry picked from commit 4c8bbc45bedce9d9eab1b95c1ec4c3b3082fddd9)
ffd6ed
---
ffd6ed
 p2v/config.c     | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ffd6ed
 p2v/conversion.c | 68 ++++--------------------------------------------------
ffd6ed
 p2v/p2v.h        |  3 +++
ffd6ed
 3 files changed, 77 insertions(+), 64 deletions(-)
ffd6ed
ffd6ed
diff --git a/p2v/config.c b/p2v/config.c
ffd6ed
index 495bca2..b32b5ca 100644
ffd6ed
--- a/p2v/config.c
ffd6ed
+++ b/p2v/config.c
ffd6ed
@@ -103,3 +103,73 @@ free_config (struct config *c)
ffd6ed
   free (c->output_storage);
ffd6ed
   free (c);
ffd6ed
 }
ffd6ed
+
ffd6ed
+/* Print the conversion parameters and other important information. */
ffd6ed
+void
ffd6ed
+print_config (struct config *config, FILE *fp)
ffd6ed
+{
ffd6ed
+  size_t i;
ffd6ed
+
ffd6ed
+  fprintf (fp, "local version   .  %s\n", PACKAGE_VERSION);
ffd6ed
+  fprintf (fp, "remote version  .  %d.%d.%d\n",
ffd6ed
+           v2v_major, v2v_minor, v2v_release);
ffd6ed
+  fprintf (fp, "remote debugging   %s\n",
ffd6ed
+           config->verbose ? "true" : "false");
ffd6ed
+  fprintf (fp, "conversion server  %s\n",
ffd6ed
+           config->server ? config->server : "none");
ffd6ed
+  fprintf (fp, "port . . . . . .   %d\n", config->port);
ffd6ed
+  fprintf (fp, "username . . . .   %s\n",
ffd6ed
+           config->username ? config->username : "none");
ffd6ed
+  fprintf (fp, "password . . . .   %s\n",
ffd6ed
+           config->password && strlen (config->password) > 0 ? "***" : "none");
ffd6ed
+  fprintf (fp, "sudo . . . . . .   %s\n",
ffd6ed
+           config->sudo ? "true" : "false");
ffd6ed
+  fprintf (fp, "guest name . . .   %s\n",
ffd6ed
+           config->guestname ? config->guestname : "none");
ffd6ed
+  fprintf (fp, "vcpus  . . . . .   %d\n", config->vcpus);
ffd6ed
+  fprintf (fp, "memory . . . . .   %" PRIu64 "\n", config->memory);
ffd6ed
+  fprintf (fp, "flags  . . . . .  %s%s%s\n",
ffd6ed
+           config->flags & FLAG_ACPI ? " acpi" : "",
ffd6ed
+           config->flags & FLAG_APIC ? " apic" : "",
ffd6ed
+           config->flags & FLAG_PAE  ? " pae"  : "");
ffd6ed
+  fprintf (fp, "disks  . . . . .  ");
ffd6ed
+  if (config->disks != NULL) {
ffd6ed
+    for (i = 0; config->disks[i] != NULL; ++i)
ffd6ed
+      fprintf (fp, " %s", config->disks[i]);
ffd6ed
+  }
ffd6ed
+  fprintf (fp, "\n");
ffd6ed
+  fprintf (fp, "removable  . . .  ");
ffd6ed
+  if (config->removable != NULL) {
ffd6ed
+    for (i = 0; config->removable[i] != NULL; ++i)
ffd6ed
+      fprintf (fp, " %s", config->removable[i]);
ffd6ed
+  }
ffd6ed
+  fprintf (fp, "\n");
ffd6ed
+  fprintf (fp, "interfaces . . .  ");
ffd6ed
+  if (config->interfaces != NULL) {
ffd6ed
+    for (i = 0; config->interfaces[i] != NULL; ++i)
ffd6ed
+      fprintf (fp, " %s", config->interfaces[i]);
ffd6ed
+  }
ffd6ed
+  fprintf (fp, "\n");
ffd6ed
+  fprintf (fp, "network map  . .  ");
ffd6ed
+  if (config->network_map != NULL) {
ffd6ed
+    for (i = 0; config->network_map[i] != NULL; ++i)
ffd6ed
+      fprintf (fp, " %s", config->network_map[i]);
ffd6ed
+  }
ffd6ed
+  fprintf (fp, "\n");
ffd6ed
+  fprintf (fp, "output . . . . .   %s\n",
ffd6ed
+           config->output ? config->output : "none");
ffd6ed
+  fprintf (fp, "output alloc . .   ");
ffd6ed
+  switch (config->output_allocation) {
ffd6ed
+  case OUTPUT_ALLOCATION_NONE:         fprintf (fp, "none"); break;
ffd6ed
+  case OUTPUT_ALLOCATION_SPARSE:       fprintf (fp, "sparse"); break;
ffd6ed
+  case OUTPUT_ALLOCATION_PREALLOCATED: fprintf (fp, "preallocated"); break;
ffd6ed
+  default: fprintf (fp, "unknown? (%d)", config->output_allocation);
ffd6ed
+  }
ffd6ed
+  fprintf (fp, "\n");
ffd6ed
+  fprintf (fp, "output conn  . .   %s\n",
ffd6ed
+           config->output_connection ? config->output_connection : "none");
ffd6ed
+  fprintf (fp, "output format  .   %s\n",
ffd6ed
+           config->output_format ? config->output_format : "none");
ffd6ed
+  fprintf (fp, "output storage .   %s\n",
ffd6ed
+           config->output_storage ? config->output_storage : "none");
ffd6ed
+}
ffd6ed
diff --git a/p2v/conversion.c b/p2v/conversion.c
ffd6ed
index 6c03ab9..b1cb2e7 100644
ffd6ed
--- a/p2v/conversion.c
ffd6ed
+++ b/p2v/conversion.c
ffd6ed
@@ -58,7 +58,6 @@ static int wait_qemu_nbd (int nbd_local_port, int timeout_seconds);
ffd6ed
 static void cleanup_data_conns (struct data_conn *data_conns, size_t nr);
ffd6ed
 static char *generate_libvirt_xml (struct config *, struct data_conn *);
ffd6ed
 static const char *map_interface_to_network (struct config *, const char *interface);
ffd6ed
-static void debug_parameters (struct config *);
ffd6ed
 
ffd6ed
 static char *conversion_error;
ffd6ed
 
ffd6ed
@@ -109,7 +108,10 @@ start_conversion (struct config *config,
ffd6ed
   struct tm tm;
ffd6ed
   mexp_h *control_h = NULL;
ffd6ed
 
ffd6ed
-  debug_parameters (config);
ffd6ed
+#if DEBUG_STDERR
ffd6ed
+  print_config (config, stderr);
ffd6ed
+  fprintf (stderr, "\n");
ffd6ed
+#endif
ffd6ed
 
ffd6ed
   for (i = 0; config->disks[i] != NULL; ++i) {
ffd6ed
     data_conns[i].h = NULL;
ffd6ed
@@ -800,65 +802,3 @@ map_interface_to_network (struct config *config, const char *interface)
ffd6ed
   /* No mapping found. */
ffd6ed
   return "default";
ffd6ed
 }
ffd6ed
-
ffd6ed
-static void
ffd6ed
-debug_parameters (struct config *config)
ffd6ed
-{
ffd6ed
-#if DEBUG_STDERR
ffd6ed
-  size_t i;
ffd6ed
-
ffd6ed
-  /* Print the conversion parameters and other important information. */
ffd6ed
-  fprintf (stderr, "local version   .  %s\n", PACKAGE_VERSION);
ffd6ed
-  fprintf (stderr, "remote version  .  %d.%d.%d\n",
ffd6ed
-           v2v_major, v2v_minor, v2v_release);
ffd6ed
-  fprintf (stderr, "remote debugging   %s\n",
ffd6ed
-           config->verbose ? "true" : "false");
ffd6ed
-  fprintf (stderr, "conversion server  %s\n",
ffd6ed
-           config->server ? config->server : "none");
ffd6ed
-  fprintf (stderr, "port . . . . . .   %d\n", config->port);
ffd6ed
-  fprintf (stderr, "username . . . .   %s\n",
ffd6ed
-           config->username ? config->username : "none");
ffd6ed
-  fprintf (stderr, "password . . . .   %s\n",
ffd6ed
-           config->password && strlen (config->password) > 0 ? "***" : "none");
ffd6ed
-  fprintf (stderr, "sudo . . . . . .   %s\n",
ffd6ed
-           config->sudo ? "true" : "false");
ffd6ed
-  fprintf (stderr, "guest name . . .   %s\n",
ffd6ed
-           config->guestname ? config->guestname : "none");
ffd6ed
-  fprintf (stderr, "vcpus  . . . . .   %d\n", config->vcpus);
ffd6ed
-  fprintf (stderr, "memory . . . . .   %" PRIu64 "\n", config->memory);
ffd6ed
-  fprintf (stderr, "disks  . . . . .  ");
ffd6ed
-  if (config->disks != NULL) {
ffd6ed
-    for (i = 0; config->disks[i] != NULL; ++i)
ffd6ed
-      fprintf (stderr, " %s", config->disks[i]);
ffd6ed
-  }
ffd6ed
-  fprintf (stderr, "\n");
ffd6ed
-  fprintf (stderr, "removable  . . .  ");
ffd6ed
-  if (config->removable != NULL) {
ffd6ed
-    for (i = 0; config->removable[i] != NULL; ++i)
ffd6ed
-      fprintf (stderr, " %s", config->removable[i]);
ffd6ed
-  }
ffd6ed
-  fprintf (stderr, "\n");
ffd6ed
-  fprintf (stderr, "interfaces . . .  ");
ffd6ed
-  if (config->interfaces != NULL) {
ffd6ed
-    for (i = 0; config->interfaces[i] != NULL; ++i)
ffd6ed
-      fprintf (stderr, " %s", config->interfaces[i]);
ffd6ed
-  }
ffd6ed
-  fprintf (stderr, "\n");
ffd6ed
-  fprintf (stderr, "network map  . .  ");
ffd6ed
-  if (config->network_map != NULL) {
ffd6ed
-    for (i = 0; config->network_map[i] != NULL; ++i)
ffd6ed
-      fprintf (stderr, " %s", config->network_map[i]);
ffd6ed
-  }
ffd6ed
-  fprintf (stderr, "\n");
ffd6ed
-  fprintf (stderr, "output . . . . .   %s\n",
ffd6ed
-           config->output ? config->output : "none");
ffd6ed
-  fprintf (stderr, "output alloc . .   %d\n", config->output_allocation);
ffd6ed
-  fprintf (stderr, "output conn  . .   %s\n",
ffd6ed
-           config->output_connection ? config->output_connection : "none");
ffd6ed
-  fprintf (stderr, "output format  .   %s\n",
ffd6ed
-           config->output_format ? config->output_format : "none");
ffd6ed
-  fprintf (stderr, "output storage .   %s\n",
ffd6ed
-           config->output_storage ? config->output_storage : "none");
ffd6ed
-  fprintf (stderr, "\n");
ffd6ed
-#endif
ffd6ed
-}
ffd6ed
diff --git a/p2v/p2v.h b/p2v/p2v.h
ffd6ed
index 41d305d..a588893 100644
ffd6ed
--- a/p2v/p2v.h
ffd6ed
+++ b/p2v/p2v.h
ffd6ed
@@ -19,6 +19,8 @@
ffd6ed
 #ifndef P2V_H
ffd6ed
 #define P2V_H
ffd6ed
 
ffd6ed
+#include <stdio.h>
ffd6ed
+
ffd6ed
 /* Send various debug information to stderr.  Harmless and useful, so
ffd6ed
  * can be left enabled in production builds.
ffd6ed
  */
ffd6ed
@@ -84,6 +86,7 @@ struct config {
ffd6ed
 extern struct config *new_config (void);
ffd6ed
 extern struct config *copy_config (struct config *);
ffd6ed
 extern void free_config (struct config *);
ffd6ed
+extern void print_config (struct config *, FILE *);
ffd6ed
 
ffd6ed
 /* kernel-cmdline.c */
ffd6ed
 extern char **parse_cmdline_string (const char *cmdline);
ffd6ed
-- 
ffd6ed
1.8.3.1
ffd6ed