From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVqsR-0007OW-Od for qemu-devel@nongnu.org; Wed, 30 Nov 2011 15:35:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RVqsQ-00039z-83 for qemu-devel@nongnu.org; Wed, 30 Nov 2011 15:35:35 -0500 Received: from smtp25.services.sfr.fr ([93.17.128.119]:1915) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVqsQ-00039v-3X for qemu-devel@nongnu.org; Wed, 30 Nov 2011 15:35:34 -0500 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 30 Nov 2011 21:35:38 +0100 Message-Id: <1322685338-3825-3-git-send-email-hpoussin@reactos.org> In-Reply-To: <1322685338-3825-1-git-send-email-hpoussin@reactos.org> References: <1322685338-3825-1-git-send-email-hpoussin@reactos.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 2/2] net: store guest timestamp in dump file instead of time since guest startup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Herv=C3=A9=20Poussineau?= 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=C3=A9 Poussineau --- net/dump.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/net/dump.c b/net/dump.c index 8132411..4b48d48 100644 --- a/net/dump.c +++ b/net/dump.c @@ -30,6 +30,7 @@ =20 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 =3D muldiv64(qemu_get_clock_ns(vm_clock), 1000000, get_ticks_per_= sec()); caplen =3D size > s->pcap_caplen ? s->pcap_caplen : size; =20 - hdr.ts.tv_sec =3D ts / 1000000; + hdr.ts.tv_sec =3D ts / 1000000 + s->start_ts; hdr.ts.tv_usec =3D ts % 1000000; hdr.caplen =3D caplen; hdr.len =3D 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; =20 fd =3D 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 =3D fd; s->pcap_caplen =3D len; =20 + qemu_get_timedate(&tm, 0); + s->start_ts =3D mktime(&tm); + return 0; } =20 --=20 1.7.6.3