[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 06 of 27 V4] libxl: provide _init and _setdefault for libxl_domain_create_info
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1330533035 0 # Node ID 1284834d9b10a613573e0889822736e6e8941e0f # Parent 8cfc778d4547fc37f16895771312d858c5eca5b9 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 8cfc778d4547 -r 1284834d9b10 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Wed Feb 29 16:30:35 2012 +0000 +++ b/tools/libxl/libxl.h Wed Feb 29 16:30:35 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 8cfc778d4547 -r 1284834d9b10 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Wed Feb 29 16:30:35 2012 +0000 +++ b/tools/libxl/libxl_create.c Wed Feb 29 16:30:35 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; } @@ -470,6 +473,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 8cfc778d4547 -r 1284834d9b10 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Wed Feb 29 16:30:35 2012 +0000 +++ b/tools/libxl/libxl_dm.c Wed Feb 29 16:30:35 2012 +0000 @@ -705,7 +705,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)); @@ -740,6 +740,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 8cfc778d4547 -r 1284834d9b10 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Wed Feb 29 16:30:35 2012 +0000 +++ b/tools/libxl/libxl_internal.h Wed Feb 29 16:30:35 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 8cfc778d4547 -r 1284834d9b10 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Wed Feb 29 16:30:35 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Wed Feb 29 16:30:35 2012 +0000 @@ -535,8 +535,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 |