mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
qemu: Define and use a auto cleanup function with virSEVCapability
Keep with the recent effort of replacing as many explicit *Free functions with their automatic equivalents. Signed-off-by: Erik Skultety <eskultet@redhat.com> Acked-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
6c50cef8a3
commit
d96eb28e5e
@ -25,6 +25,7 @@
|
||||
|
||||
# include "internal.h"
|
||||
# include "domain_conf.h"
|
||||
# include "viralloc.h"
|
||||
|
||||
typedef const char * (*virDomainCapsValToStr)(int value);
|
||||
|
||||
@ -215,4 +216,7 @@ char * virDomainCapsFormat(virDomainCapsPtr const caps);
|
||||
|
||||
void
|
||||
virSEVCapabilitiesFree(virSEVCapability *capabilities);
|
||||
|
||||
VIR_DEFINE_AUTOPTR_FUNC(virSEVCapability, virSEVCapabilitiesFree);
|
||||
|
||||
#endif /* __DOMAIN_CAPABILITIES_H__ */
|
||||
|
@ -5263,9 +5263,8 @@ static int
|
||||
virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr qemuCaps,
|
||||
virDomainCapsPtr domCaps)
|
||||
{
|
||||
virSEVCapability *sev;
|
||||
virSEVCapability *cap = qemuCaps->sevCapabilities;
|
||||
int ret = -1;
|
||||
VIR_AUTOPTR(virSEVCapability) sev = NULL;
|
||||
|
||||
if (!cap)
|
||||
return 0;
|
||||
@ -5274,19 +5273,16 @@ virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr qemuCaps,
|
||||
return -1;
|
||||
|
||||
if (VIR_STRDUP(sev->pdh, cap->pdh) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (VIR_STRDUP(sev->cert_chain, cap->cert_chain) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
sev->cbitpos = cap->cbitpos;
|
||||
sev->reduced_phys_bits = cap->reduced_phys_bits;
|
||||
VIR_STEAL_PTR(domCaps->sev, sev);
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virSEVCapabilitiesFree(sev);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -6443,9 +6443,11 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
|
||||
virJSONValuePtr cmd;
|
||||
virJSONValuePtr reply = NULL;
|
||||
virJSONValuePtr caps;
|
||||
virSEVCapability *capability = NULL;
|
||||
const char *pdh = NULL, *cert_chain = NULL;
|
||||
unsigned int cbitpos, reduced_phys_bits;
|
||||
const char *pdh = NULL;
|
||||
const char *cert_chain = NULL;
|
||||
unsigned int cbitpos;
|
||||
unsigned int reduced_phys_bits;
|
||||
VIR_AUTOPTR(virSEVCapability) capability = NULL;
|
||||
|
||||
*capabilities = NULL;
|
||||
|
||||
@ -6476,7 +6478,7 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
|
||||
}
|
||||
|
||||
if (virJSONValueObjectGetNumberUint(caps, "reduced-phys-bits",
|
||||
&reduced_phys_bits) < 0) {
|
||||
&reduced_phys_bits) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("query-sev-capabilities reply was missing"
|
||||
" 'reduced-phys-bits' field"));
|
||||
@ -6512,7 +6514,6 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virSEVCapabilitiesFree(capability);
|
||||
virJSONValueFree(cmd);
|
||||
virJSONValueFree(reply);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user