Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JqNlz-0002Ke-Pm for qemu-devel@nongnu.org; Mon, 28 Apr 2008 03:27:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JqNly-0002KQ-2B for qemu-devel@nongnu.org; Mon, 28 Apr 2008 03:27:39 -0400 Received: from [199.232.76.173] (port=49552 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JqNlx-0002KN-Rl for qemu-devel@nongnu.org; Mon, 28 Apr 2008 03:27:37 -0400 Received: from mx20.gnu.org ([199.232.41.8]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JqNlx-0007hh-AA for qemu-devel@nongnu.org; Mon, 28 Apr 2008 03:27:37 -0400 Received: from bzq-179-150-194.static.bezeqint.net ([212.179.150.194] helo=il.qumranet.com) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JqNlw-0004fI-9a for qemu-devel@nongnu.org; Mon, 28 Apr 2008 03:27:36 -0400 Received: from localhost (karma.qumranet.com [172.16.16.240]) by il.qumranet.com (Postfix) with ESMTP id AA1F1250136 for ; Mon, 28 Apr 2008 10:27:32 +0300 (IDT) Date: Mon, 28 Apr 2008 10:27:32 +0300 From: Dan Kenigsberg Subject: Re: [Qemu-devel] [Patch] [kinda-resend] persistent real-time-clock Message-ID: <20080428072732.GB6184@karma.qumranet.com> References: <20080427154501.GA20547@karma.qumranet.com> <20080427212803.GA29507@shareable.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080427212803.GA29507@shareable.org> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Sun, Apr 27, 2008 at 10:28:03PM +0100, Jamie Lokier wrote: > Dan Kenigsberg wrote: > > These patches will allow doing the same with VM: > > - Before shutting a VM down, use the monitor's info timeoffset to see > > how much (in seconds) does the rtc differ from the host clock. > > - Store this offset somewhere. > > - Use it next time with -startdate now+offset. > > Another useful one would be store the actual time, and use the same > time when starting next time - without including any advance in host's > clock in the interval. > > That's useful when running some time-limited software in a VM. Then > you can only run the VM when you're using the software, and get more > use out of it before the time runs out. > It does not seem hard to add something like that (though it seems quite orthogonal to my original perpose). Did you mean something like the following? diff --git a/monitor.c b/monitor.c index 76817e1..45396aa 100644 --- a/monitor.c +++ b/monitor.c @@ -264,6 +264,14 @@ static void do_info_blockstats(void) bdrv_info_stats(); } +void do_info_timedate(void) +{ + struct tm tm; + qemu_get_timedate(&tm, 0); + term_printf("%d-%02d-%02dT%02d:%02d:%02d\n", tm.tm_year + 1900, tm.tm_mon, + tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); +} + /* get the current CPU defined by the user */ static int mon_set_cpu(int cpu_index) { @@ -1410,6 +1418,8 @@ static term_cmd_t info_cmds[] = { { "timeoffset", "", do_info_timeoffset, "", "show how much the VM real time clock differ from host time" }, #endif + { "timedate", "", do_info_timedate, + "", "show the current VM time and date" }, { "name", "", do_info_name, "", "show the current VM name" }, #if defined(TARGET_PPC)