From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GJgBK-0001ce-QV for qemu-devel@nongnu.org; Sat, 02 Sep 2006 20:49:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GJgBJ-0001cS-V0 for qemu-devel@nongnu.org; Sat, 02 Sep 2006 20:49:50 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GJgBJ-0001cP-QJ for qemu-devel@nongnu.org; Sat, 02 Sep 2006 20:49:49 -0400 Received: from [216.148.227.154] (helo=rwcrmhc14.comcast.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GJgLV-0000qL-3V for qemu-devel@nongnu.org; Sat, 02 Sep 2006 21:00:21 -0400 From: Jim Peterson Date: Sat, 2 Sep 2006 20:49:45 -0400 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_pai+EHV1JmUEF8R" Message-Id: <200609022049.45864.jspeter@jimsara.org> Subject: [Qemu-devel] QEMU Patch 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 --Boundary-00=_pai+EHV1JmUEF8R Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline I'm not quite sure where to send this. I've added a slight modification to qemu-0.8.2 that allows the user to specify the desired date and time to which to set the real time clock at startup. The patch is attached. The date is parsed using the getdate(3) function, so the DATEMSK environment variable must point to an appropriate file containing the formats to check for. My need for this comes about as a side effect from the fact that, for some reason, the "-loadvm" command locks up with an XP image on an Opteron 248 host. (but it does not seem to lock up on an Pentium 4 host) --Jim --Boundary-00=_pai+EHV1JmUEF8R Content-Type: text/x-diff; charset="us-ascii"; name="qemu-0.8.2-setdate.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="qemu-0.8.2-setdate.patch" diff -ruN qemu-0.8.2/hw/pc.c qemu-0.8.2.new/hw/pc.c --- qemu-0.8.2/hw/pc.c 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2.new/hw/pc.c 2006-09-02 15:30:49.000000000 -0400 @@ -163,11 +163,16 @@ int i; /* set the CMOS date */ - time(&ti); - if (rtc_utc) - tm = gmtime(&ti); + if (rtc_use_time) + tm = &rtc_tm; else - tm = localtime(&ti); + { + time(&ti); + if (rtc_utc) + tm = gmtime(&ti); + else + tm = localtime(&ti); + } rtc_set_date(s, tm); val = to_bcd(s, (tm->tm_year / 100) + 19); diff -ruN qemu-0.8.2/vl.c qemu-0.8.2.new/vl.c --- qemu-0.8.2/vl.c 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2.new/vl.c 2006-09-02 20:14:44.000000000 -0400 @@ -128,6 +128,8 @@ QEMUTimer *gui_timer; int vm_running; int rtc_utc = 1; +int rtc_use_time = 0; +struct tm rtc_tm; int cirrus_vga_enabled = 1; #ifdef TARGET_SPARC int graphic_width = 1024; @@ -5150,6 +5152,7 @@ " use -soundhw all to enable all of them\n" #endif "-localtime set the real time clock to local time [default=utc]\n" + "-date [date] set the real time clock to given date using getdate(3)\n" "-full-screen start in full screen\n" #ifdef TARGET_I386 "-win2k-hack use it when installing Windows 2000 to avoid a disk full bug\n" @@ -5285,6 +5288,7 @@ QEMU_OPTION_no_code_copy, QEMU_OPTION_k, QEMU_OPTION_localtime, + QEMU_OPTION_setdate, QEMU_OPTION_cirrusvga, QEMU_OPTION_g, QEMU_OPTION_std_vga, @@ -5362,6 +5366,7 @@ { "g", 1, QEMU_OPTION_g }, #endif { "localtime", 0, QEMU_OPTION_localtime }, + { "date", 1, QEMU_OPTION_setdate }, { "std-vga", 0, QEMU_OPTION_std_vga }, { "monitor", 1, QEMU_OPTION_monitor }, { "serial", 1, QEMU_OPTION_serial }, @@ -5607,6 +5612,7 @@ QEMUMachine *machine; char usb_devices[MAX_USB_CMDLINE][128]; int usb_devices_index; + struct tm* tmp_tm; LIST_INIT (&vm_change_state_head); #ifndef _WIN32 @@ -5907,6 +5913,16 @@ case QEMU_OPTION_localtime: rtc_utc = 0; break; + case QEMU_OPTION_setdate: + rtc_use_time = 1; + tmp_tm = getdate(optarg); + if (!tmp_tm) + { + fprintf (stderr, "qemu: bad date format '%s'\n",optarg); + exit(1); + } + memcpy(&rtc_tm,tmp_tm,sizeof(rtc_tm)); + break; case QEMU_OPTION_cirrusvga: cirrus_vga_enabled = 1; break; diff -ruN qemu-0.8.2/vl.h qemu-0.8.2.new/vl.h --- qemu-0.8.2/vl.h 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2.new/vl.h 2006-09-02 15:45:25.000000000 -0400 @@ -142,6 +142,8 @@ extern int ram_size; extern int bios_size; extern int rtc_utc; +extern int rtc_use_time; +extern struct tm rtc_tm; extern int cirrus_vga_enabled; extern int graphic_width; extern int graphic_height; --Boundary-00=_pai+EHV1JmUEF8R--