virDomainEventActionParseXML(xmlXPathContextPtr ctxt,
const char *name,
const char *xpath,
- int *val,
- int defaultVal,
+ unsigned int *val,
+ unsigned int defaultVal,
virEventActionFromStringFunc convFunc)
{
g_autofree char *tmp = virXPathString(xpath, ctxt);
+ int tmpval;
if (tmp == NULL) {
*val = defaultVal;
} else {
- *val = convFunc(tmp);
- if (*val < 0) {
+ tmpval = convFunc(tmp);
+ if (tmpval < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown %1$s action: %2$s"), name, tmp);
return -1;
}
+ *val = tmpval;
}
return 0;
}
virDomainResourceDef *resource;
virDomainIdMapDef idmap;
- /* These 3 are based on virDomainLifecycleAction enum flags */
- int onReboot;
- int onPoweroff;
- int onCrash;
+ virDomainLifecycleAction onReboot;
+ virDomainLifecycleAction onPoweroff;
+ virDomainLifecycleAction onCrash;
- int onLockFailure; /* enum virDomainLockFailureAction */
+ virDomainLockFailureAction onLockFailure;
virDomainPowerManagement pm;
g_autofree char *on_poweroff = NULL;
g_autofree char *on_reboot = NULL;
g_autofree char *on_crash = NULL;
+ int tmp;
if (xenConfigGetString(conf, "on_poweroff", &on_poweroff, "destroy") < 0)
return -1;
- if ((def->onPoweroff = virDomainLifecycleActionTypeFromString(on_poweroff)) < 0) {
+ if ((tmp = virDomainLifecycleActionTypeFromString(on_poweroff)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected value %1$s for on_poweroff"), on_poweroff);
return -1;
}
+ def->onPoweroff = tmp;
if (xenConfigGetString(conf, "on_reboot", &on_reboot, "restart") < 0)
return -1;
- if ((def->onReboot = virDomainLifecycleActionTypeFromString(on_reboot)) < 0) {
+ if ((tmp = virDomainLifecycleActionTypeFromString(on_reboot)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected value %1$s for on_reboot"), on_reboot);
return -1;
}
+ def->onReboot = tmp;
if (xenConfigGetString(conf, "on_crash", &on_crash, "restart") < 0)
return -1;
- if ((def->onCrash = virDomainLifecycleActionTypeFromString(on_crash)) < 0) {
+ if ((tmp = virDomainLifecycleActionTypeFromString(on_crash)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected value %1$s for on_crash"), on_crash);
return -1;
}
+ def->onCrash = tmp;
return 0;
}