summaryrefslogtreecommitdiffstats
path: root/qemu-config.c
diff options
context:
space:
mode:
authorKevin Wolf2010-05-17 10:36:47 +0200
committerAnthony Liguori2010-05-24 22:18:23 +0200
commit019e78ba6ec6f402dffc6bc9683f461a11a52c28 (patch)
treea94af7efd41021bd43b7c581fcaedca1e19ad51c /qemu-config.c
parentVirtio-net: Replace the hardcode 6 with defined ETN_ALEN (diff)
downloadqemu-019e78ba6ec6f402dffc6bc9683f461a11a52c28.tar.gz
qemu-019e78ba6ec6f402dffc6bc9683f461a11a52c28.tar.xz
qemu-019e78ba6ec6f402dffc6bc9683f461a11a52c28.zip
Fix error handling in qemu_read_config_file
We need to close the file even in error case. While at it, make the callers catch all kind of errors. ENOENT is allowed for default config files, they are optional. Reported-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qemu-config.c')
-rw-r--r--qemu-config.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/qemu-config.c b/qemu-config.c
index d5008851cb..aa376d450a 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -521,14 +521,18 @@ out:
int qemu_read_config_file(const char *filename)
{
FILE *f = fopen(filename, "r");
+ int ret;
+
if (f == NULL) {
return -errno;
}
- if (qemu_config_parse(f, vm_config_groups, filename) != 0) {
- return -EINVAL;
- }
+ ret = qemu_config_parse(f, vm_config_groups, filename);
fclose(f);
- return 0;
+ if (ret == 0) {
+ return 0;
+ } else {
+ return -EINVAL;
+ }
}