qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com,
	alex.bennee@linaro.org, mark.burton@greensocs.com,
	real@ispras.ru, batuzovk@ispras.ru,
	maria.klimushenkova@ispras.ru, afaerber@suse.de,
	fred.konrad@greensocs.com
Subject: Re: [Qemu-devel] [RFC PATCH v9 04/23] replay: internal functions for replay log
Date: Wed, 18 Feb 2015 13:43:00 +0100	[thread overview]
Message-ID: <54E488D4.7040707@redhat.com> (raw)
In-Reply-To: <20150218115603.4176.35365.stgit@PASHA-ISP>



On 18/02/2015 12:56, Pavel Dovgalyuk wrote:
> This patch adds functions to perform read and write operations
> with replay log.
> 
> Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> ---
>  replay/Makefile.objs     |    1 
>  replay/replay-internal.c |  143 ++++++++++++++++++++++++++++++++++++++++++++++
>  replay/replay-internal.h |   44 ++++++++++++++
>  3 files changed, 188 insertions(+), 0 deletions(-)
>  create mode 100755 replay/replay-internal.c
>  create mode 100755 replay/replay-internal.h
> 
> diff --git a/replay/Makefile.objs b/replay/Makefile.objs
> index 7ea860f..1148f45 100755
> --- a/replay/Makefile.objs
> +++ b/replay/Makefile.objs
> @@ -1 +1,2 @@
>  obj-y += replay.o
> +obj-y += replay-internal.o
> diff --git a/replay/replay-internal.c b/replay/replay-internal.c
> new file mode 100755
> index 0000000..e905de8
> --- /dev/null
> +++ b/replay/replay-internal.c
> @@ -0,0 +1,143 @@
> +/*
> + * replay-internal.c
> + *
> + * Copyright (c) 2010-2015 Institute for System Programming
> + *                         of the Russian Academy of Sciences.
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + *
> + */
> +
> +#include "qemu-common.h"
> +#include "replay-internal.h"
> +
> +unsigned int replay_data_kind = -1;
> +unsigned int replay_has_unread_data;
> +
> +/* File for replay writing */
> +FILE *replay_file;
> +
> +void replay_put_byte(uint8_t byte)
> +{
> +    if (replay_file) {
> +        putc(byte, replay_file);
> +    }
> +}
> +
> +void replay_put_event(uint8_t event)
> +{
> +    replay_put_byte(event);
> +}
> +
> +
> +void replay_put_word(uint16_t word)
> +{
> +    replay_put_byte(word >> 8);
> +    replay_put_byte(word);
> +}
> +
> +void replay_put_dword(uint32_t dword)
> +{
> +    replay_put_word(dword >> 16);
> +    replay_put_word(dword);
> +}
> +
> +void replay_put_qword(int64_t qword)
> +{
> +    replay_put_dword(qword >> 32);
> +    replay_put_dword(qword);
> +}
> +
> +void replay_put_array(const uint8_t *buf, size_t size)
> +{
> +    if (replay_file) {
> +        replay_put_dword(size);
> +        fwrite(buf, 1, size, replay_file);
> +    }
> +}
> +
> +uint8_t replay_get_byte(void)
> +{
> +    uint8_t byte = 0;
> +    if (replay_file) {
> +        byte = getc(replay_file);
> +    }
> +    return byte;
> +}
> +
> +uint16_t replay_get_word(void)
> +{
> +    uint16_t word = 0;
> +    if (replay_file) {
> +        word = replay_get_byte();
> +        word = (word << 8) + replay_get_byte();
> +    }
> +
> +    return word;
> +}
> +
> +uint32_t replay_get_dword(void)
> +{
> +    uint32_t dword = 0;
> +    if (replay_file) {
> +        dword = replay_get_word();
> +        dword = (dword << 16) + replay_get_word();
> +    }
> +
> +    return dword;
> +}
> +
> +int64_t replay_get_qword(void)
> +{
> +    int64_t qword = 0;
> +    if (replay_file) {
> +        qword = replay_get_dword();
> +        qword = (qword << 32) + replay_get_dword();
> +    }
> +
> +    return qword;
> +}
> +
> +void replay_get_array(uint8_t *buf, size_t *size)
> +{
> +    if (replay_file) {
> +        *size = replay_get_dword();
> +        fread(buf, 1, *size, replay_file);
> +    }
> +}
> +
> +void replay_get_array_alloc(uint8_t **buf, size_t *size)
> +{
> +    if (replay_file) {
> +        *size = replay_get_dword();
> +        *buf = g_malloc(*size);
> +        fread(*buf, 1, *size, replay_file);
> +    }
> +}
> +
> +void replay_check_error(void)
> +{
> +    if (replay_file) {
> +        if (feof(replay_file)) {
> +            fprintf(stderr, "replay file is over\n");

I suggest using error_report (that will also require removal of the \n)
but apart from this nit:

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

> +            qemu_system_vmstop_request_prepare();
> +            qemu_system_vmstop_request(RUN_STATE_PAUSED);
> +        } else if (ferror(replay_file)) {
> +            fprintf(stderr, "replay file is over or something goes wrong\n");
> +            qemu_system_vmstop_request_prepare();
> +            qemu_system_vmstop_request(RUN_STATE_INTERNAL_ERROR);
> +        }
> +    }
> +}
> +
> +void replay_fetch_data_kind(void)
> +{
> +    if (replay_file) {
> +        if (!replay_has_unread_data) {
> +            replay_data_kind = replay_get_byte();
> +            replay_check_error();
> +            replay_has_unread_data = 1;
> +        }
> +    }
> +}
> diff --git a/replay/replay-internal.h b/replay/replay-internal.h
> new file mode 100755
> index 0000000..d1b7575
> --- /dev/null
> +++ b/replay/replay-internal.h
> @@ -0,0 +1,44 @@
> +#ifndef REPLAY_INTERNAL_H
> +#define REPLAY_INTERNAL_H
> +
> +/*
> + * replay-internal.h
> + *
> + * Copyright (c) 2010-2015 Institute for System Programming
> + *                         of the Russian Academy of Sciences.
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + *
> + */
> +
> +#include <stdio.h>
> +
> +extern unsigned int replay_data_kind;
> +extern unsigned int replay_has_unread_data;
> +
> +/* File for replay writing */
> +extern FILE *replay_file;
> +
> +void replay_put_byte(uint8_t byte);
> +void replay_put_event(uint8_t event);
> +void replay_put_word(uint16_t word);
> +void replay_put_dword(uint32_t dword);
> +void replay_put_qword(int64_t qword);
> +void replay_put_array(const uint8_t *buf, size_t size);
> +
> +uint8_t replay_get_byte(void);
> +uint16_t replay_get_word(void);
> +uint32_t replay_get_dword(void);
> +int64_t replay_get_qword(void);
> +void replay_get_array(uint8_t *buf, size_t *size);
> +void replay_get_array_alloc(uint8_t **buf, size_t *size);
> +
> +/*! Checks error status of the file. */
> +void replay_check_error(void);
> +
> +/*! Reads data type from the file and stores it in the
> +    replay_data_kind variable. */
> +void replay_fetch_data_kind(void);
> +
> +#endif
> 

  reply	other threads:[~2015-02-18 12:43 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-18 11:55 [Qemu-devel] [RFC PATCH v9 00/23] Deterministic replay core Pavel Dovgalyuk
2015-02-18 11:55 ` [Qemu-devel] [RFC PATCH v9 01/23] i386: partial revert of interrupt poll fix Pavel Dovgalyuk
2015-02-18 11:55 ` [Qemu-devel] [RFC PATCH v9 02/23] replay: global variables and function stubs Pavel Dovgalyuk
2015-02-18 11:55 ` [Qemu-devel] [RFC PATCH v9 03/23] sysemu: system functions for replay Pavel Dovgalyuk
2015-02-18 11:56 ` [Qemu-devel] [RFC PATCH v9 04/23] replay: internal functions for replay log Pavel Dovgalyuk
2015-02-18 12:43   ` Paolo Bonzini [this message]
2015-02-18 11:56 ` [Qemu-devel] [RFC PATCH v9 05/23] replay: introduce mutex to protect the " Pavel Dovgalyuk
2015-02-18 11:56 ` [Qemu-devel] [RFC PATCH v9 06/23] replay: introduce icount event Pavel Dovgalyuk
2015-02-18 13:49   ` Paolo Bonzini
2015-02-18 14:14   ` Paolo Bonzini
2015-02-18 11:56 ` [Qemu-devel] [RFC PATCH v9 07/23] cpu-exec: allow temporary disabling icount Pavel Dovgalyuk
2015-02-18 11:56 ` [Qemu-devel] [RFC PATCH v9 08/23] cpu: replay instructions sequence Pavel Dovgalyuk
2015-02-18 12:50   ` Paolo Bonzini
2015-02-18 13:48   ` Paolo Bonzini
2015-02-18 11:56 ` [Qemu-devel] [RFC PATCH v9 09/23] replay: interrupts and exceptions Pavel Dovgalyuk
2015-02-18 13:54   ` Paolo Bonzini
2015-02-18 14:14   ` Paolo Bonzini
2015-02-18 11:56 ` [Qemu-devel] [RFC PATCH v9 10/23] replay: asynchronous events infrastructure Pavel Dovgalyuk
2015-02-18 11:56 ` [Qemu-devel] [RFC PATCH v9 11/23] replay: recording and replaying clock ticks Pavel Dovgalyuk
2015-02-18 14:13   ` Paolo Bonzini
2015-02-18 11:56 ` [Qemu-devel] [RFC PATCH v9 12/23] timer: replace time() with QEMU_CLOCK_HOST Pavel Dovgalyuk
2015-02-18 13:04   ` Paolo Bonzini
2015-02-18 11:56 ` [Qemu-devel] [RFC PATCH v9 13/23] replay: shutdown event Pavel Dovgalyuk
2015-02-18 11:57 ` [Qemu-devel] [RFC PATCH v9 14/23] replay: checkpoints Pavel Dovgalyuk
2015-02-18 14:14   ` Paolo Bonzini
2015-02-18 11:57 ` [Qemu-devel] [RFC PATCH v9 15/23] aio: replace stack of bottom halves with queue Pavel Dovgalyuk
2015-02-18 13:06   ` Paolo Bonzini
2015-02-18 13:10   ` Paolo Bonzini
2015-02-18 11:57 ` [Qemu-devel] [RFC PATCH v9 16/23] replay: bottom halves Pavel Dovgalyuk
2015-02-18 11:57 ` [Qemu-devel] [RFC PATCH v9 17/23] replay: replay aio requests Pavel Dovgalyuk
2015-02-18 11:57 ` [Qemu-devel] [RFC PATCH v9 18/23] replay: thread pool Pavel Dovgalyuk
2015-02-18 11:57 ` [Qemu-devel] [RFC PATCH v9 19/23] typedef: add typedef for QemuOpts Pavel Dovgalyuk
2015-02-18 13:11   ` Paolo Bonzini
2015-02-18 11:57 ` [Qemu-devel] [RFC PATCH v9 20/23] replay: initialization and deinitialization Pavel Dovgalyuk
2015-02-18 13:14   ` Paolo Bonzini
2015-02-18 11:57 ` [Qemu-devel] [RFC PATCH v9 21/23] replay: replay blockers for devices Pavel Dovgalyuk
2015-02-18 11:57 ` [Qemu-devel] [RFC PATCH v9 22/23] replay: command line options Pavel Dovgalyuk
2015-02-18 13:18   ` Paolo Bonzini
2015-02-20  8:02     ` Pavel Dovgaluk
     [not found]     ` <23594.561199616$1424419399@news.gmane.org>
2015-02-20 10:28       ` Paolo Bonzini
2015-02-18 11:57 ` [Qemu-devel] [RFC PATCH v9 23/23] replay: recording of the user input Pavel Dovgalyuk
2015-02-18 14:19 ` [Qemu-devel] [RFC PATCH v9 00/23] Deterministic replay core Paolo Bonzini
2015-02-27  9:23   ` Pavel Dovgaluk
2015-02-27 13:07     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54E488D4.7040707@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=Pavel.Dovgaluk@ispras.ru \
    --cc=afaerber@suse.de \
    --cc=alex.bennee@linaro.org \
    --cc=batuzovk@ispras.ru \
    --cc=fred.konrad@greensocs.com \
    --cc=maria.klimushenkova@ispras.ru \
    --cc=mark.burton@greensocs.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=real@ispras.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).