[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 20 of 23] libxl: add libxl_domain_build_info_init_type
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1329150454 0 # Node ID 1adeebf9e6bd3d74a2f6e35937d4c6ada4212ccd # Parent 871a9c864b558f554f6d72cef59cfc8e6af2d81a libxl: add libxl_domain_build_info_init_type Use instead of parameterising libxl_domain_build_info_init. This allows callers to initialise a libxl_domain_build_info but not to commit to a particular type later on (e.g. after they've parsed the domain config) Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r 871a9c864b55 -r 1adeebf9e6bd tools/libxl/libxl.h --- a/tools/libxl/libxl.h Mon Feb 13 16:27:34 2012 +0000 +++ b/tools/libxl/libxl.h Mon Feb 13 16:27:34 2012 +0000 @@ -389,8 +389,9 @@ int libxl_ctx_postfork(libxl_ctx *ctx); /* domain related functions */ void libxl_domain_create_info_init(libxl_domain_create_info *c_info); -void libxl_domain_build_info_init(libxl_domain_build_info *b_info, - const libxl_domain_create_info *c_info); +void libxl_domain_build_info_init(libxl_domain_build_info *b_info); +void libxl_domain_build_info_init_type(libxl_domain_build_info *b_info, + libxl_domain_type type); typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv); int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid); int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd); diff -r 871a9c864b55 -r 1adeebf9e6bd tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Feb 13 16:27:34 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Feb 13 16:27:34 2012 +0000 @@ -69,23 +69,29 @@ int libxl__domain_create_info_setdefault return 0; } -void libxl_domain_build_info_init(libxl_domain_build_info *b_info, - const libxl_domain_create_info *c_info) +void libxl_domain_build_info_init(libxl_domain_build_info *b_info) { memset(b_info, '\0', sizeof(*b_info)); - b_info->type = c_info->type; + b_info->type = -1; b_info->max_memkb = LIBXL_MEMKB_DEFAULT; b_info->target_memkb = LIBXL_MEMKB_DEFAULT; b_info->shadow_memkb = LIBXL_MEMKB_DEFAULT; b_info->video_memkb = LIBXL_MEMKB_DEFAULT; +} + +void libxl_domain_build_info_init_type(libxl_domain_build_info *b_info, + libxl_domain_type type) +{ + assert(b_info->type == -1); + b_info->type = type; switch (b_info->type) { case LIBXL_DOMAIN_TYPE_HVM: b_info->u.hvm.timer_mode = LIBXL_TIMER_MODE_DEFAULT; break; case LIBXL_DOMAIN_TYPE_PV: - b_info->u.pv.slack_memkb = 0; + b_info->u.pv.slack_memkb = LIBXL_MEMKB_DEFAULT; break; default: abort(); diff -r 871a9c864b55 -r 1adeebf9e6bd tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Feb 13 16:27:34 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Feb 13 16:27:34 2012 +0000 @@ -707,7 +707,8 @@ static int libxl__create_stubdom(libxl__ libxl_uuid_generate(&dm_config.c_info.uuid); - libxl_domain_build_info_init(&dm_config.b_info, &dm_config.c_info); + libxl_domain_build_info_init(&dm_config.b_info); + libxl_domain_build_info_init_type(&dm_config.b_info, LIBXL_DOMAIN_TYPE_PV); dm_config.b_info.max_vcpus = 1; dm_config.b_info.max_memkb = 32 * 1024; diff -r 871a9c864b55 -r 1adeebf9e6bd tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Feb 13 16:27:34 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Feb 13 16:27:34 2012 +0000 @@ -584,7 +584,8 @@ static void parse_config_data(const char exit(1); } - libxl_domain_build_info_init(b_info, c_info); + libxl_domain_build_info_init(b_info); + libxl_domain_build_info_init_type(b_info, c_info->type); /* the following is the actual config parsing with overriding values in the structures */ if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) { @@ -701,7 +702,7 @@ static void parse_config_data(const char if (!xlu_cfg_get_long (config, "videoram", &l, 0)) b_info->video_memkb = l * 1024; - switch(c_info->type) { + switch(b_info->type) { case LIBXL_DOMAIN_TYPE_HVM: if (!xlu_cfg_get_string (config, "kernel", &buf, 0)) fprintf(stderr, "WARNING: ignoring \"kernel\" directive for HVM guest. " _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |