mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
libxl: provide _init and _setdefault for libxl_domain_create_info.
Some fields require further scaffolding before they can use the _init/_setdefault scheme and are handled in later patches. It doesn't seem reasonable for the library to pick a default for the domain type so reject as invalid. Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
This commit is contained in:
1 parent
95cb7aa35b
commit
c8d71a6de2
5 files changed
+20
-10
No files matched your search
+1
-1
@@ -356,7 +356,7 @@ int libxl_ctx_free(libxl_ctx *ctx /* 0 is OK */);
|
||||
int libxl_ctx_postfork(libxl_ctx *ctx);
|
||||
|
||||
/* domain related functions */
|
||||
int libxl_init_create_info(libxl_ctx *ctx, libxl_domain_create_info *c_info);
|
||||
void libxl_domain_create_info_init(libxl_domain_create_info *c_info);
|
||||
int libxl_init_build_info(libxl_ctx *ctx,
|
||||
libxl_domain_build_info *b_info,
|
||||
libxl_domain_create_info *c_info);
|
||||
|
||||
@@ -50,16 +50,19 @@ void libxl_domain_config_dispose(libxl_domain_config *d_config)
|
||||
libxl_domain_build_info_dispose(&d_config->b_info);
|
||||
}
|
||||
|
||||
int libxl_init_create_info(libxl_ctx *ctx, libxl_domain_create_info *c_info)
|
||||
void libxl_domain_create_info_init(libxl_domain_create_info *c_info)
|
||||
{
|
||||
memset(c_info, '\0', sizeof(*c_info));
|
||||
c_info->xsdata = NULL;
|
||||
c_info->platformdata = NULL;
|
||||
c_info->hap = 1;
|
||||
c_info->type = LIBXL_DOMAIN_TYPE_HVM;
|
||||
c_info->oos = 1;
|
||||
c_info->ssidref = 0;
|
||||
c_info->poolid = 0;
|
||||
}
|
||||
|
||||
int libxl__domain_create_info_setdefault(libxl__gc *gc,
|
||||
libxl_domain_create_info *c_info)
|
||||
{
|
||||
if (!c_info->type)
|
||||
return ERROR_INVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -470,6 +473,9 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
|
||||
|
||||
domid = 0;
|
||||
|
||||
ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info);
|
||||
if (ret) goto error_out;
|
||||
|
||||
ret = libxl__domain_make(gc, &d_config->c_info, &domid);
|
||||
if (ret) {
|
||||
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret);
|
||||
|
||||
@@ -705,7 +705,7 @@ static int libxl__create_stubdom(libxl__gc *gc,
|
||||
goto out;
|
||||
}
|
||||
|
||||
memset(&dm_config.c_info, 0x00, sizeof(libxl_domain_create_info));
|
||||
libxl_domain_create_info_init(&dm_config.c_info);
|
||||
dm_config.c_info.type = LIBXL_DOMAIN_TYPE_PV;
|
||||
dm_config.c_info.name = libxl__sprintf(gc, "%s-dm",
|
||||
libxl__domid_to_name(gc, guest_domid));
|
||||
@@ -740,6 +740,9 @@ static int libxl__create_stubdom(libxl__gc *gc,
|
||||
dm_config.vifs = guest_config->vifs;
|
||||
dm_config.num_vifs = guest_config->num_vifs;
|
||||
|
||||
ret = libxl__domain_create_info_setdefault(gc, &dm_config.c_info);
|
||||
if (ret) goto out;
|
||||
|
||||
libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, &vfb, &vkb);
|
||||
dm_config.vfbs = &vfb;
|
||||
dm_config.num_vfbs = 1;
|
||||
|
||||
@@ -187,6 +187,8 @@ libxl__ev_xswatch *libxl__watch_slot_contents(libxl__gc *gc, int slotnum);
|
||||
* version of the _evdisable_FOO function; the internal one is
|
||||
* used during cleanup.
|
||||
*/
|
||||
_hidden int libxl__domain_create_info_setdefault(libxl__gc *gc,
|
||||
libxl_domain_create_info *c_info);
|
||||
|
||||
struct libxl__evgen_domain_death {
|
||||
uint32_t domid;
|
||||
|
||||
@@ -535,8 +535,7 @@ static void parse_config_data(const char *configfile_filename_report,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (libxl_init_create_info(ctx, c_info))
|
||||
exit(1);
|
||||
libxl_domain_create_info_init(c_info);
|
||||
|
||||
if (!xlu_cfg_get_string (config, "seclabel", &buf, 0)) {
|
||||
e = libxl_flask_context_to_sid(ctx, (char *)buf, strlen(buf),
|
||||
|
||||