mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
storage: encryption: Add deep copy function for storage encryption
This commit is contained in:
parent
2624dfde37
commit
756b46ddd2
@ -66,6 +66,46 @@ virStorageEncryptionFree(virStorageEncryptionPtr enc)
|
|||||||
VIR_FREE(enc);
|
VIR_FREE(enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static virStorageEncryptionSecretPtr
|
||||||
|
virStorageEncryptionSecretCopy(const virStorageEncryptionSecret *src)
|
||||||
|
{
|
||||||
|
virStorageEncryptionSecretPtr ret;
|
||||||
|
|
||||||
|
if (VIR_ALLOC(ret) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
memcpy(ret, src, sizeof(*src));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
virStorageEncryptionPtr
|
||||||
|
virStorageEncryptionCopy(const virStorageEncryption *src)
|
||||||
|
{
|
||||||
|
virStorageEncryptionPtr ret;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (VIR_ALLOC(ret) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (VIR_ALLOC_N(ret->secrets, src->nsecrets) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
ret->nsecrets = src->nsecrets;
|
||||||
|
ret->format = src->format;
|
||||||
|
|
||||||
|
for (i = 0; i < src->nsecrets; i++) {
|
||||||
|
if (!(ret->secrets[i] = virStorageEncryptionSecretCopy(src->secrets[i])))
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
error:
|
||||||
|
virStorageEncryptionFree(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static virStorageEncryptionSecretPtr
|
static virStorageEncryptionSecretPtr
|
||||||
virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt,
|
virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt,
|
||||||
xmlNodePtr node)
|
xmlNodePtr node)
|
||||||
|
@ -61,6 +61,9 @@ struct _virStorageEncryption {
|
|||||||
virStorageEncryptionSecretPtr *secrets;
|
virStorageEncryptionSecretPtr *secrets;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virStorageEncryptionPtr virStorageEncryptionCopy(const virStorageEncryption *src)
|
||||||
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
void virStorageEncryptionFree(virStorageEncryptionPtr enc);
|
void virStorageEncryptionFree(virStorageEncryptionPtr enc);
|
||||||
|
|
||||||
virStorageEncryptionPtr virStorageEncryptionParseNode(xmlDocPtr xml,
|
virStorageEncryptionPtr virStorageEncryptionParseNode(xmlDocPtr xml,
|
||||||
|
Loading…
Reference in New Issue
Block a user