
On 10/29/2010 05:25 PM, Daniel P. Berrange wrote:
On Fri, Oct 29, 2010 at 04:43:19PM +0800, Osier Yang wrote:
Currently only record timestamps for domain start and shutdown, for domain start, record timestamps before qemu command line, for domain shutdown, just says it's shutting down.
* src/qemu/qemu_driver.c (qemudStartVMDaemon, qemudShutdownVMDaemon) --- src/qemu/qemu_driver.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1eea3a9..89b4d11 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3828,6 +3828,10 @@ static int qemudStartVMDaemon(virConnectPtr conn, char ebuf[1024]; char *pidfile = NULL; int logfile = -1; + struct timeval cur_time; + struct tm time_info; + char timestr[100]; + char *timestamp; qemuDomainObjPrivatePtr priv = vm->privateData;
struct qemudHookData hookData; @@ -4015,7 +4019,27 @@ static int qemudStartVMDaemon(virConnectPtr conn, goto cleanup; }
+ gettimeofday(&cur_time, NULL); + localtime_r(&cur_time.tv_sec,&time_info); + + strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S",&time_info); + + if (virAsprintf(×tamp, "%s.%3d: ", + timestr, (int) cur_time.tv_usec / 1000)< 0) { + VIR_FREE(timestamp); + virReportOOMError(); + goto cleanup; + }
This is a rather unwieldly block of code, that is just dieing to have a helper function in src/util, so we don't need to duplicate it everywhere
Agree, yes, indeed see similar codes used in some other places, hesitated about if it will be good to replace them, will write a helper function, and update the patch then.. Thanks. - Osier
Regards, Daniel