Adjust the parser and switch statements to go with it.
Note that the XEN/libxl drivers had a 'default:' case for few of the
swtich statements so this patch blindly expands it to what it would be
in those cases.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/domain_conf.c | 12 +++---------
src/conf/domain_conf.h | 2 +-
src/libxl/libxl_conf.c | 6 +++++-
src/libxl/xen_common.c | 6 +++++-
4 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d91c058868..6c976b366a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10546,7 +10546,6 @@ virDomainTimerDefParseXML(xmlNodePtr node,
VIR_XPATH_NODE_AUTORESTORE(ctxt)
xmlNodePtr catchup;
int ret;
- g_autofree char *mode = NULL;
ctxt->node = node;
@@ -10577,14 +10576,9 @@ virDomainTimerDefParseXML(xmlNodePtr node,
return NULL;
}
- mode = virXMLPropString(node, "mode");
- if (mode != NULL) {
- if ((def->mode = virDomainTimerModeTypeFromString(mode)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown timer mode '%s'"), mode);
- return NULL;
- }
- }
+ if (virXMLPropEnum(node, "mode", virDomainTimerModeTypeFromString,
+ VIR_XML_PROP_NONZERO, &def->mode) < 0)
+ return NULL;
catchup = virXPathNode("./catchup", ctxt);
if (catchup != NULL) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 36b6757c3c..f5825138e7 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2483,7 +2483,7 @@ struct _virDomainTimerDef {
/* frequency & mode are only valid for name='tsc' */
unsigned long long frequency; /* in Hz, unspecified = 0 */
- int mode; /* enum virDomainTimerModeType */
+ virDomainTimerModeType mode;
};
typedef enum {
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 918303c8d0..d13e48abb2 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -409,8 +409,12 @@ libxlMakeDomBuildInfo(virDomainDef *def,
case VIR_DOMAIN_TIMER_MODE_EMULATE:
b_info->tsc_mode = LIBXL_TSC_MODE_ALWAYS_EMULATE;
break;
- default:
+ case VIR_DOMAIN_TIMER_MODE_NONE:
+ case VIR_DOMAIN_TIMER_MODE_AUTO:
+ case VIR_DOMAIN_TIMER_MODE_SMPSAFE:
b_info->tsc_mode = LIBXL_TSC_MODE_DEFAULT;
+ case VIR_DOMAIN_TIMER_MODE_LAST:
+ break;
}
break;
diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index 6918a4b121..f61719adac 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -2102,9 +2102,13 @@ xenFormatHypervisorFeatures(virConf *conf, virDomainDef *def)
if (xenConfigSetString(conf, "tsc_mode",
"always_emulate") < 0)
return -1;
break;
- default:
+ case VIR_DOMAIN_TIMER_MODE_NONE:
+ case VIR_DOMAIN_TIMER_MODE_AUTO:
+ case VIR_DOMAIN_TIMER_MODE_SMPSAFE:
if (xenConfigSetString(conf, "tsc_mode", "default")
< 0)
return -1;
+ case VIR_DOMAIN_TIMER_MODE_LAST:
+ break;
}
break;
--
2.37.3