diff options
author | Kevin Wolf <kwolf@redhat.com> | 2010-03-05 17:25:55 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2010-04-23 16:08:45 +0200 |
commit | dcfb0939bd7042c9d2622181263c01d78531f272 (patch) | |
tree | 3ab9d835fb9c0af3cb4a288fddee36dacdb6d2d7 /qemu-config.c | |
parent | 6c557ab975fc8e5edb4167a241266c7c4657054a (diff) | |
download | qemu-dcfb0939bd7042c9d2622181263c01d78531f272.zip qemu-dcfb0939bd7042c9d2622181263c01d78531f272.tar.gz qemu-dcfb0939bd7042c9d2622181263c01d78531f272.tar.bz2 |
qemu-config: qemu_read_config_file() reads the normal config file
Introduce a new function qemu_read_config_file which reads the VM configuration
from a config file. Unlike qemu_config_parse it doesn't take a open file but a
filename and reduces code duplication as a side effect.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-config.c')
-rw-r--r-- | qemu-config.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/qemu-config.c b/qemu-config.c index d4a2f43..8254b35 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -488,3 +488,18 @@ out: loc_pop(&loc); return res; } + +int qemu_read_config_file(const char *filename) +{ + FILE *f = fopen(filename, "r"); + if (f == NULL) { + return -errno; + } + + if (qemu_config_parse(f, filename) != 0) { + return -EINVAL; + } + fclose(f); + + return 0; +} |