qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, jasowang@redhat.com, agraf@suse.de,
	david@gibson.dropbear.id.au
Subject: [Qemu-devel] [PATCH 2/3] replay: allow replay stopping and restarting
Date: Wed, 08 Jun 2016 08:14:04 +0300	[thread overview]
Message-ID: <20160608051404.1688.65453.stgit@PASHA-ISP> (raw)
In-Reply-To: <20160608051352.1688.7877.stgit@PASHA-ISP>

This patch fixes bug with stopping and restarting replay
through monitor.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
 block/blkreplay.c        |   18 +++++++++++++-----
 cpus.c                   |    1 +
 include/sysemu/replay.h  |    2 ++
 replay/replay-internal.h |    2 --
 vl.c                     |    1 +
 5 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/block/blkreplay.c b/block/blkreplay.c
index 42f1813..438170c 100644
--- a/block/blkreplay.c
+++ b/block/blkreplay.c
@@ -70,6 +70,14 @@ static void blkreplay_bh_cb(void *opaque)
     g_free(req);
 }
 
+static uint64_t blkreplay_next_id(void)
+{
+    if (replay_events_enabled()) {
+        return request_id++;
+    }
+    return 0;
+}
+
 static void block_request_create(uint64_t reqid, BlockDriverState *bs,
                                  Coroutine *co)
 {
@@ -84,7 +92,7 @@ static void block_request_create(uint64_t reqid, BlockDriverState *bs,
 static int coroutine_fn blkreplay_co_readv(BlockDriverState *bs,
     int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
 {
-    uint64_t reqid = request_id++;
+    uint64_t reqid = blkreplay_next_id();
     int ret = bdrv_co_readv(bs->file->bs, sector_num, nb_sectors, qiov);
     block_request_create(reqid, bs, qemu_coroutine_self());
     qemu_coroutine_yield();
@@ -95,7 +103,7 @@ static int coroutine_fn blkreplay_co_readv(BlockDriverState *bs,
 static int coroutine_fn blkreplay_co_writev(BlockDriverState *bs,
     int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
 {
-    uint64_t reqid = request_id++;
+    uint64_t reqid = blkreplay_next_id();
     int ret = bdrv_co_writev(bs->file->bs, sector_num, nb_sectors, qiov);
     block_request_create(reqid, bs, qemu_coroutine_self());
     qemu_coroutine_yield();
@@ -106,7 +114,7 @@ static int coroutine_fn blkreplay_co_writev(BlockDriverState *bs,
 static int coroutine_fn blkreplay_co_write_zeroes(BlockDriverState *bs,
     int64_t sector_num, int nb_sectors, BdrvRequestFlags flags)
 {
-    uint64_t reqid = request_id++;
+    uint64_t reqid = blkreplay_next_id();
     int ret = bdrv_co_write_zeroes(bs->file->bs, sector_num, nb_sectors, flags);
     block_request_create(reqid, bs, qemu_coroutine_self());
     qemu_coroutine_yield();
@@ -117,7 +125,7 @@ static int coroutine_fn blkreplay_co_write_zeroes(BlockDriverState *bs,
 static int coroutine_fn blkreplay_co_discard(BlockDriverState *bs,
     int64_t sector_num, int nb_sectors)
 {
-    uint64_t reqid = request_id++;
+    uint64_t reqid = blkreplay_next_id();
     int ret = bdrv_co_discard(bs->file->bs, sector_num, nb_sectors);
     block_request_create(reqid, bs, qemu_coroutine_self());
     qemu_coroutine_yield();
@@ -127,7 +135,7 @@ static int coroutine_fn blkreplay_co_discard(BlockDriverState *bs,
 
 static int coroutine_fn blkreplay_co_flush(BlockDriverState *bs)
 {
-    uint64_t reqid = request_id++;
+    uint64_t reqid = blkreplay_next_id();
     int ret = bdrv_co_flush(bs->file->bs);
     block_request_create(reqid, bs, qemu_coroutine_self());
     qemu_coroutine_yield();
diff --git a/cpus.c b/cpus.c
index 326742f..34f951f 100644
--- a/cpus.c
+++ b/cpus.c
@@ -742,6 +742,7 @@ static int do_vm_stop(RunState state)
         runstate_set(state);
         vm_state_notify(0, state);
         qapi_event_send_stop(&error_abort);
+        replay_disable_events();
     }
 
     bdrv_drain_all();
diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h
index 0a88393..52430d3 100644
--- a/include/sysemu/replay.h
+++ b/include/sysemu/replay.h
@@ -105,6 +105,8 @@ bool replay_checkpoint(ReplayCheckpoint checkpoint);
 
 /*! Disables storing events in the queue */
 void replay_disable_events(void);
+/*! Enables storing events in the queue */
+void replay_enable_events(void);
 /*! Returns true when saving events is enabled */
 bool replay_events_enabled(void);
 /*! Adds bottom half event to the queue */
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index efbf14c..310c4b7 100644
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -119,8 +119,6 @@ void replay_read_next_clock(unsigned int kind);
 void replay_init_events(void);
 /*! Clears internal data structures for events handling */
 void replay_finish_events(void);
-/*! Enables storing events in the queue */
-void replay_enable_events(void);
 /*! Flushes events queue */
 void replay_flush_events(void);
 /*! Clears events list before loading new VM state */
diff --git a/vl.c b/vl.c
index 2f74fe8..b361ca8 100644
--- a/vl.c
+++ b/vl.c
@@ -765,6 +765,7 @@ void vm_start(void)
     if (runstate_is_running()) {
         qapi_event_send_stop(&error_abort);
     } else {
+        replay_enable_events();
         cpu_enable_ticks();
         runstate_set(RUN_STATE_RUNNING);
         vm_state_notify(1, RUN_STATE_RUNNING);

  parent reply	other threads:[~2016-06-08  5:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-08  5:13 [Qemu-devel] [PATCH 0/3] icount/replay additions Pavel Dovgalyuk
2016-06-08  5:13 ` [Qemu-devel] [PATCH 1/3] target-ppc: exceptions handling in icount mode Pavel Dovgalyuk
2016-06-08  5:14 ` Pavel Dovgalyuk [this message]
2016-06-08 10:31   ` [Qemu-devel] [PATCH 2/3] replay: allow replay stopping and restarting Paolo Bonzini
2016-06-20  6:26     ` Pavel Dovgalyuk
2016-06-29  9:43       ` Pavel Dovgalyuk
2016-06-29 10:45       ` Paolo Bonzini
2016-06-29 11:40         ` Pavel Dovgalyuk
2016-06-08  5:14 ` [Qemu-devel] [PATCH 3/3] record/replay: add network support Pavel Dovgalyuk

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=20160608051404.1688.65453.stgit@PASHA-ISP \
    --to=pavel.dovgaluk@ispras.ru \
    --cc=agraf@suse.de \
    --cc=david@gibson.dropbear.id.au \
    --cc=jasowang@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).