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;