|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 29 of 32 RFC] libxl: add named enum for timer mode
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1326713149 0
# Node ID feeea78c60ef4a0ec5d4d827bb15cc004ece9774
# Parent 90fe4b95bdc935b2d5328603aa77d4de37253c36
libxl: add named enum for timer mode.
In order to have 0 == default the specific values are off-by-one from the
underlying domctl. I'm not sure I like this.
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 <ian.campbell@xxxxxxxxxx>
diff -r 90fe4b95bdc9 -r feeea78c60ef tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Mon Jan 16 11:18:54 2012 +0000
+++ b/tools/libxl/libxl_create.c Mon Jan 16 11:25:49 2012 +0000
@@ -91,7 +91,6 @@ int libxl_init_build_info(libxl_ctx *ctx
switch (b_info->type) {
case LIBXL_DOMAIN_TYPE_HVM:
- b_info->u.hvm.timer_mode = 1;
break;
case LIBXL_DOMAIN_TYPE_PV:
b_info->u.pv.slack_memkb = 8 * 1024;
@@ -122,6 +121,9 @@ int libxl__domain_build_info_setdefaults
case LIBXL_DOMAIN_TYPE_HVM:
if (!b_info->video_memkb)
b_info->video_memkb = 8 * 1024;
+ if (b_info->u.hvm.timer_mode == LIBXL_TIMER_MODE_DEFAULT)
+ b_info->u.hvm.timer_mode =
+ LIBXL_TIMER_MODE_NO_DELAY_FOR_MISSED_TICKS;
libxl_defbool_setdefault(&b_info->u.hvm.pae, true);
libxl_defbool_setdefault(&b_info->u.hvm.apic, true);
diff -r 90fe4b95bdc9 -r feeea78c60ef tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Mon Jan 16 11:18:54 2012 +0000
+++ b/tools/libxl/libxl_dom.c Mon Jan 16 11:25:49 2012 +0000
@@ -248,6 +248,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) - 1;
+}
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_inter
xc_set_hvm_param(handle, domid, HVM_PARAM_HPET_ENABLED,
libxl_defbool_val(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,
libxl_defbool_val(info->u.hvm.vpt_align));
xc_set_hvm_param(handle, domid, HVM_PARAM_NESTEDHVM,
diff -r 90fe4b95bdc9 -r feeea78c60ef tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl Mon Jan 16 11:18:54 2012 +0000
+++ b/tools/libxl/libxl_types.idl Mon Jan 16 11:25:49 2012 +0000
@@ -94,6 +94,15 @@ libxl_tsc_mode = Enumeration("tsc_mode",
(3, "native_paravirt"),
])
+# NB: specific values are + 1 from underlying hypercall value
+libxl_timer_mode = Enumeration("timer_mode", [
+ (0, "default"),
+ (1, "delay_for_missed_ticks"),
+ (2, "no_delay_for_missed_ticks"),
+ (3, "no_missed_ticks_pending"),
+ (4, "one_missed_tick_pending"),
+ ])
+
#
# Complex libxl types
#
@@ -232,7 +241,7 @@ libxl_domain_build_info = Struct("domain
("timeoffset", string),
("hpet", libxl_defbool),
("vpt_align", libxl_defbool),
- ("timer_mode", integer),
+ ("timer_mode", libxl_timer_mode),
("nested_hvm", libxl_defbool),
("nographic", libxl_defbool),
("stdvga", libxl_defbool),
diff -r 90fe4b95bdc9 -r feeea78c60ef tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Mon Jan 16 11:18:54 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c Mon Jan 16 11:25:49 2012 +0000
@@ -363,7 +363,8 @@ static void printf_info(int domid,
libxl_defbool_to_string(b_info->u.hvm.hpet));
printf("\t\t\t(vpt_align %s)\n",
libxl_defbool_to_string(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 %s)\n",
libxl_defbool_to_string(b_info->u.hvm.nested_hvm));
printf("\t\t\t(stdvga %s)\n",
@@ -765,8 +766,31 @@ static void parse_config_data(const char
xlu_cfg_get_defbool(config, "viridian", &b_info->u.hvm.viridian, 0);
xlu_cfg_get_defbool(config, "hpet", &b_info->u.hvm.hpet, 0);
xlu_cfg_get_defbool(config, "vpt_align", &b_info->u.hvm.vpt_align, 0);
- if (!xlu_cfg_get_long (config, "timer_mode", &l, 0))
+
+ if (!xlu_cfg_get_long(config, "timer_mode", &l, 1)) {
+ /* enum is off by one from raw number */
+ 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_DEFAULT ||
+ 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);
+ }
+ }
+
xlu_cfg_get_defbool(config, "nestedhvm", &b_info->u.hvm.nested_hvm, 0);
break;
case LIBXL_DOMAIN_TYPE_PV:
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |