diff options
author | Hervé Poussineau <hpoussin@reactos.org> | 2011-11-30 21:35:38 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-12-20 15:44:30 -0600 |
commit | 0fa29915cdcadb5853515703d3eca8992627dcf2 (patch) | |
tree | 9dcce6b290e6fcf793c0becbb412f6c7299c0659 /net/dump.c | |
parent | 6514ed528cd6cf752927b4eb38e64bba84c321ff (diff) | |
download | qemu-0fa29915cdcadb5853515703d3eca8992627dcf2.zip qemu-0fa29915cdcadb5853515703d3eca8992627dcf2.tar.gz qemu-0fa29915cdcadb5853515703d3eca8992627dcf2.tar.bz2 |
net: store guest timestamp in dump file instead of time since guest startup
Stored dates are no more 1970-01-01 (+ run time), but have a real meaning.
If someone wants to have comparable timestamps accross boots, it is
possible to start qemu with -rtc to give the startup date.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'net/dump.c')
-rw-r--r-- | net/dump.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -30,6 +30,7 @@ typedef struct DumpState { VLANClientState nc; + int64_t start_ts; int fd; int pcap_caplen; } DumpState; @@ -70,7 +71,7 @@ static ssize_t dump_receive(VLANClientState *nc, const uint8_t *buf, size_t size ts = muldiv64(qemu_get_clock_ns(vm_clock), 1000000, get_ticks_per_sec()); caplen = size > s->pcap_caplen ? s->pcap_caplen : size; - hdr.ts.tv_sec = ts / 1000000; + hdr.ts.tv_sec = ts / 1000000 + s->start_ts; hdr.ts.tv_usec = ts % 1000000; hdr.caplen = caplen; hdr.len = size; @@ -104,6 +105,7 @@ static int net_dump_init(VLANState *vlan, const char *device, struct pcap_file_hdr hdr; VLANClientState *nc; DumpState *s; + struct tm tm; int fd; fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644); @@ -136,6 +138,9 @@ static int net_dump_init(VLANState *vlan, const char *device, s->fd = fd; s->pcap_caplen = len; + qemu_get_timedate(&tm, 0); + s->start_ts = mktime(&tm); + return 0; } |