From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfY6v-000388-In for qemu-devel@nongnu.org; Fri, 15 Jun 2012 11:06:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfY6t-0004oz-0i for qemu-devel@nongnu.org; Fri, 15 Jun 2012 11:06:53 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:47190) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfY6s-0004gs-Lg for qemu-devel@nongnu.org; Fri, 15 Jun 2012 11:06:50 -0400 Received: by mail-pb0-f45.google.com with SMTP id ro12so5648793pbb.4 for ; Fri, 15 Jun 2012 08:06:49 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 15 Jun 2012 17:05:35 +0200 Message-Id: <1339772759-31004-13-git-send-email-pbonzini@redhat.com> In-Reply-To: <1339772759-31004-1-git-send-email-pbonzini@redhat.com> References: <1339772759-31004-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [RFC PATCH 12/36] 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, stefanha@linux.vnet.ibm.com, lcapitulino@redhat.com 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 4011ce4..2f6384a 100644 --- a/block.c +++ b/block.c @@ -4133,9 +4133,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 b760bc8..d09d267 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -429,7 +429,7 @@ # # Since: 1.0 ## -{ 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] } +{ 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'nospace', 'failed' ] } ## # @BlockInfo: -- 1.7.10.2