Blame SOURCES/0035-launch-Remove-guestfs_int_print_timestamped_message-.patch

e76f14
From 076ecc7fd7987d9fd023a3b0e11bf15024b96957 Mon Sep 17 00:00:00 2001
e76f14
From: "Richard W.M. Jones" <rjones@redhat.com>
e76f14
Date: Sat, 19 Mar 2016 21:27:32 +0000
e76f14
Subject: [PATCH] launch: Remove guestfs_int_print_timestamped_message
e76f14
 function.
e76f14
e76f14
This function was kind of like debug(), except that it didn't check
e76f14
the g->verbose flag and it only worked in the library (it would crash
e76f14
if used after fork).
e76f14
e76f14
It also wasn't very useful.  The sort of boot analysis done by
e76f14
[forthcoming program] tests/qemu/boot-analysis.c means that
e76f14
timestamping (some) messages is even less interesting than before.
e76f14
e76f14
Remove it and replace calls with debug() instead.
e76f14
e76f14
(cherry picked from commit e94e61f76f5b0dcdcb0d1b7c74e53c7e3d7da5b2)
e76f14
---
e76f14
 src/appliance.c        |  9 +++------
e76f14
 src/guestfs-internal.h |  1 -
e76f14
 src/launch-direct.c    |  9 +++------
e76f14
 src/launch-libvirt.c   | 21 +++++++--------------
e76f14
 src/launch-uml.c       |  3 +--
e76f14
 src/launch-unix.c      |  6 ++----
e76f14
 src/launch.c           | 25 -------------------------
e76f14
 7 files changed, 16 insertions(+), 58 deletions(-)
e76f14
e76f14
diff --git a/src/appliance.c b/src/appliance.c
e76f14
index cf13091..1687a93 100644
e76f14
--- a/src/appliance.c
e76f14
+++ b/src/appliance.c
e76f14
@@ -220,18 +220,15 @@ build_supermin_appliance (guestfs_h *g,
e76f14
   appliancedir = safe_asprintf (g, "%s/appliance.d", cachedir);
e76f14
   lockfile = safe_asprintf (g, "%s/lock", cachedir);
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "begin building supermin appliance");
e76f14
+  debug (g, "begin building supermin appliance");
e76f14
 
e76f14
   /* Build the appliance if it needs to be built. */
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "run supermin");
e76f14
+  debug (g, "run supermin");
e76f14
 
e76f14
   if (run_supermin_build (g, lockfile, appliancedir, supermin_path) == -1)
e76f14
     return -1;
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "finished building supermin appliance");
e76f14
+  debug (g, "finished building supermin appliance");
e76f14
 
e76f14
   /* Return the appliance filenames. */
e76f14
   *kernel = safe_asprintf (g, "%s/kernel", appliancedir);
e76f14
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
e76f14
index 5dd0a32..44dae32 100644
e76f14
--- a/src/guestfs-internal.h
e76f14
+++ b/src/guestfs-internal.h
e76f14
@@ -760,7 +760,6 @@ extern int guestfs_int_get_uefi (guestfs_h *g, char **code, char **vars);
e76f14
 
e76f14
 /* launch.c */
e76f14
 extern int64_t guestfs_int_timeval_diff (const struct timeval *x, const struct timeval *y);
e76f14
-extern void guestfs_int_print_timestamped_message (guestfs_h *g, const char *fs, ...) __attribute__((format (printf,2,3)));
e76f14
 extern void guestfs_int_launch_send_progress (guestfs_h *g, int perdozen);
e76f14
 extern char *guestfs_int_appliance_command_line (guestfs_h *g, const char *appliance_dev, int flags);
e76f14
 #define APPLIANCE_COMMAND_LINE_IS_TCG 1
e76f14
diff --git a/src/launch-direct.c b/src/launch-direct.c
e76f14
index 646f9c6..8d99979 100644
e76f14
--- a/src/launch-direct.c
e76f14
+++ b/src/launch-direct.c
e76f14
@@ -290,8 +290,7 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
e76f14
 
e76f14
   guestfs_int_launch_send_progress (g, 3);
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "begin testing qemu features");
e76f14
+  debug (g, "begin testing qemu features");
e76f14
 
e76f14
   /* Get qemu help text and version. */
e76f14
   if (qemu_supports (g, data, NULL) == -1)
e76f14
@@ -331,8 +330,7 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
e76f14
     }
e76f14
   }
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "finished testing qemu features");
e76f14
+  debug (g, "finished testing qemu features");
e76f14
 
e76f14
   /* Construct the qemu command line.  We have to do this before
e76f14
    * forking, because after fork we are not allowed to use
e76f14
@@ -818,8 +816,7 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
e76f14
     goto cleanup1;
e76f14
   }
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "appliance is up");
e76f14
+  debug (g, "appliance is up");
e76f14
 
e76f14
   /* This is possible in some really strange situations, such as
e76f14
    * guestfsd starts up OK but then qemu immediately exits.  Check for
e76f14
diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
e76f14
index 4b87301..ceaa696 100644
e76f14
--- a/src/launch-libvirt.c
e76f14
+++ b/src/launch-libvirt.c
e76f14
@@ -347,8 +347,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
e76f14
   }
e76f14
   debug (g, "guest random name = %s", data->name);
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "connect to libvirt");
e76f14
+  debug (g, "connect to libvirt");
e76f14
 
e76f14
   /* Decode the URI string. */
e76f14
   if (!libvirt_uri) {           /* "libvirt" */
e76f14
@@ -387,8 +386,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
e76f14
     data->qemu_version = 0;
e76f14
   }
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "get libvirt capabilities");
e76f14
+  debug (g, "get libvirt capabilities");
e76f14
 
