To avoid convolution of switch() inside of virDomainSecDefFormat() even
more (as new sectypes are added), move formatting into a separate
function.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_conf.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9179cc18bb..264f182d05 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -26670,6 +26670,19 @@ virDomainSEVCommonDefFormat(virBuffer *attrBuf,
}
+static void
+virDomainSEVDefFormat(virBuffer *attrBuf,
+ virBuffer *childBuf,
+ virDomainSEVDef *def)
+{
+ virDomainSEVCommonDefFormat(attrBuf, childBuf, &def->common);
+
+ virBufferAsprintf(childBuf, "<policy>0x%04x</policy>\n",
def->policy);
+ virBufferEscapeString(childBuf, "<dhCert>%s</dhCert>\n",
def->dh_cert);
+ virBufferEscapeString(childBuf, "<session>%s</session>\n",
def->session);
+}
+
+
static void
virDomainSecDefFormat(virBuffer *buf, virDomainSecDef *sec)
{
@@ -26683,18 +26696,9 @@ virDomainSecDefFormat(virBuffer *buf, virDomainSecDef *sec)
virDomainLaunchSecurityTypeToString(sec->sectype));
switch ((virDomainLaunchSecurity) sec->sectype) {
- case VIR_DOMAIN_LAUNCH_SECURITY_SEV: {
- virDomainSEVDef *sev = &sec->data.sev;
-
- virDomainSEVCommonDefFormat(&attrBuf, &childBuf, &sev->common);
-
- virBufferAsprintf(&childBuf,
"<policy>0x%04x</policy>\n", sev->policy);
- virBufferEscapeString(&childBuf,
"<dhCert>%s</dhCert>\n", sev->dh_cert);
-
- virBufferEscapeString(&childBuf,
"<session>%s</session>\n", sev->session);
-
+ case VIR_DOMAIN_LAUNCH_SECURITY_SEV:
+ virDomainSEVDefFormat(&attrBuf, &childBuf, &sec->data.sev);
break;
- }
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
break;
--
2.44.2