mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 01:34:11 +03: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);
|
||||
}
|
||||
|
||||
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
|
||||
virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt,
|
||||
xmlNodePtr node)
|
||||
|
@ -61,6 +61,9 @@ struct _virStorageEncryption {
|
||||
virStorageEncryptionSecretPtr *secrets;
|
||||
};
|
||||
|
||||
virStorageEncryptionPtr virStorageEncryptionCopy(const virStorageEncryption *src)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
|
||||
void virStorageEncryptionFree(virStorageEncryptionPtr enc);
|
||||
|
||||
virStorageEncryptionPtr virStorageEncryptionParseNode(xmlDocPtr xml,
|
||||
|
Loading…
Reference in New Issue
Block a user