Commit e4ec5ad4 authored by Pavel Dovgalyuk's avatar Pavel Dovgalyuk Committed by Kevin Wolf
Browse files

replay: add BH oneshot event for block layer



Replay is capable of recording normal BH events, but sometimes
there are single use callbacks scheduled with aio_bh_schedule_oneshot
function. This patch enables recording and replaying such callbacks.
Block layer uses these events for calling the completion function.
Replaying these calls makes the execution deterministic.

Signed-off-by: default avatarPavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
Acked-by: default avatarKevin Wolf <kwolf@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent ae25dccb
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#include "hw/qdev-core.h"
#include "sysemu/blockdev.h"
#include "sysemu/runstate.h"
#include "sysemu/sysemu.h"
#include "sysemu/replay.h"
#include "qapi/error.h"
#include "qapi/qapi-events-block.h"
#include "qemu/id.h"
@@ -1306,7 +1308,8 @@ BlockAIOCB *blk_abort_aio_request(BlockBackend *blk,
    acb->blk = blk;
    acb->ret = ret;

    aio_bh_schedule_oneshot(blk_get_aio_context(blk), error_callback_bh, acb);
    replay_bh_schedule_oneshot_event(blk_get_aio_context(blk),
                                     error_callback_bh, acb);
    return &acb->common;
}

@@ -1362,7 +1365,7 @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes,

    acb->has_returned = true;
    if (acb->rwco.ret != NOT_DONE) {
        aio_bh_schedule_oneshot(blk_get_aio_context(blk),
        replay_bh_schedule_oneshot_event(blk_get_aio_context(blk),
                                         blk_aio_complete_bh, acb);
    }

+2 −2
Original line number Diff line number Diff line
@@ -369,7 +369,7 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
    if (bs) {
        bdrv_inc_in_flight(bs);
    }
    aio_bh_schedule_oneshot(bdrv_get_aio_context(bs),
    replay_bh_schedule_oneshot_event(bdrv_get_aio_context(bs),
                                     bdrv_co_drain_bh_cb, &data);

    qemu_coroutine_yield();
+3 −2
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include "qemu/module.h"
#include "qemu/option.h"
#include "qemu/uuid.h"
#include "sysemu/replay.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-misc.h"
#include "qapi/qmp/qdict.h"
@@ -280,7 +281,7 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
    }

    if (iTask->co) {
        aio_bh_schedule_oneshot(iTask->iscsilun->aio_context,
        replay_bh_schedule_oneshot_event(iTask->iscsilun->aio_context,
                                         iscsi_co_generic_bh_cb, iTask);
    } else {
        iTask->complete = 1;
+4 −2
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@
#include "qemu/option.h"
#include "qemu/uri.h"
#include "qemu/cutils.h"
#include "sysemu/sysemu.h"
#include "sysemu/replay.h"
#include "qapi/qapi-visit-block-core.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h"
@@ -257,7 +259,7 @@ nfs_co_generic_cb(int ret, struct nfs_context *nfs, void *data,
    if (task->ret < 0) {
        error_report("NFS Error: %s", nfs_get_error(nfs));
    }
    aio_bh_schedule_oneshot(task->client->aio_context,
    replay_bh_schedule_oneshot_event(task->client->aio_context,
                                     nfs_co_generic_bh_cb, task);
}

+3 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "qemu/module.h"
#include "qemu/option.h"
#include "block/block_int.h"
#include "sysemu/replay.h"

#define NULL_OPT_LATENCY "latency-ns"
#define NULL_OPT_ZEROES  "read-zeroes"
@@ -179,7 +180,8 @@ static inline BlockAIOCB *null_aio_common(BlockDriverState *bs,
        timer_mod_ns(&acb->timer,
                     qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + s->latency_ns);
    } else {
        aio_bh_schedule_oneshot(bdrv_get_aio_context(bs), null_bh_cb, acb);
        replay_bh_schedule_oneshot_event(bdrv_get_aio_context(bs),
                                         null_bh_cb, acb);
    }
    return &acb->common;
}
Loading