Blob Blame History Raw
From 076ecc7fd7987d9fd023a3b0e11bf15024b96957 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 19 Mar 2016 21:27:32 +0000
Subject: [PATCH] launch: Remove guestfs_int_print_timestamped_message
 function.

This function was kind of like debug(), except that it didn't check
the g->verbose flag and it only worked in the library (it would crash
if used after fork).

It also wasn't very useful.  The sort of boot analysis done by
[forthcoming program] tests/qemu/boot-analysis.c means that
timestamping (some) messages is even less interesting than before.

Remove it and replace calls with debug() instead.

(cherry picked from commit e94e61f76f5b0dcdcb0d1b7c74e53c7e3d7da5b2)
---
 src/appliance.c        |  9 +++------
 src/guestfs-internal.h |  1 -
 src/launch-direct.c    |  9 +++------
 src/launch-libvirt.c   | 21 +++++++--------------
 src/launch-uml.c       |  3 +--
 src/launch-unix.c      |  6 ++----
 src/launch.c           | 25 -------------------------
 7 files changed, 16 insertions(+), 58 deletions(-)

diff --git a/src/appliance.c b/src/appliance.c
index cf13091..1687a93 100644
--- a/src/appliance.c
+++ b/src/appliance.c
@@ -220,18 +220,15 @@ build_supermin_appliance (guestfs_h *g,
   appliancedir = safe_asprintf (g, "%s/appliance.d", cachedir);
   lockfile = safe_asprintf (g, "%s/lock", cachedir);
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "begin building supermin appliance");
+  debug (g, "begin building supermin appliance");
 
   /* Build the appliance if it needs to be built. */
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "run supermin");
+  debug (g, "run supermin");
 
   if (run_supermin_build (g, lockfile, appliancedir, supermin_path) == -1)
     return -1;
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "finished building supermin appliance");
+  debug (g, "finished building supermin appliance");
 
   /* Return the appliance filenames. */
   *kernel = safe_asprintf (g, "%s/kernel", appliancedir);
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index 5dd0a32..44dae32 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -760,7 +760,6 @@ extern int guestfs_int_get_uefi (guestfs_h *g, char **code, char **vars);
 
 /* launch.c */
 extern int64_t guestfs_int_timeval_diff (const struct timeval *x, const struct timeval *y);
-extern void guestfs_int_print_timestamped_message (guestfs_h *g, const char *fs, ...) __attribute__((format (printf,2,3)));
 extern void guestfs_int_launch_send_progress (guestfs_h *g, int perdozen);
 extern char *guestfs_int_appliance_command_line (guestfs_h *g, const char *appliance_dev, int flags);
 #define APPLIANCE_COMMAND_LINE_IS_TCG 1
diff --git a/src/launch-direct.c b/src/launch-direct.c
index 646f9c6..8d99979 100644
--- a/src/launch-direct.c
+++ b/src/launch-direct.c
@@ -290,8 +290,7 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
 
   guestfs_int_launch_send_progress (g, 3);
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "begin testing qemu features");
+  debug (g, "begin testing qemu features");
 
   /* Get qemu help text and version. */
   if (qemu_supports (g, data, NULL) == -1)
@@ -331,8 +330,7 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
     }
   }
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "finished testing qemu features");
+  debug (g, "finished testing qemu features");
 
   /* Construct the qemu command line.  We have to do this before
    * forking, because after fork we are not allowed to use
@@ -818,8 +816,7 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
     goto cleanup1;
   }
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "appliance is up");
+  debug (g, "appliance is up");
 
   /* This is possible in some really strange situations, such as
    * guestfsd starts up OK but then qemu immediately exits.  Check for
diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
index 4b87301..ceaa696 100644
--- a/src/launch-libvirt.c
+++ b/src/launch-libvirt.c
@@ -347,8 +347,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
   }
   debug (g, "guest random name = %s", data->name);
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "connect to libvirt");
+  debug (g, "connect to libvirt");
 
   /* Decode the URI string. */
   if (!libvirt_uri) {           /* "libvirt" */
@@ -387,8 +386,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
     data->qemu_version = 0;
   }
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "get libvirt capabilities");
+  debug (g, "get libvirt capabilities");
 
   capabilities_xml = virConnectGetCapabilities (conn);
   if (!capabilities_xml) {
@@ -400,8 +398,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
    * struct, and can also fail if we detect that the hypervisor cannot
    * run qemu guests (RHBZ#886915).
    */
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "parsing capabilities XML");
+  debug (g, "parsing capabilities XML");
 
   if (parse_capabilities (g, capabilities_xml, data) == -1)
     goto cleanup;
@@ -425,8 +422,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
   /* Locate and/or build the appliance. */
   TRACE0 (launch_build_libvirt_appliance_start);
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "build appliance");
+  debug (g, "build appliance");
 
   if (guestfs_int_build_appliance (g, &params.kernel, &params.dtb,
 				   &params.initrd, &appliance) == -1)
