summaryrefslogtreecommitdiffstats
path: root/src/launch-appliance.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-07-19 20:24:39 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-07-20 13:43:13 +0100
commit4df6beee54ca870faa92bcee346a671e19c80237 (patch)
treeb720d9d2912f5023580f20195430aeaec17eab71 /src/launch-appliance.c
parent54fd9a10a6da427f3888e913a9f942375e83c189 (diff)
downloadlibguestfs-4df6beee54ca870faa92bcee346a671e19c80237.tar.gz
libguestfs-4df6beee54ca870faa92bcee346a671e19c80237.tar.xz
libguestfs-4df6beee54ca870faa92bcee346a671e19c80237.zip
launch: Move launch timing / messages code into launch.c.
Diffstat (limited to 'src/launch-appliance.c')
-rw-r--r--src/launch-appliance.c74
1 files changed, 2 insertions, 72 deletions
diff --git a/src/launch-appliance.c b/src/launch-appliance.c
index 64bbebc1..6b4be356 100644
--- a/src/launch-appliance.c
+++ b/src/launch-appliance.c
@@ -36,7 +36,6 @@
#include "guestfs_protocol.h"
static int is_openable (guestfs_h *g, const char *path, int flags);
-static int64_t timeval_diff (const struct timeval *x, const struct timeval *y);
static void print_qemu_command_line (guestfs_h *g, char **argv);
static int qemu_supports (guestfs_h *g, const char *option);
static int qemu_supports_device (guestfs_h *g, const char *device_name);
@@ -159,8 +158,6 @@ guestfs___launch_appliance (guestfs_h *g)
return -1;
}
- /* Start the clock ... */
- gettimeofday (&g->launch_t, NULL);
guestfs___launch_send_progress (g, 0);
TRACE0 (launch_build_appliance_start);
@@ -736,74 +733,6 @@ guestfs___launch_appliance (guestfs_h *g)
return -1;
}
-/* launch (of the appliance) generates approximate progress
- * messages. Currently these are defined as follows:
- *
- * 0 / 12: launch clock starts
- * 3 / 12: appliance created
- * 6 / 12: detected that guest kernel started
- * 9 / 12: detected that /init script is running
- * 12 / 12: launch completed successfully
- *
- * Notes:
- * (1) This is not a documented ABI and the behaviour may be changed
- * or removed in future.
- * (2) Messages are only sent if more than 5 seconds has elapsed
- * since the launch clock started.
- * (3) There is a gross hack in proto.c to make this work.
- */
-void
-guestfs___launch_send_progress (guestfs_h *g, int perdozen)
-{
- struct timeval tv;
-
- gettimeofday (&tv, NULL);
- if (timeval_diff (&g->launch_t, &tv) >= 5000) {
- guestfs_progress progress_message =
- { .proc = 0, .serial = 0, .position = perdozen, .total = 12 };
-
- guestfs___progress_message_callback (g, &progress_message);
- }
-}
-
-/* Compute Y - X and return the result in milliseconds.
- * Approximately the same as this code:
- * http://www.mpp.mpg.de/~huber/util/timevaldiff.c
- */
-static int64_t
-timeval_diff (const struct timeval *x, const struct timeval *y)
-{
- int64_t msec;
-
- msec = (y->tv_sec - x->tv_sec) * 1000;
- msec += (y->tv_usec - x->tv_usec) / 1000;
- return msec;
-}
-
-/* Note that since this calls 'debug' it should only be called
- * from the parent process.
- */
-void
-guestfs___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", timeval_diff (&g->launch_t, &tv), msg);
-
- free (msg);
-}
-
/* This is called from the forked subprocess just before qemu runs, so
* it can just print the message straight to stderr, where it will be
* picked up and funnelled through the usual appliance event API.
@@ -816,7 +745,8 @@ print_qemu_command_line (guestfs_h *g, char **argv)
struct timeval tv;
gettimeofday (&tv, NULL);
- fprintf (stderr, "[%05" PRIi64 "ms] ", timeval_diff (&g->launch_t, &tv));
+ fprintf (stderr, "[%05" PRIi64 "ms] ",
+ guestfs___timeval_diff (&g->launch_t, &tv));
while (argv[i]) {
if (argv[i][0] == '-') /* -option starts a new line */