debuggers.hg

view tools/libxl/libxlutil.h @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents 206e25c65694
children
line source
1 /*
2 * Copyright (C) 2010 Citrix Ltd.
3 * Author Ian Jackson <ian.jackson@eu.citrix.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation; version 2.1 only. with the special
8 * exception on linking described in file LICENSE.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 */
16 #ifndef LIBXLUTIL_H
17 #define LIBXLUTIL_H
19 #include <stdio.h>
21 #include "libxl.h"
23 /* Unless otherwise stated, all functions return an errno value. */
24 typedef struct XLU_Config XLU_Config;
25 typedef struct XLU_ConfigList XLU_ConfigList;
27 XLU_Config *xlu_cfg_init(FILE *report, const char *report_filename);
28 /* 0 means we got ENOMEM. */
29 /* report_filename is copied; report is saved and must remain valid
30 * until the Config is destroyed. */
32 int xlu_cfg_readfile(XLU_Config*, const char *real_filename);
33 int xlu_cfg_readdata(XLU_Config*, const char *data, int length);
34 /* If these fail, then it is undefined behaviour to call xlu_cfg_get_...
35 * functions. You have to just xlu_cfg_destroy. */
37 void xlu_cfg_destroy(XLU_Config*);
40 /* All of the following print warnings to "report" if there is a problem.
41 * Return values are:
42 * 0 OK
43 * ESRCH not defined
44 * EINVAL value found but wrong format for request (prints warning)
45 * ERANGE value out of range (from strtol)
46 */
48 int xlu_cfg_get_string(const XLU_Config*, const char *n, const char **value_r);
49 int xlu_cfg_replace_string(const XLU_Config *cfg, const char *n, char **value_r); /* free/strdup version */
50 int xlu_cfg_get_long(const XLU_Config*, const char *n, long *value_r);
52 int xlu_cfg_get_list(const XLU_Config*, const char *n,
53 XLU_ConfigList **list_r /* may be 0 */,
54 int *entries_r /* may be 0 */,
55 int dont_warn);
56 /* there is no need to free *list_r; lifetime is that of the XLU_Config */
57 const char *xlu_cfg_get_listitem(const XLU_ConfigList*, int entry);
58 /* xlu_cfg_get_listitem cannot fail, except that if entry is
59 * out of range it returns 0 (not setting errno) */
61 #endif /* LIBXLUTIL_H */