[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 06 of 26 V3] libxl: provide _init and _setdefault for libxl_domain_create_info
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1330000276 0 # Node ID 8052126f50e2dae878ad227a3f0e45cec193c19f # Parent b218d889232a922085e7e9edc50c369e50a4958e 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@xxxxxxxxxx> diff -r b218d889232a -r 8052126f50e2 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Thu Feb 23 12:31:16 2012 +0000 +++ b/tools/libxl/libxl.h Thu Feb 23 12:31:16 2012 +0000 @@ -356,7 +356,7 @@ int libxl_ctx_free(libxl_ctx *ctx /* 0 i 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); diff -r b218d889232a -r 8052126f50e2 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Thu Feb 23 12:31:16 2012 +0000 +++ b/tools/libxl/libxl_create.c Thu Feb 23 12:31:16 2012 +0000 @@ -50,16 +50,19 @@ void libxl_domain_config_dispose(libxl_d 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; } @@ -469,6 +472,9 @@ static int do_domain_create(libxl__gc *g 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); diff -r b218d889232a -r 8052126f50e2 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Thu Feb 23 12:31:16 2012 +0000 +++ b/tools/libxl/libxl_dm.c Thu Feb 23 12:31:16 2012 +0000 @@ -703,7 +703,7 @@ static int libxl__create_stubdom(libxl__ 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)); @@ -738,6 +738,9 @@ static int libxl__create_stubdom(libxl__ 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; diff -r b218d889232a -r 8052126f50e2 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Thu Feb 23 12:31:16 2012 +0000 +++ b/tools/libxl/libxl_internal.h Thu Feb 23 12:31:16 2012 +0000 @@ -187,6 +187,8 @@ libxl__ev_xswatch *libxl__watch_slot_con * 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; diff -r b218d889232a -r 8052126f50e2 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Thu Feb 23 12:31:16 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Thu Feb 23 12:31:16 2012 +0000 @@ -536,8 +536,7 @@ static void parse_config_data(const char 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), _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |