1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-06 17:17:56 +03:00

conf: Separate SEV formatting into a function

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@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Michal Privoznik 2024-06-11 13:00:58 +02:00
parent d2cad18ca3
commit faa3548ed5

View File

@ -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;