|
|
cd9d16 |
From 2139ef7f75ff63904fac6b451c8a89e4b0c72448 Mon Sep 17 00:00:00 2001
|
|
|
cd9d16 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
cd9d16 |
Date: Wed, 26 Oct 2011 12:25:25 +0200
|
|
|
cd9d16 |
Subject: [PATCH] vmdk: Improve error handling
|
|
|
cd9d16 |
MIME-Version: 1.0
|
|
|
cd9d16 |
Content-Type: text/plain; charset=UTF-8
|
|
|
cd9d16 |
Content-Transfer-Encoding: 8bit
|
|
|
cd9d16 |
|
|
|
cd9d16 |
Return the right error values in some more places.
|
|
|
cd9d16 |
|
|
|
cd9d16 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
cd9d16 |
(cherry picked from commit 99f1835d9bc744f98370254600530e66f32e6d81)
|
|
|
cd9d16 |
|
|
|
cd9d16 |
Signed-off-by: Bruce Rogers <brogers@suse.com>
|
|
|
cd9d16 |
Signed-off-by: Andreas Färber <afaerber@suse.de>
|
|
|
cd9d16 |
---
|
|
|
cd9d16 |
block/vmdk.c | 21 +++++++++++++++------
|
|
|
cd9d16 |
1 file changed, 15 insertions(+), 6 deletions(-)
|
|
|
cd9d16 |
|
|
|
cd9d16 |
diff --git a/block/vmdk.c b/block/vmdk.c
|
|
|
cd9d16 |
index b5caa40..8284747 100644
|
|
|
cd9d16 |
--- a/block/vmdk.c
|
|
|
cd9d16 |
+++ b/block/vmdk.c
|
|
|
cd9d16 |
@@ -181,8 +181,10 @@ static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
|
|
|
cd9d16 |
const char *p_name, *cid_str;
|
|
|
cd9d16 |
size_t cid_str_size;
|
|
|
cd9d16 |
BDRVVmdkState *s = bs->opaque;
|
|
|
cd9d16 |
+ int ret;
|
|
|
cd9d16 |
|
|
|
cd9d16 |
- if (bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE) != DESC_SIZE) {
|
|
|
cd9d16 |
+ ret = bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE);
|
|
|
cd9d16 |
+ if (ret < 0) {
|
|
|
cd9d16 |
return 0;
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
|
|
|
cd9d16 |
@@ -208,10 +210,12 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
|
|
|
cd9d16 |
char desc[DESC_SIZE], tmp_desc[DESC_SIZE];
|
|
|
cd9d16 |
char *p_name, *tmp_str;
|
|
|
cd9d16 |
BDRVVmdkState *s = bs->opaque;
|
|
|
cd9d16 |
+ int ret;
|
|
|
cd9d16 |
|
|
|
cd9d16 |
memset(desc, 0, sizeof(desc));
|
|
|
cd9d16 |
- if (bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE) != DESC_SIZE) {
|
|
|
cd9d16 |
- return -EIO;
|
|
|
cd9d16 |
+ ret = bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE);
|
|
|
cd9d16 |
+ if (ret < 0) {
|
|
|
cd9d16 |
+ return ret;
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
|
|
|
cd9d16 |
tmp_str = strstr(desc, "parentCID");
|
|
|
cd9d16 |
@@ -223,9 +227,11 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
|
|
|
cd9d16 |
pstrcat(desc, sizeof(desc), tmp_desc);
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
|
|
|
cd9d16 |
- if (bdrv_pwrite_sync(bs->file, s->desc_offset, desc, DESC_SIZE) < 0) {
|
|
|
cd9d16 |
- return -EIO;
|
|
|
cd9d16 |
+ ret = bdrv_pwrite_sync(bs->file, s->desc_offset, desc, DESC_SIZE);
|
|
|
cd9d16 |
+ if (ret < 0) {
|
|
|
cd9d16 |
+ return ret;
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
+
|
|
|
cd9d16 |
return 0;
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
|
|
|
cd9d16 |
@@ -906,7 +912,10 @@ static int vmdk_write(BlockDriverState *bs, int64_t sector_num,
|
|
|
cd9d16 |
/* update CID on the first write every time the virtual disk is
|
|
|
cd9d16 |
* opened */
|
|
|
cd9d16 |
if (!s->cid_updated) {
|
|
|
cd9d16 |
- vmdk_write_cid(bs, time(NULL));
|
|
|
cd9d16 |
+ ret = vmdk_write_cid(bs, time(NULL));
|
|
|
cd9d16 |
+ if (ret < 0) {
|
|
|
cd9d16 |
+ return ret;
|
|
|
cd9d16 |
+ }
|
|
|
cd9d16 |
s->cid_updated = true;
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
--
|
|
|
cd9d16 |
1.7.11.2
|
|
|
cd9d16 |
|