Revision f6503059 vl.c
b/vl.c | ||
---|---|---|
180 | 180 |
int nb_nics; |
181 | 181 |
NICInfo nd_table[MAX_NICS]; |
182 | 182 |
int vm_running; |
183 |
int rtc_utc = 1; |
|
184 |
int rtc_start_date = -1; /* -1 means now */
|
|
183 |
static int rtc_utc = 1;
|
|
184 |
static int rtc_date_offset = -1; /* -1 means no change */
|
|
185 | 185 |
int cirrus_vga_enabled = 1; |
186 | 186 |
int vmsvga_enabled = 0; |
187 | 187 |
#ifdef TARGET_SPARC |
... | ... | |
1565 | 1565 |
} |
1566 | 1566 |
|
1567 | 1567 |
/***********************************************************/ |
1568 |
/* host time/date access */ |
|
1569 |
void qemu_get_timedate(struct tm *tm, int offset) |
|
1570 |
{ |
|
1571 |
time_t ti; |
|
1572 |
struct tm *ret; |
|
1573 |
|
|
1574 |
time(&ti); |
|
1575 |
ti += offset; |
|
1576 |
if (rtc_date_offset == -1) { |
|
1577 |
if (rtc_utc) |
|
1578 |
ret = gmtime(&ti); |
|
1579 |
else |
|
1580 |
ret = localtime(&ti); |
|
1581 |
} else { |
|
1582 |
ti -= rtc_date_offset; |
|
1583 |
ret = gmtime(&ti); |
|
1584 |
} |
|
1585 |
|
|
1586 |
memcpy(tm, ret, sizeof(struct tm)); |
|
1587 |
} |
|
1588 |
|
|
1589 |
int qemu_timedate_diff(struct tm *tm) |
|
1590 |
{ |
|
1591 |
time_t seconds; |
|
1592 |
|
|
1593 |
if (rtc_date_offset == -1) |
|
1594 |
if (rtc_utc) |
|
1595 |
seconds = mktimegm(tm); |
|
1596 |
else |
|
1597 |
seconds = mktime(tm); |
|
1598 |
else |
|
1599 |
seconds = mktimegm(tm) + rtc_date_offset; |
|
1600 |
|
|
1601 |
return seconds - time(NULL); |
|
1602 |
} |
|
1603 |
|
|
1604 |
/***********************************************************/ |
|
1568 | 1605 |
/* character device */ |
1569 | 1606 |
|
1570 | 1607 |
static void qemu_chr_event(CharDriverState *s, int event) |
... | ... | |
8698 | 8735 |
case QEMU_OPTION_startdate: |
8699 | 8736 |
{ |
8700 | 8737 |
struct tm tm; |
8738 |
time_t rtc_start_date; |
|
8701 | 8739 |
if (!strcmp(optarg, "now")) { |
8702 |
rtc_start_date = -1;
|
|
8740 |
rtc_date_offset = -1;
|
|
8703 | 8741 |
} else { |
8704 | 8742 |
if (sscanf(optarg, "%d-%d-%dT%d:%d:%d", |
8705 | 8743 |
&tm.tm_year, |
... | ... | |
8728 | 8766 |
"'now' or '2006-06-17T16:01:21' or '2006-06-17'\n"); |
8729 | 8767 |
exit(1); |
8730 | 8768 |
} |
8769 |
rtc_date_offset = time(NULL) - rtc_start_date; |
|
8731 | 8770 |
} |
8732 | 8771 |
} |
8733 | 8772 |
break; |
Also available in: Unified diff