[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 24 of 27 V4] libxl: add libxl_domain_build_info_init_type
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1330598786 0 # Node ID 6be99cd73e1e242d516b1e4ac2d59dd940904a54 # Parent 708e5be5a38cf88a6dd5da81c41a632a6281269f 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> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> diff -r 708e5be5a38c -r 6be99cd73e1e tools/libxl/libxl.h --- a/tools/libxl/libxl.h Thu Mar 01 10:46:26 2012 +0000 +++ b/tools/libxl/libxl.h Thu Mar 01 10:46:26 2012 +0000 @@ -382,8 +382,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 708e5be5a38c -r 6be99cd73e1e tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Thu Mar 01 10:46:26 2012 +0000 +++ b/tools/libxl/libxl_create.c Thu Mar 01 10:46:26 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 708e5be5a38c -r 6be99cd73e1e tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Thu Mar 01 10:46:26 2012 +0000 +++ b/tools/libxl/libxl_dm.c Thu Mar 01 10:46:26 2012 +0000 @@ -701,7 +701,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 708e5be5a38c -r 6be99cd73e1e tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Thu Mar 01 10:46:26 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Thu Mar 01 10:46:26 2012 +0000 @@ -582,7 +582,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)) { @@ -699,7 +700,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@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |