From dcfb0939bd7042c9d2622181263c01d78531f272 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 5 Mar 2010 17:25:55 +0100 Subject: 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 --- qemu-config.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'qemu-config.c') diff --git a/qemu-config.c b/qemu-config.c index d4a2f43ff..8254b3516 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; +} -- cgit v1.2.3