[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 02 of 23] libxl: provide _init and _setdefault for libxl_domain_create_info
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1329148119 0 # Node ID 53d4e198863a29e204186ab10c8950c3bd4235a8 # Parent d50c4dc752717e2742a7e9018fcbaffbfff9ea6c 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 d50c4dc75271 -r 53d4e198863a tools/libxl/libxl.h --- a/tools/libxl/libxl.h Mon Feb 13 15:35:18 2012 +0000 +++ b/tools/libxl/libxl.h Mon Feb 13 15:48:39 2012 +0000 @@ -363,7 +363,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 d50c4dc75271 -r 53d4e198863a tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Feb 13 15:35:18 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Feb 13 15:48:39 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 d50c4dc75271 -r 53d4e198863a tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Feb 13 15:35:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Feb 13 15:48:39 2012 +0000 @@ -699,7 +699,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)); @@ -734,6 +734,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 d50c4dc75271 -r 53d4e198863a tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon Feb 13 15:35:18 2012 +0000 +++ b/tools/libxl/libxl_internal.h Mon Feb 13 15:48:39 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 d50c4dc75271 -r 53d4e198863a tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Feb 13 15:35:18 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Feb 13 15:48:39 2012 +0000 @@ -537,8 +537,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@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |