[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/6] blkdebug: Use errp for read_config()
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH 1/6] blkdebug: Use errp for read_config() |
Date: |
Thu, 21 Nov 2013 20:05:49 +0100 |
Use an Error variable in the read_config() function.
Signed-off-by: Max Reitz <address@hidden>
---
block/blkdebug.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 16d2b91..76f80c0 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -271,7 +271,7 @@ static void remove_rule(BlkdebugRule *rule)
g_free(rule);
}
-static int read_config(BDRVBlkdebugState *s, const char *filename)
+static int read_config(BDRVBlkdebugState *s, const char *filename, Error
**errp)
{
FILE *f;
int ret;
@@ -279,11 +279,16 @@ static int read_config(BDRVBlkdebugState *s, const char
*filename)
f = fopen(filename, "r");
if (f == NULL) {
+ error_setg_errno(errp, errno, "Could not read blkdebug config file "
+ "'%s'", filename);
return -errno;
}
ret = qemu_config_parse(f, config_groups, filename);
if (ret < 0) {
+ error_setg(errp, "Could not parse blkdebug config file '%s'",
+ filename);
+ ret = -EINVAL;
goto fail;
}
@@ -370,9 +375,9 @@ static int blkdebug_open(BlockDriverState *bs, QDict
*options, int flags,
/* Read rules from config file */
config = qemu_opt_get(opts, "config");
if (config) {
- ret = read_config(s, config);
- if (ret < 0) {
- error_setg_errno(errp, -ret, "Could not read blkdebug config
file");
+ ret = read_config(s, config, &local_err);
+ if (ret) {
+ error_propagate(errp, local_err);
goto fail;
}
}
--
1.8.4.2
- [Qemu-devel] [PATCH 0/6] blkdebug/blkverify: Allow command-line configuration, Max Reitz, 2013/11/21
- [Qemu-devel] [PATCH 1/6] blkdebug: Use errp for read_config(),
Max Reitz <=
- [Qemu-devel] [PATCH 2/6] blkdebug: Don't require sophisticated filename, Max Reitz, 2013/11/21
- [Qemu-devel] [PATCH 4/6] blkdebug: Always call read_config(), Max Reitz, 2013/11/21
- [Qemu-devel] [PATCH 5/6] blkdebug: Use command-line in read_config(), Max Reitz, 2013/11/21
- [Qemu-devel] [PATCH 3/6] qemu-option: Add qemu_config_parse_qdict(), Max Reitz, 2013/11/21
- [Qemu-devel] [PATCH 6/6] blkverify: Don't require protocol filename, Max Reitz, 2013/11/21