From 560e15896d09ccb26cd49138f5a8de303ae05f8d Mon Sep 17 00:00:00 2001 From: Kevin Wolf <kwolf@redhat.com> Date: Fri, 18 Jun 2010 15:22:21 -0300 Subject: [PATCH 03/18] qcow2: Return 0/-errno in write_l2_entries RH-Author: Kevin Wolf <kwolf@redhat.com> Message-id: <1276874554-9820-4-git-send-email-kwolf@redhat.com> Patchwork-id: 9978 O-Subject: [RHEL-5.6 KVM PATCH 03/16] qcow2: Return 0/-errno in write_l2_entries Bugzilla: 605701 RH-Acked-by: Juan Quintela <quintela@redhat.com> RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com> RH-Acked-by: Christoph Hellwig <chellwig@redhat.com> RH-Acked-by: Jes Sorensen <Jes.Sorensen@redhat.com> Bugzilla: 605701 Upstream commit: 79a31189d4e3d226c6c700d630476ec63bbc19a2 Change write_l2_entries to return the real error code instead of -1. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- qemu/block-qcow2.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- qemu/block-qcow2.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c index 04cf7a5..0576aad 100644 --- a/qemu/block-qcow2.c +++ b/qemu/block-qcow2.c @@ -1037,11 +1037,12 @@ static int write_l2_entries(BDRVQcowState *s, uint64_t *l2_table, int start_offset = (8 * l2_index) & ~511; int end_offset = (8 * (l2_index + num) + 511) & ~511; size_t len = end_offset - start_offset; + int ret; - if (bdrv_pwrite(s->hd, l2_offset + start_offset, &l2_table[l2_start_index], - len) != len) - { - return -1; + ret = bdrv_pwrite(s->hd, l2_offset + start_offset, + &l2_table[l2_start_index], len); + if (ret < 0) { + return ret; } return 0; -- 1.7.0.3