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
tests/qemu/boot-analysis.c means that timestamping (some) messages is
even less interesting than before.
Remove it and replace calls with debug() instead.
---
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 de088e9..864761f 100644
--- a/src/appliance.c
+++ b/src/appliance.c
@@ -233,18 +233,15 @@ build_supermin_appliance (guestfs_h *g,
}
(void) utimes (cachedir, NULL);
- 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 3707c1b..61f384c 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -778,7 +778,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 f1fe92b..3ed840d 100644
--- a/src/launch-direct.c
+++ b/src/launch-direct.c
@@ -285,8 +285,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)
@@ -327,8 +326,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
@@ -815,8 +813,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 cdc83f4..9f2672d 100644
--- a/src/launch-libvirt.c
+++ b/src/launch-libvirt.c
@@ -286,8 +286,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" */
@@ -326,8 +325,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) {
@@ -339,8 +337,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;
@@ -373,8 +370,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, ¶ms.kernel, ¶ms.initrd,
&appliance) == -1)
@@ -503,8 +499,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");
@@ -522,8 +517,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) {
@@ -591,8 +585,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 1c2fd02..318081c 100644
--- a/src/launch-uml.c
+++ b/src/launch-uml.c
@@ -446,8 +446,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 973e14b..212de69 100644
--- a/src/launch-unix.c
+++ b/src/launch-unix.c
@@ -53,8 +53,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) {
@@ -90,8 +89,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 074ac6f..f553bd3 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -119,31 +119,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
--
2.5.0