qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] net: truncate output file when using dump backend
@ 2011-11-06 21:52 Hervé Poussineau
  2011-11-06 21:52 ` [Qemu-devel] [PATCH 2/2] net: store correct timestamp in dump file Hervé Poussineau
  2011-11-07 10:08 ` [Qemu-devel] [PATCH 1/2] net: truncate output file when using dump backend Stefan Hajnoczi
  0 siblings, 2 replies; 5+ messages in thread
From: Hervé Poussineau @ 2011-11-06 21:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Liguori, Hervé Poussineau


Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 net/dump.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/dump.c b/net/dump.c
index 0d0cbb2..8132411 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -106,7 +106,7 @@ static int net_dump_init(VLANState *vlan, const char *device,
     DumpState *s;
     int fd;
 
-    fd = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644);
+    fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);
     if (fd < 0) {
         error_report("-net dump: can't open %s", filename);
         return -1;
-- 
1.7.6.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 2/2] net: store correct timestamp in dump file
  2011-11-06 21:52 [Qemu-devel] [PATCH 1/2] net: truncate output file when using dump backend Hervé Poussineau
@ 2011-11-06 21:52 ` Hervé Poussineau
  2011-11-07  6:44   ` Mark Wu
  2011-11-07 10:08 ` [Qemu-devel] [PATCH 1/2] net: truncate output file when using dump backend Stefan Hajnoczi
  1 sibling, 1 reply; 5+ messages in thread
From: Hervé Poussineau @ 2011-11-06 21:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Liguori, Hervé Poussineau


Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 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 @@
 
 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;
 }
 
-- 
1.7.6.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] net: store correct timestamp in dump file
  2011-11-06 21:52 ` [Qemu-devel] [PATCH 2/2] net: store correct timestamp in dump file Hervé Poussineau
@ 2011-11-07  6:44   ` Mark Wu
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Wu @ 2011-11-07  6:44 UTC (permalink / raw)
  To: Hervé Poussineau; +Cc: Anthony Liguori, qemu-devel

On 11/07/2011 05:52 AM, Hervé Poussineau wrote:
> Signed-off-by: Hervé Poussineau<hpoussin@reactos.org>
> ---
>   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 @@
>
>   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());
I agree that using host time as timestamp is more reasonable than the 
virtual clock because in most cases rtc for guest is based on host time 
not  virtual clock.
I think we can simply use "host_clock" instead of "vm_clock" to achieve 
that. It will use the same time as host no matter what option is 
specified for guest's rtc. With your patch, the time stamp will keep the 
same as the choice of guest rtc, which is utc default.

  -    ts = muldiv64(qemu_get_clock_ns(vm_clock), 1000000, 
get_ticks_per_sec());
+    ts = muldiv64(qemu_get_clock_ns(host_clock), 1000000, 
get_ticks_per_sec());
      caplen = size > s->pcap_caplen ? s->pcap_caplen : size;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] net: truncate output file when using dump backend
  2011-11-06 21:52 [Qemu-devel] [PATCH 1/2] net: truncate output file when using dump backend Hervé Poussineau
  2011-11-06 21:52 ` [Qemu-devel] [PATCH 2/2] net: store correct timestamp in dump file Hervé Poussineau
@ 2011-11-07 10:08 ` Stefan Hajnoczi
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2011-11-07 10:08 UTC (permalink / raw)
  To: Hervé Poussineau; +Cc: Anthony Liguori, qemu-devel

On Sun, Nov 06, 2011 at 10:52:04PM +0100, Hervé Poussineau wrote:
> 
> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
> ---
>  net/dump.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 1/2] net: truncate output file when using dump backend
  2011-11-30 20:35 [Qemu-devel] [PATCH v2 0/2] net: fix some problems with " Hervé Poussineau
@ 2011-11-30 20:35 ` Hervé Poussineau
  0 siblings, 0 replies; 5+ messages in thread
From: Hervé Poussineau @ 2011-11-30 20:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Hervé Poussineau

This prevents data of a previous run to be seen in the new dump file.

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 net/dump.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/dump.c b/net/dump.c
index 0d0cbb2..8132411 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -106,7 +106,7 @@ static int net_dump_init(VLANState *vlan, const char *device,
     DumpState *s;
     int fd;
 
-    fd = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644);
+    fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);
     if (fd < 0) {
         error_report("-net dump: can't open %s", filename);
         return -1;
-- 
1.7.6.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-30 20:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-06 21:52 [Qemu-devel] [PATCH 1/2] net: truncate output file when using dump backend Hervé Poussineau
2011-11-06 21:52 ` [Qemu-devel] [PATCH 2/2] net: store correct timestamp in dump file Hervé Poussineau
2011-11-07  6:44   ` Mark Wu
2011-11-07 10:08 ` [Qemu-devel] [PATCH 1/2] net: truncate output file when using dump backend Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2011-11-30 20:35 [Qemu-devel] [PATCH v2 0/2] net: fix some problems with " Hervé Poussineau
2011-11-30 20:35 ` [Qemu-devel] [PATCH 1/2] net: truncate output file when using " Hervé Poussineau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).