[Libguestfs] [PATCH 2/3] Record time of guest launch.
Richard W.M. Jones
rjones at redhat.com
Tue Nov 10 13:25:21 UTC 2009
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
-------------- next part --------------
>From e3104fb2cab4efdd980d39ab378e88d3238cbb2b Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Mon, 9 Nov 2009 14:16:21 +0000
Subject: [PATCH 2/3] Record time of guest launch.
The guest handle field start_t was previously used (when we
had the wait_ready call), but had fallen into disuse. Note
that it could never be accessed through the API.
Rename this field as launch_t, convert it to a timeval, and
use it to measure the time since guestfs_launch was called
so that we can start profiling guest launch.
---
src/guestfs.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/guestfs.c b/src/guestfs.c
index 896d8a7..cb103d4 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -107,7 +107,8 @@ struct guestfs_h
int sock; /* Daemon communications socket. */
pid_t pid; /* Qemu PID. */
pid_t recoverypid; /* Recovery process PID. */
- time_t start_t; /* The time when we started qemu. */
+
+ struct timeval launch_t; /* The time that we called guestfs_launch. */
char *tmpdir; /* Temporary directory containing socket. */
@@ -876,6 +877,9 @@ guestfs__launch (guestfs_h *g)
char unixsock[256];
struct sockaddr_un addr;
+ /* Start the clock ... */
+ gettimeofday (&g->launch_t, NULL);
+
#ifdef P_tmpdir
tmpdir = P_tmpdir;
#else
@@ -1264,9 +1268,6 @@ guestfs__launch (guestfs_h *g)
g->recoverypid = r;
}
- /* Start the clock ... */
- time (&g->start_t);
-
if (!g->direct) {
/* Close the other ends of the pipe. */
close (wfd[0]);
@@ -1414,7 +1415,7 @@ guestfs__launch (guestfs_h *g)
g->fd[1] = -1;
g->pid = 0;
g->recoverypid = 0;
- g->start_t = 0;
+ memset (&g->launch_t, 0, sizeof g->launch_t);
cleanup0:
if (g->sock >= 0) {
@@ -1840,7 +1841,7 @@ child_cleanup (guestfs_h *g)
g->sock = -1;
g->pid = 0;
g->recoverypid = 0;
- g->start_t = 0;
+ memset (&g->launch_t, 0, sizeof g->launch_t);
g->state = CONFIG;
if (g->subprocess_quit_cb)
g->subprocess_quit_cb (g, g->subprocess_quit_cb_data);
--
1.6.5.rc2
More information about the Libguestfs
mailing list