mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 21:15:20 +00:00
conf: Rework virDomainKeyWrapDefParseXML
Rewrite the code to make usage of some VIR_AUTOFREE logic. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
226d069ee4
commit
269d9c1aca
@ -1170,31 +1170,25 @@ static int
|
|||||||
virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt)
|
virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
|
||||||
int n;
|
int n;
|
||||||
VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
|
VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
|
||||||
|
VIR_AUTOFREE(virDomainKeyWrapDefPtr) keywrap = NULL;
|
||||||
|
|
||||||
if ((n = virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)) < 0)
|
if ((n = virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)) < 0)
|
||||||
return n;
|
return n;
|
||||||
|
|
||||||
if (VIR_ALLOC(def->keywrap) < 0)
|
if (VIR_ALLOC(keywrap) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (virDomainKeyWrapCipherDefParseXML(def->keywrap, nodes[i]) < 0)
|
if (virDomainKeyWrapCipherDefParseXML(keywrap, nodes[i]) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!def->keywrap->aes &&
|
if (keywrap->aes || keywrap->dea)
|
||||||
!def->keywrap->dea)
|
VIR_STEAL_PTR(def->keywrap, keywrap);
|
||||||
VIR_FREE(def->keywrap);
|
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (ret < 0)
|
|
||||||
VIR_FREE(def->keywrap);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user