From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StcvS-00063C-1t for qemu-devel@nongnu.org; Tue, 24 Jul 2012 07:05:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StcvQ-0005Pg-OU for qemu-devel@nongnu.org; Tue, 24 Jul 2012 07:05:13 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:61960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StcvQ-00057s-Jk for qemu-devel@nongnu.org; Tue, 24 Jul 2012 07:05:12 -0400 Received: by mail-yx0-f173.google.com with SMTP id l1so6601761yen.4 for ; Tue, 24 Jul 2012 04:05:12 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 24 Jul 2012 13:03:50 +0200 Message-Id: <1343127865-16608-13-git-send-email-pbonzini@redhat.com> In-Reply-To: <1343127865-16608-1-git-send-email-pbonzini@redhat.com> References: <1343127865-16608-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 12/47] block: sort BlockDeviceIoStatus errors by severity List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, jcody@redhat.com, eblake@redhat.com, stefanha@linux.vnet.ibm.com This does not let a "failed" (EIO) status override a "nospace" status. When several concurrent asynchronous operations fail, management will always observe the most severe condition. Signed-off-by: Paolo Bonzini --- block.c | 11 ++++++++--- qapi-schema.json | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index 333a8fd..dce07b3 100644 --- a/block.c +++ b/block.c @@ -3883,9 +3883,14 @@ void bdrv_iostatus_reset(BlockDriverState *bs) void bdrv_iostatus_set_err(BlockDriverState *bs, int error) { assert(bdrv_iostatus_is_enabled(bs)); - if (bs->iostatus == BLOCK_DEVICE_IO_STATUS_OK) { - bs->iostatus = error == ENOSPC ? BLOCK_DEVICE_IO_STATUS_NOSPACE : - BLOCK_DEVICE_IO_STATUS_FAILED; + BlockDeviceIoStatus new_status = + (error == ENOSPC ? BLOCK_DEVICE_IO_STATUS_NOSPACE : + BLOCK_DEVICE_IO_STATUS_FAILED); + + /* iostatus values are sorted from less severe to most severe + * (ok, nospace, failed). */ + if (bs->iostatus < new_status) { + bs->iostatus = new_status; } } diff --git a/qapi-schema.json b/qapi-schema.json index 136ce5e..2dee7c3 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -435,7 +435,7 @@ # # Since: 1.0 ## -{ 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] } +{ 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'nospace', 'failed' ] } ## # @BlockInfo: -- 1.7.10.4