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>
This commit is contained in:
Kevin Wolf 2010-03-05 17:25:55 +01:00
parent 6c557ab975
commit dcfb0939bd
3 changed files with 28 additions and 24 deletions

View file

@ -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;
}