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);
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,
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);
(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
#
("timeoffset", string),
("hpet", bool),
("vpt_align", bool),
- ("timer_mode", integer),
+ ("timer_mode", libxl_timer_mode),
("nested_hvm", bool),
("no_incr_generationid", bool),
("nographic", bool),
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);
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;