From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 23/30] iostatus: move BlockdevOnError declaration to QAPI
Date: Fri, 28 Sep 2012 19:57:06 +0200 [thread overview]
Message-ID: <1348855033-17174-24-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1348855033-17174-1-git-send-email-kwolf@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
This will let block-stream reuse the enum. Places that used the enums
are renamed accordingly.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 6 +++---
block.h | 5 -----
block/commit.c | 14 +++++++-------
block_int.h | 2 +-
blockdev.c | 14 +++++++-------
hw/fdc.c | 4 ++--
hw/ide/core.c | 6 +++---
hw/scsi-disk.c | 6 +++---
hw/scsi-generic.c | 4 ++--
hw/virtio-blk.c | 6 +++---
qapi-schema.json | 23 +++++++++++++++++++++++
11 files changed, 54 insertions(+), 36 deletions(-)
diff --git a/block.c b/block.c
index 7b45082..1c3ebd7 100644
--- a/block.c
+++ b/block.c
@@ -4209,9 +4209,9 @@ void bdrv_iostatus_enable(BlockDriverState *bs)
bool bdrv_iostatus_is_enabled(const BlockDriverState *bs)
{
return (bs->iostatus_enabled &&
- (bs->on_write_error == BLOCK_ERR_STOP_ENOSPC ||
- bs->on_write_error == BLOCK_ERR_STOP_ANY ||
- bs->on_read_error == BLOCK_ERR_STOP_ANY));
+ (bs->on_write_error == BLOCKDEV_ON_ERROR_ENOSPC ||
+ bs->on_write_error == BLOCKDEV_ON_ERROR_STOP ||
+ bs->on_read_error == BLOCKDEV_ON_ERROR_STOP));
}
void bdrv_iostatus_disable(BlockDriverState *bs)
diff --git a/block.h b/block.h
index 038621f..ee81129 100644
--- a/block.h
+++ b/block.h
@@ -91,11 +91,6 @@ typedef struct BlockDevOps {
#define BDRV_SECTOR_MASK ~(BDRV_SECTOR_SIZE - 1)
typedef enum {
- BLOCK_ERR_REPORT, BLOCK_ERR_IGNORE, BLOCK_ERR_STOP_ENOSPC,
- BLOCK_ERR_STOP_ANY
-} BlockdevOnError;
-
-typedef enum {
BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP
} BlockErrorAction;
diff --git a/block/commit.c b/block/commit.c
index cabb470..733c914 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -34,7 +34,7 @@ typedef struct CommitBlockJob {
BlockDriverState *active;
BlockDriverState *top;
BlockDriverState *base;
- BlockErrorAction on_error;
+ BlockdevOnError on_error;
int base_flags;
int orig_overlay_flags;
} CommitBlockJob;
@@ -126,9 +126,9 @@ wait:
bytes_written += n * BDRV_SECTOR_SIZE;
}
if (ret < 0) {
- if (s->on_error == BLOCK_ERR_STOP_ANY ||
- s->on_error == BLOCK_ERR_REPORT ||
- (s->on_error == BLOCK_ERR_STOP_ENOSPC && ret == -ENOSPC)) {
+ if (s->on_error == BLOCKDEV_ON_ERROR_STOP ||
+ s->on_error == BLOCKDEV_ON_ERROR_REPORT||
+ (s->on_error == BLOCKDEV_ON_ERROR_ENOSPC && ret == -ENOSPC)) {
goto exit_free_buf;
} else {
n = 0;
@@ -182,7 +182,7 @@ static BlockJobType commit_job_type = {
void commit_start(BlockDriverState *bs, BlockDriverState *base,
BlockDriverState *top, int64_t speed,
- BlockErrorAction on_error, BlockDriverCompletionFunc *cb,
+ BlockdevOnError on_error, BlockDriverCompletionFunc *cb,
void *opaque, Error **errp)
{
CommitBlockJob *s;
@@ -192,8 +192,8 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
BlockDriverState *overlay_bs;
Error *local_err = NULL;
- if ((on_error == BLOCK_ERR_STOP_ANY ||
- on_error == BLOCK_ERR_STOP_ENOSPC) &&
+ if ((on_error == BLOCKDEV_ON_ERROR_STOP ||
+ on_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) {
error_set(errp, QERR_INVALID_PARAMETER_COMBINATION);
return;
diff --git a/block_int.h b/block_int.h
index b98c770..615aafc 100644
--- a/block_int.h
+++ b/block_int.h
@@ -323,7 +323,7 @@ void stream_start(BlockDriverState *bs, BlockDriverState *base,
*/
void commit_start(BlockDriverState *bs, BlockDriverState *base,
BlockDriverState *top, int64_t speed,
- BlockErrorAction on_error, BlockDriverCompletionFunc *cb,
+ BlockdevOnError on_error, BlockDriverCompletionFunc *cb,
void *opaque, Error **errp);
#endif /* BLOCK_INT_H */
diff --git a/blockdev.c b/blockdev.c
index f097e57..6330715 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -241,13 +241,13 @@ static void drive_put_ref_bh_schedule(DriveInfo *dinfo)
static int parse_block_error_action(const char *buf, int is_read)
{
if (!strcmp(buf, "ignore")) {
- return BLOCK_ERR_IGNORE;
+ return BLOCKDEV_ON_ERROR_IGNORE;
} else if (!is_read && !strcmp(buf, "enospc")) {
- return BLOCK_ERR_STOP_ENOSPC;
+ return BLOCKDEV_ON_ERROR_ENOSPC;
} else if (!strcmp(buf, "stop")) {
- return BLOCK_ERR_STOP_ANY;
+ return BLOCKDEV_ON_ERROR_STOP;
} else if (!strcmp(buf, "report")) {
- return BLOCK_ERR_REPORT;
+ return BLOCKDEV_ON_ERROR_REPORT;
} else {
error_report("'%s' invalid %s error action",
buf, is_read ? "read" : "write");
@@ -433,7 +433,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
return NULL;
}
- on_write_error = BLOCK_ERR_STOP_ENOSPC;
+ on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {
error_report("werror is not supported by this bus type");
@@ -446,7 +446,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
}
}
- on_read_error = BLOCK_ERR_REPORT;
+ on_read_error = BLOCKDEV_ON_ERROR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {
error_report("rerror is not supported by this bus type");
@@ -1143,7 +1143,7 @@ void qmp_block_commit(const char *device,
/* This will be part of the QMP command, if/when the
* BlockdevOnError change for blkmirror makes it in
*/
- BlockErrorAction on_error = BLOCK_ERR_REPORT;
+ BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;
/* drain all i/o before commits */
bdrv_drain_all();
diff --git a/hw/fdc.c b/hw/fdc.c
index 08830c1..43b0f20 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1994,11 +1994,11 @@ static int fdctrl_connect_drives(FDCtrl *fdctrl)
drive->fdctrl = fdctrl;
if (drive->bs) {
- if (bdrv_get_on_error(drive->bs, 0) != BLOCK_ERR_STOP_ENOSPC) {
+ if (bdrv_get_on_error(drive->bs, 0) != BLOCKDEV_ON_ERROR_ENOSPC) {
error_report("fdc doesn't support drive option werror");
return -1;
}
- if (bdrv_get_on_error(drive->bs, 1) != BLOCK_ERR_REPORT) {
+ if (bdrv_get_on_error(drive->bs, 1) != BLOCKDEV_ON_ERROR_REPORT) {
error_report("fdc doesn't support drive option rerror");
return -1;
}
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 57b9fa4..2620e87 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -559,13 +559,13 @@ static int ide_handle_rw_error(IDEState *s, int error, int op)
int is_read = (op & BM_STATUS_RETRY_READ);
BlockdevOnError action = bdrv_get_on_error(s->bs, is_read);
- if (action == BLOCK_ERR_IGNORE) {
+ if (action == BLOCKDEV_ON_ERROR_IGNORE) {
bdrv_emit_qmp_error_event(s->bs, BDRV_ACTION_IGNORE, is_read);
return 0;
}
- if ((error == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)
- || action == BLOCK_ERR_STOP_ANY) {
+ if ((error == ENOSPC && action == BLOCKDEV_ON_ERROR_ENOSPC)
+ || action == BLOCKDEV_ON_ERROR_STOP) {
s->bus->dma->ops->set_unit(s->bus->dma, s->unit);
s->bus->error_status = op;
bdrv_emit_qmp_error_event(s->bs, BDRV_ACTION_STOP, is_read);
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index fef83a3..c295326 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -390,13 +390,13 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error)
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
BlockdevOnError action = bdrv_get_on_error(s->qdev.conf.bs, is_read);
- if (action == BLOCK_ERR_IGNORE) {
+ if (action == BLOCKDEV_ON_ERROR_IGNORE) {
bdrv_emit_qmp_error_event(s->qdev.conf.bs, BDRV_ACTION_IGNORE, is_read);
return 0;
}
- if ((error == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)
- || action == BLOCK_ERR_STOP_ANY) {
+ if ((error == ENOSPC && action == BLOCKDEV_ON_ERROR_ENOSPC)
+ || action == BLOCKDEV_ON_ERROR_STOP) {
bdrv_emit_qmp_error_event(s->qdev.conf.bs, BDRV_ACTION_STOP, is_read);
vm_stop(RUN_STATE_IO_ERROR);
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index a5eb663..d904534 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -400,11 +400,11 @@ static int scsi_generic_initfn(SCSIDevice *s)
return -1;
}
- if (bdrv_get_on_error(s->conf.bs, 0) != BLOCK_ERR_STOP_ENOSPC) {
+ if (bdrv_get_on_error(s->conf.bs, 0) != BLOCKDEV_ON_ERROR_ENOSPC) {
error_report("Device doesn't support drive option werror");
return -1;
}
- if (bdrv_get_on_error(s->conf.bs, 1) != BLOCK_ERR_REPORT) {
+ if (bdrv_get_on_error(s->conf.bs, 1) != BLOCKDEV_ON_ERROR_REPORT) {
error_report("Device doesn't support drive option rerror");
return -1;
}
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 01e537d..f178fa8 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -69,13 +69,13 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
BlockdevOnError action = bdrv_get_on_error(req->dev->bs, is_read);
VirtIOBlock *s = req->dev;
- if (action == BLOCK_ERR_IGNORE) {
+ if (action == BLOCKDEV_ON_ERROR_IGNORE) {
bdrv_emit_qmp_error_event(s->bs, BDRV_ACTION_IGNORE, is_read);
return 0;
}
- if ((error == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)
- || action == BLOCK_ERR_STOP_ANY) {
+ if ((error == ENOSPC && action == BLOCKDEV_ON_ERROR_ENOSPC)
+ || action == BLOCKDEV_ON_ERROR_STOP) {
req->next = s->rq;
s->rq = req;
bdrv_emit_qmp_error_event(s->bs, BDRV_ACTION_STOP, is_read);
diff --git a/qapi-schema.json b/qapi-schema.json
index 0f2b1a0..a726413 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1088,6 +1088,29 @@
{ 'command': 'query-pci', 'returns': ['PciInfo'] }
##
+# @BlockdevOnError:
+#
+# An enumeration of possible behaviors for errors on I/O operations.
+# The exact meaning depends on whether the I/O was initiated by a guest
+# or by a block job
+#
+# @report: for guest operations, report the error to the guest;
+# for jobs, cancel the job
+#
+# @ignore: ignore the error, only report a QMP event (BLOCK_IO_ERROR
+# or BLOCK_JOB_ERROR)
+#
+# @enospc: same as @stop on ENOSPC, same as @report otherwise.
+#
+# @stop: for guest operations, stop the virtual machine;
+# for jobs, pause the job
+#
+# Since: 1.3
+##
+{ 'enum': 'BlockdevOnError',
+ 'data': ['report', 'ignore', 'enospc', 'stop'] }
+
+##
# @BlockJobInfo:
#
# Information about a long-running block device operation.
--
1.7.6.5
next prev parent reply other threads:[~2012-09-28 18:54 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-28 17:56 [Qemu-devel] [PULL 00/30] Block patches Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 01/30] block-migration: Flush requests in blk_mig_cleanup Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 02/30] block: after creating a live snapshot, make old image read-only Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 03/30] aio: Fix qemu_aio_wait() to maintain correct walking_handlers count Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 04/30] qemu: URI parsing library Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 05/30] aio: Another fix to the walking_handlers logic Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 06/30] configure: Add a config option for GlusterFS as block backend Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 07/30] block: Support GlusterFS as a QEMU " Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 08/30] block: add support functions for live commit, to find and delete images Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 09/30] block: add live block commit functionality Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 10/30] blockdev: rename block_stream_cb to a generic block_job_cb Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 11/30] block: helper function, to find the base image of a chain Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 12/30] QAPI: add command for live block commit, 'block-commit' Kevin Wolf
2012-10-05 17:29 ` Eric Blake
2012-10-05 18:05 ` Eric Blake
2012-10-08 14:37 ` Paolo Bonzini
2012-10-11 15:42 ` Eric Blake
2012-09-28 17:56 ` [Qemu-devel] [PATCH 13/30] qemu-iotests: add initial tests for live block commit Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 14/30] qerror/block: introduce QERR_BLOCK_JOB_NOT_ACTIVE Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 15/30] block: fix documentation of block_job_cancel_sync Kevin Wolf
2012-09-28 17:56 ` [Qemu-devel] [PATCH 16/30] block: move job APIs to separate files Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 17/30] block: add block_job_query Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 18/30] qmp: add 'busy' member to BlockJobInfo Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 19/30] block: add support for job pause/resume Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 20/30] qmp: add block-job-pause and block-job-resume Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 21/30] qemu-iotests: add test for pausing a streaming operation Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 22/30] iostatus: rename BlockErrorAction, BlockQMPEventAction Kevin Wolf
2012-09-28 17:57 ` Kevin Wolf [this message]
2012-09-28 17:57 ` [Qemu-devel] [PATCH 24/30] iostatus: change is_read to a bool Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 25/30] iostatus: reorganize io error code Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 26/30] block: introduce block job error Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 27/30] stream: add on-error argument Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 28/30] blkdebug: process all set_state rules in the old state Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 29/30] qemu-iotests: map underscore to dash in QMP argument names Kevin Wolf
2012-09-28 17:57 ` [Qemu-devel] [PATCH 30/30] qemu-iotests: add tests for streaming error handling Kevin Wolf
2012-10-05 2:11 ` [Qemu-devel] [PULL 00/30] Block patches Anthony Liguori
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=1348855033-17174-24-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=anthony@codemonkey.ws \
--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).