Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/conf/domain_conf.c | 33 +++++++++------------------------
1 file changed, 9 insertions(+), 24 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5822f3d85a..8930dc33ce 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14813,39 +14813,24 @@ static int
virDomainPerfEventDefParseXML(virDomainPerfDef *perf,
xmlNodePtr node)
{
- int event;
- g_autofree char *name = NULL;
- g_autofree char *enabled = NULL;
-
- if (!(name = virXMLPropString(node, "name"))) {
- virReportError(VIR_ERR_XML_ERROR, "%s", _("missing perf event
name"));
- return -1;
- }
+ virPerfEventType name;
+ virTristateBool enabled;
- if ((event = virPerfEventTypeFromString(name)) < 0) {
- virReportError(VIR_ERR_XML_ERROR,
- _("'unsupported perf event '%s'"), name);
+ if (virXMLPropEnum(node, "name", virPerfEventTypeFromString,
+ VIR_XML_PROP_REQUIRED, &name) < 0)
return -1;
- }
- if (perf->events[event] != VIR_TRISTATE_BOOL_ABSENT) {
- virReportError(VIR_ERR_XML_ERROR,
- _("perf event '%s' was already specified"),
name);
+ if (virXMLPropTristateBool(node, "enabled", VIR_XML_PROP_REQUIRED,
&enabled) < 0)
return -1;
- }
- if (!(enabled = virXMLPropString(node, "enabled"))) {
+ if (perf->events[name] != VIR_TRISTATE_BOOL_ABSENT) {
virReportError(VIR_ERR_XML_ERROR,
- _("missing state of perf event '%s'"), name);
+ _("perf event '%s' was already specified"),
+ virPerfEventTypeToString(name));
return -1;
}
- if ((perf->events[event] = virTristateBoolTypeFromString(enabled)) < 0) {
- virReportError(VIR_ERR_XML_ERROR,
- _("invalid state '%s' of perf event
'%s'"),
- enabled, name);
- return -1;
- }
+ perf->events[name] = enabled;
return 0;
}
--
2.26.3