From patchwork Fri Jun 15 15:05:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 165186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 258A6B70AB for ; Sat, 16 Jun 2012 02:15:16 +1000 (EST) Received: from localhost ([::1]:59275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfY7p-0004iE-3h for incoming@patchwork.ozlabs.org; Fri, 15 Jun 2012 11:07:49 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfY6r-0002wo-OE for qemu-devel@nongnu.org; Fri, 15 Jun 2012 11:06:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfY6l-0004nU-PP for qemu-devel@nongnu.org; Fri, 15 Jun 2012 11:06:49 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:49781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfY6l-0004fx-Gb for qemu-devel@nongnu.org; Fri, 15 Jun 2012 11:06:43 -0400 Received: by mail-pz0-f45.google.com with SMTP id n2so3246681dad.4 for ; Fri, 15 Jun 2012 08:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=Df1fh0u1V1xDb4lKfjIqKtlsgrKfaQ4IYxBvsEk/S+A=; b=VTG5R0xLTKnWBn2lB2m9GiUutDRmdaCdfjuha4UMH6kirYpVy0TIdoGNieoaHM74Mf 6Pt53thFkz+q53RjYWpryD9+mM+1rQkiaFVfdWmOv2OoijyqlPFlk0ejKqSuKyFtY173 aG/AHFO/o7xpCO+oDQ5rZDDp9pE4EkUmrAgMc7DlM2e5953uq8MzwAbVXm83+i06tUtA d2SorybYK99MLICcU1BCcQSY/ZWYX3c92ll2oNgkE+4rm2u78sjsjEYFriRWli9RJl1O /U77jUWUlP4zAibRWf9bASblVrm2parFftfA3vpQQF992yzoBpkQG4iT+CSKjhhjikZ/ 3yCg== Received: by 10.68.213.234 with SMTP id nv10mr21062006pbc.56.1339772802589; Fri, 15 Jun 2012 08:06:42 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-204-25.ip51.fastwebnet.it. [93.34.204.25]) by mx.google.com with ESMTPS id rs3sm13501390pbc.47.2012.06.15.08.06.39 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jun 2012 08:06:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2012 17:05:33 +0200 Message-Id: <1339772759-31004-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.10.2 In-Reply-To: <1339772759-31004-1-git-send-email-pbonzini@redhat.com> References: <1339772759-31004-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.45 Cc: kwolf@redhat.com, stefanha@linux.vnet.ibm.com, lcapitulino@redhat.com Subject: [Qemu-devel] [RFC PATCH 10/36] block: move BlockdevOnError declaration to QAPI X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This will let block-stream reuse the enum. Signed-off-by: Paolo Bonzini --- block.c | 6 +++--- block.h | 5 ----- blockdev.c | 12 ++++++------ 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 +++++++++++++++++++++++ 9 files changed, 45 insertions(+), 27 deletions(-) diff --git a/block.c b/block.c index 62a3dcf..878b712 100644 --- a/block.c +++ b/block.c @@ -4079,9 +4079,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 bb1ae42..32f8fc5 100644 --- a/block.h +++ b/block.h @@ -89,11 +89,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/blockdev.c b/blockdev.c index 1ea6e94..51bc488 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"); @@ -432,7 +432,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"); @@ -445,7 +445,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"); diff --git a/hw/fdc.c b/hw/fdc.c index bfa4e68..1c266f1 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -1869,11 +1869,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 f78b282..2fb584f 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -560,13 +560,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 76c32e4..b196328 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -392,13 +392,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 d856d23..380925d 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -406,11 +406,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 d4afb20..29f93af 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -68,13 +68,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 c16e1ea..b760bc8 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -896,6 +896,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) +# +# @stop: for guest operations, stop the virtual machine; +# for jobs, pause the job +# +# @enospc: same as @stop on ENOSPC, same as @report otherwise. +# +# Since: 1.2 +## +{ 'enum': 'BlockdevOnError', + 'data': ['report', 'ignore', 'enospc', 'stop'] } + +## # @BlockJobInfo: # # Information about a long-running block device operation.