From 6045148455bc2b3a37585fb5c36462b97d87077b Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Fri, 8 Apr 2011 20:18:14 +0300 Subject: [PATCH] kvm tools: Cleanup virtio_blk_do_io_request I/O error handling There's no point in keeping track of I/O error count when a simple boolean flag is all we need. Signed-off-by: Pekka Enberg --- tools/kvm/virtio-blk.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/kvm/virtio-blk.c b/tools/kvm/virtio-blk.c index b61b9d43b04f..d14a04b4b3c7 100644 --- a/tools/kvm/virtio-blk.c +++ b/tools/kvm/virtio-blk.c @@ -105,18 +105,20 @@ static bool virtio_blk_do_io_request(struct kvm *self, struct virt_queue *queue) struct virtio_blk_outhdr *req; uint32_t block_len, block_cnt; uint16_t out, in, head; - int err, err_cnt, i; uint8_t *status; + bool io_error; void *block; + int err, i; - head = virt_queue__get_iov(queue, iov, &out, &in, self); + io_error = false; + + head = virt_queue__get_iov(queue, iov, &out, &in, self); /* head */ req = iov[0].iov_base; /* block */ block_cnt = 0; - err_cnt = 0; for (i = 1; i < out + in - 1; i++) { block = iov[i].iov_base; @@ -131,19 +133,16 @@ static bool virtio_blk_do_io_request(struct kvm *self, struct virt_queue *queue) break; default: warning("request type %d", req->type); - err = -1; + io_error = true; } - if (err) - err_cnt++; - req->sector += block_len >> SECTOR_SHIFT; block_cnt += block_len; } /* status */ status = iov[out + in - 1].iov_base; - *status = err_cnt ? VIRTIO_BLK_S_IOERR : VIRTIO_BLK_S_OK; + *status = io_error ? VIRTIO_BLK_S_IOERR : VIRTIO_BLK_S_OK; virt_queue__set_used_elem(queue, head, block_cnt); -- 2.39.5