@@ -555,8 +551,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
   }
 
   /* Construct the libvirt XML. */
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "create libvirt XML");
+  debug (g, "create libvirt XML");
 
   params.appliance_index = g->nr_drives;
   strcpy (params.appliance_dev, "/dev/sd");
@@ -574,8 +569,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
   }
 
   /* Launch the libvirt guest. */
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "launch libvirt guest");
+  debug (g, "launch libvirt guest");
 
   dom = virDomainCreateXML (conn, (char *) xml, VIR_DOMAIN_START_AUTODESTROY);
   if (!dom) {
@@ -643,8 +637,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
     goto cleanup;
   }
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "appliance is up");
+  debug (g, "appliance is up");
 
   /* This is possible in some really strange situations, such as
    * guestfsd starts up OK but then qemu immediately exits.  Check for
diff --git a/src/launch-uml.c b/src/launch-uml.c
index 38be7a8..f6ed516 100644
--- a/src/launch-uml.c
+++ b/src/launch-uml.c
@@ -456,8 +456,7 @@ launch_uml (guestfs_h *g, void *datav, const char *arg)
     goto cleanup1;
   }
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "appliance is up");
+  debug (g, "appliance is up");
 
   /* This is possible in some really strange situations, such as
    * guestfsd starts up OK but then vmlinux immediately exits.  Check
diff --git a/src/launch-unix.c b/src/launch-unix.c
index 428fdc6..f44c746 100644
--- a/src/launch-unix.c
+++ b/src/launch-unix.c
@@ -59,8 +59,7 @@ launch_unix (guestfs_h *g, void *datav, const char *sockpath)
     return -1;
   }
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "connecting to %s", sockpath);
+  debug (g, "connecting to %s", sockpath);
 
   daemon_sock = socket (AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
   if (daemon_sock == -1) {
@@ -96,8 +95,7 @@ launch_unix (guestfs_h *g, void *datav, const char *sockpath)
     goto cleanup;
   }
 
-  if (g->verbose)
-    guestfs_int_print_timestamped_message (g, "connected");
+  debug (g, "connected");
 
   if (g->state != READY) {
     error (g, _("contacted guestfsd, but state != READY"));
diff --git a/src/launch.c b/src/launch.c
index 40b4810..0eb7d18 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -127,31 +127,6 @@ guestfs_int_launch_send_progress (guestfs_h *g, int perdozen)
   }
 }
 
-/* Note that since this calls 'debug' it should only be called
- * from the parent process.
- */
-void
-guestfs_int_print_timestamped_message (guestfs_h *g, const char *fs, ...)
-{
-  va_list args;
-  char *msg;
-  int err;
-  struct timeval tv;
-
-  va_start (args, fs);
-  err = vasprintf (&msg, fs, args);
-  va_end (args);
-
-  if (err < 0) return;
-
-  gettimeofday (&tv, NULL);
-
-  debug (g, "[%05" PRIi64 "ms] %s",
-         guestfs_int_timeval_diff (&g->launch_t, &tv), msg);
-
-  free (msg);
-}
-
 /* Compute Y - X and return the result in milliseconds.
  * Approximately the same as this code:
  * http://www.mpp.mpg.de/~huber/util/timevaldiff.c
-- 
1.8.3.1