aboutsummaryrefslogtreecommitdiff
path: root/blockjob.c
diff options
context:
space:
mode:
Diffstat (limited to 'blockjob.c')
-rw-r--r--blockjob.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/blockjob.c b/blockjob.c
index 7d84ca1d6c..4da86cdfcd 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -26,7 +26,6 @@
#include "config-host.h"
#include "qemu-common.h"
#include "trace.h"
-#include "monitor/monitor.h"
#include "block/block.h"
#include "block/blockjob.h"
#include "block/block_int.h"
@@ -34,6 +33,7 @@
#include "block/coroutine.h"
#include "qmp-commands.h"
#include "qemu/timer.h"
+#include "qapi-event.h"
void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
int64_t speed, BlockDriverCompletionFunc *cb,
@@ -232,26 +232,31 @@ static void block_job_iostatus_set_err(BlockJob *job, int error)
}
}
+void block_job_event_cancelled(BlockJob *job)
+{
+ qapi_event_send_block_job_cancelled(job->driver->job_type,
+ bdrv_get_device_name(job->bs),
+ job->len,
+ job->offset,
+ job->speed,
+ &error_abort);
+}
-QObject *qobject_from_block_job(BlockJob *job)
+void block_job_event_completed(BlockJob *job, const char *msg)
{
- return qobject_from_jsonf("{ 'type': %s,"
- "'device': %s,"
- "'len': %" PRId64 ","
- "'offset': %" PRId64 ","
- "'speed': %" PRId64 " }",
- BlockJobType_lookup[job->driver->job_type],
- bdrv_get_device_name(job->bs),
- job->len,
- job->offset,
- job->speed);
+ qapi_event_send_block_job_completed(job->driver->job_type,
+ bdrv_get_device_name(job->bs),
+ job->len,
+ job->offset,
+ job->speed,
+ !!msg,
+ msg,
+ &error_abort);
}
-void block_job_ready(BlockJob *job)
+void block_job_event_ready(BlockJob *job)
{
- QObject *data = qobject_from_block_job(job);
- monitor_protocol_event(QEVENT_BLOCK_JOB_READY, data);
- qobject_decref(data);
+ qapi_event_send_block_job_ready(bdrv_get_device_name(job->bs), &error_abort);
}
BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs,
@@ -262,22 +267,26 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs,
switch (on_err) {
case BLOCKDEV_ON_ERROR_ENOSPC:
- action = (error == ENOSPC) ? BDRV_ACTION_STOP : BDRV_ACTION_REPORT;
+ action = (error == ENOSPC) ?
+ BLOCK_ERROR_ACTION_STOP : BLOCK_ERROR_ACTION_REPORT;
break;
case BLOCKDEV_ON_ERROR_STOP:
- action = BDRV_ACTION_STOP;
+ action = BLOCK_ERROR_ACTION_STOP;
break;
case BLOCKDEV_ON_ERROR_REPORT:
- action = BDRV_ACTION_REPORT;
+ action = BLOCK_ERROR_ACTION_REPORT;
break;
case BLOCKDEV_ON_ERROR_IGNORE:
- action = BDRV_ACTION_IGNORE;
+ action = BLOCK_ERROR_ACTION_IGNORE;
break;
default:
abort();
}
- bdrv_emit_qmp_error_event(job->bs, QEVENT_BLOCK_JOB_ERROR, action, is_read);
- if (action == BDRV_ACTION_STOP) {
+ qapi_event_send_block_job_error(bdrv_get_device_name(bs),
+ is_read ? IO_OPERATION_TYPE_READ :
+ IO_OPERATION_TYPE_WRITE,
+ action, &error_abort);
+ if (action == BLOCK_ERROR_ACTION_STOP) {
block_job_pause(job);
block_job_iostatus_set_err(job, error);
if (bs != job->bs) {