e76f14
   capabilities_xml = virConnectGetCapabilities (conn);
e76f14
   if (!capabilities_xml) {
e76f14
@@ -400,8 +398,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
e76f14
    * struct, and can also fail if we detect that the hypervisor cannot
e76f14
    * run qemu guests (RHBZ#886915).
e76f14
    */
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "parsing capabilities XML");
e76f14
+  debug (g, "parsing capabilities XML");
e76f14
 
e76f14
   if (parse_capabilities (g, capabilities_xml, data) == -1)
e76f14
     goto cleanup;
e76f14
@@ -425,8 +422,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
e76f14
   /* Locate and/or build the appliance. */
e76f14
   TRACE0 (launch_build_libvirt_appliance_start);
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "build appliance");
e76f14
+  debug (g, "build appliance");
e76f14
 
e76f14
   if (guestfs_int_build_appliance (g, &params.kernel, &params.dtb,
e76f14
 				   &params.initrd, &appliance) == -1)
e76f14
@@ -555,8 +551,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
e76f14
   }
e76f14
 
e76f14
   /* Construct the libvirt XML. */
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "create libvirt XML");
e76f14
+  debug (g, "create libvirt XML");
e76f14
 
e76f14
   params.appliance_index = g->nr_drives;
e76f14
   strcpy (params.appliance_dev, "/dev/sd");
e76f14
@@ -574,8 +569,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
e76f14
   }
e76f14
 
e76f14
   /* Launch the libvirt guest. */
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "launch libvirt guest");
e76f14
+  debug (g, "launch libvirt guest");
e76f14
 
e76f14
   dom = virDomainCreateXML (conn, (char *) xml, VIR_DOMAIN_START_AUTODESTROY);
e76f14
   if (!dom) {
e76f14
@@ -643,8 +637,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
e76f14
     goto cleanup;
e76f14
   }
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "appliance is up");
e76f14
+  debug (g, "appliance is up");
e76f14
 
e76f14
   /* This is possible in some really strange situations, such as
e76f14
    * guestfsd starts up OK but then qemu immediately exits.  Check for
e76f14
diff --git a/src/launch-uml.c b/src/launch-uml.c
e76f14
index 38be7a8..f6ed516 100644
e76f14
--- a/src/launch-uml.c
e76f14
+++ b/src/launch-uml.c
e76f14
@@ -456,8 +456,7 @@ launch_uml (guestfs_h *g, void *datav, const char *arg)
e76f14
     goto cleanup1;
e76f14
   }
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "appliance is up");
e76f14
+  debug (g, "appliance is up");
e76f14
 
e76f14
   /* This is possible in some really strange situations, such as
e76f14
    * guestfsd starts up OK but then vmlinux immediately exits.  Check
e76f14
diff --git a/src/launch-unix.c b/src/launch-unix.c
e76f14
index 428fdc6..f44c746 100644
e76f14
--- a/src/launch-unix.c
e76f14
+++ b/src/launch-unix.c
e76f14
@@ -59,8 +59,7 @@ launch_unix (guestfs_h *g, void *datav, const char *sockpath)
e76f14
     return -1;
e76f14
   }
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "connecting to %s", sockpath);
e76f14
+  debug (g, "connecting to %s", sockpath);
e76f14
 
e76f14
   daemon_sock = socket (AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
e76f14
   if (daemon_sock == -1) {
e76f14
@@ -96,8 +95,7 @@ launch_unix (guestfs_h *g, void *datav, const char *sockpath)
e76f14
     goto cleanup;
e76f14
   }
e76f14
 
e76f14
-  if (g->verbose)
e76f14
-    guestfs_int_print_timestamped_message (g, "connected");
e76f14
+  debug (g, "connected");
e76f14
 
e76f14
   if (g->state != READY) {
e76f14
     error (g, _("contacted guestfsd, but state != READY"));
e76f14
diff --git a/src/launch.c b/src/launch.c
e76f14
index 40b4810..0eb7d18 100644
e76f14
--- a/src/launch.c
e76f14
+++ b/src/launch.c
e76f14
@@ -127,31 +127,6 @@ guestfs_int_launch_send_progress (guestfs_h *g, int perdozen)
e76f14
   }
e76f14
 }
e76f14
 
e76f14
-/* Note that since this calls 'debug' it should only be called
e76f14
- * from the parent process.
e76f14
- */
e76f14
-void
e76f14
-guestfs_int_print_timestamped_message (guestfs_h *g, const char *fs, ...)
e76f14
-{
e76f14
-  va_list args;
e76f14
-  char *msg;
e76f14
-  int err;
e76f14
-  struct timeval tv;
e76f14
-
e76f14
-  va_start (args, fs);
e76f14
-  err = vasprintf (&msg, fs, args);
e76f14
-  va_end (args);
e76f14
-
e76f14
-  if (err < 0) return;
e76f14
-
e76f14
-  gettimeofday (&tv, NULL);
e76f14
-
e76f14
-  debug (g, "[%05" PRIi64 "ms] %s",
e76f14
-         guestfs_int_timeval_diff (&g->launch_t, &tv), msg);
e76f14
-
e76f14
-  free (msg);
e76f14
-}
e76f14
-
e76f14
 /* Compute Y - X and return the result in milliseconds.
e76f14
  * Approximately the same as this code:
e76f14
  * http://www.mpp.mpg.de/~huber/util/timevaldiff.c
e76f14
-- 
aa0300
2.7.4
e76f14