# include "internal.h"
# include "domain_conf.h"
+# include "viralloc.h"
typedef const char * (*virDomainCapsValToStr)(int value);
void
virSEVCapabilitiesFree(virSEVCapability *capabilities);
+
+VIR_DEFINE_AUTOPTR_FUNC(virSEVCapability, virSEVCapabilitiesFree);
+
#endif /* __DOMAIN_CAPABILITIES_H__ */
virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsPtr domCaps)
{
- virSEVCapability *sev;
virSEVCapability *cap = qemuCaps->sevCapabilities;
- int ret = -1;
+ VIR_AUTOPTR(virSEVCapability) sev = NULL;
if (!cap)
return 0;
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;
}
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;
}
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"));
ret = 0;
cleanup:
- virSEVCapabilitiesFree(capability);
virJSONValueFree(cmd);
virJSONValueFree(reply);