From 42c0c7275deb9e17035f63f7689cf156c3e4d08f Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Mon, 5 Jul 2021 12:46:51 +0200 Subject: [PATCH] virDomainSEVDefParseXML: Use virXMLPropEnum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tim Wiederhake Reviewed-by: Ján Tomko Signed-off-by: Ján Tomko --- src/conf/domain_conf.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 68ab18f3ab..dda615a8ba 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14721,33 +14721,16 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode, VIR_XPATH_NODE_AUTORESTORE(ctxt) virDomainSEVDef *def; unsigned long policy; - g_autofree char *type = NULL; - int sectype; int rc = -1; def = g_new0(virDomainSEVDef, 1); ctxt->node = sevNode; - if (!(type = virXMLPropString(sevNode, "type"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing launch security type")); + if (virXMLPropEnum(sevNode, "type", virDomainLaunchSecurityTypeFromString, + VIR_XML_PROP_NONZERO | VIR_XML_PROP_REQUIRED, + &def->sectype) < 0) goto error; - } - - sectype = virDomainLaunchSecurityTypeFromString(type); - switch ((virDomainLaunchSecurity) sectype) { - case VIR_DOMAIN_LAUNCH_SECURITY_SEV: - break; - case VIR_DOMAIN_LAUNCH_SECURITY_NONE: - case VIR_DOMAIN_LAUNCH_SECURITY_LAST: - default: - virReportError(VIR_ERR_XML_ERROR, - _("unsupported launch security type '%s'"), - type); - goto error; - } - def->sectype = sectype; if (virXPathULongHex("string(./policy)", ctxt, &policy) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s",