From: Ian Campbell Date: Tue, 31 Jan 2012 16:34:39 +0000 (+0000) Subject: libxl: add named enum for timer mode. X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6ac0345c31bf2992296ffcce227bcb73c0a7d12b;p=xen.git libxl: add named enum for timer mode. Unlike previous iterations of this patch the enum values now match the underlying domctl values. I looked at updating xl.cfg(5) for these while I was here but frankly, even after reading the comment in xen/include/public/hvm/params.h, I don't have a clue what they mean, no_missed_ticks_pending in particular might as well be written in klingon... For the same reason I didn't try and give the enum more user-friendly names. Signed-off-by: Ian Campbell Acked-by: Ian Jackson Committed-by: Ian Jackson --- diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index a9a55df3e9..3ec22bcde1 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -203,6 +203,8 @@ typedef LIBXL_TAILQ_ENTRY(struct libxl_event) libxl_ev_link; typedef struct libxl__ctx libxl_ctx; +#define LIBXL_TIMER_MODE_DEFAULT LIBXL_TIMER_MODE_NO_DELAY_FOR_MISSED_TICKS + #include "_libxl_types.h" const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx); diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 9785cfcbf8..692ee30288 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -251,6 +251,13 @@ out: return ret == 0 ? 0 : ERROR_FAIL; } +static unsigned long timer_mode(const libxl_domain_build_info *info) +{ + const libxl_timer_mode mode = info->u.hvm.timer_mode; + assert(mode != LIBXL_TIMER_MODE_DELAY_FOR_MISSED_TICKS && + mode <= LIBXL_TIMER_MODE_ONE_MISSED_TICK_PENDING); + return ((unsigned long)mode); +} static int hvm_build_set_params(xc_interface *handle, uint32_t domid, libxl_domain_build_info *info, int store_evtchn, unsigned long *store_mfn, @@ -282,7 +289,7 @@ static int hvm_build_set_params(xc_interface *handle, uint32_t domid, xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN, info->u.hvm.viridian); xc_set_hvm_param(handle, domid, HVM_PARAM_HPET_ENABLED, (unsigned long) info->u.hvm.hpet); #endif - xc_set_hvm_param(handle, domid, HVM_PARAM_TIMER_MODE, (unsigned long) info->u.hvm.timer_mode); + xc_set_hvm_param(handle, domid, HVM_PARAM_TIMER_MODE, timer_mode(info)); xc_set_hvm_param(handle, domid, HVM_PARAM_VPT_ALIGN, (unsigned long) info->u.hvm.vpt_align); xc_set_hvm_param(handle, domid, HVM_PARAM_NESTEDHVM, info->u.hvm.nested_hvm); xc_set_hvm_param(handle, domid, HVM_PARAM_STORE_EVTCHN, store_evtchn); diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index f9d6c97c51..3c24626d8e 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -91,6 +91,14 @@ libxl_tsc_mode = Enumeration("tsc_mode", [ (3, "native_paravirt"), ]) +# Consistent with the values defined for HVM_PARAM_TIMER_MODE. +libxl_timer_mode = Enumeration("timer_mode", [ + (0, "delay_for_missed_ticks"), + (1, "no_delay_for_missed_ticks"), + (2, "no_missed_ticks_pending"), + (3, "one_missed_tick_pending"), + ]) + # # Complex libxl types # @@ -229,7 +237,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("timeoffset", string), ("hpet", bool), ("vpt_align", bool), - ("timer_mode", integer), + ("timer_mode", libxl_timer_mode), ("nested_hvm", bool), ("no_incr_generationid", bool), ("nographic", bool), diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 7ea31635a1..fc9a59c983 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -358,7 +358,9 @@ static void printf_info(int domid, printf("\t\t\t(viridian %d)\n", b_info->u.hvm.viridian); printf("\t\t\t(hpet %d)\n", b_info->u.hvm.hpet); printf("\t\t\t(vpt_align %d)\n", b_info->u.hvm.vpt_align); - printf("\t\t\t(timer_mode %d)\n", b_info->u.hvm.timer_mode); + printf("\t\t\t(timer_mode %s)\n", + libxl_timer_mode_to_string(b_info->u.hvm.timer_mode)); + printf("\t\t\t(nestedhvm %d)\n", b_info->u.hvm.nested_hvm); printf("\t\t\t(no_incr_generationid %d)\n", b_info->u.hvm.no_incr_generationid); @@ -840,8 +842,30 @@ static void parse_config_data(const char *configfile_filename_report, b_info->u.hvm.hpet = l; if (!xlu_cfg_get_long (config, "vpt_align", &l, 0)) b_info->u.hvm.vpt_align = l; - if (!xlu_cfg_get_long (config, "timer_mode", &l, 0)) + + if (!xlu_cfg_get_long(config, "timer_mode", &l, 1)) { + const char *s = libxl_timer_mode_to_string(l); + fprintf(stderr, "WARNING: specifying \"timer_mode\" as an integer is deprecated. " + "Please use the named parameter variant. %s%s%s\n", + s ? "e.g. timer_mode=\"" : "", + s ? s : "", + s ? "\"" : ""); + + if (l < LIBXL_TIMER_MODE_DELAY_FOR_MISSED_TICKS || + l > LIBXL_TIMER_MODE_ONE_MISSED_TICK_PENDING) { + fprintf(stderr, "ERROR: invalid value %ld for \"timer_mode\"\n", l); + exit (1); + } b_info->u.hvm.timer_mode = l; + } else if (!xlu_cfg_get_string(config, "timer_mode", &buf, 0)) { + fprintf(stderr, "got a timer mode string: \"%s\"\n", buf); + if (libxl_timer_mode_from_string(buf, &b_info->u.hvm.timer_mode)) { + fprintf(stderr, "ERROR: invalid value \"%s\" for \"timer_mode\"\n", + buf); + exit (1); + } + } + if (!xlu_cfg_get_long (config, "nestedhvm", &l, 0)) b_info->u.hvm.nested_hvm = l; break;