mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
qcrypto/core: add generic infrastructure for crypto options amendment
This will be used first to implement luks keyslot management. block_crypto_amend_opts_init will be used to convert qemu-img cmdline to QCryptoBlockAmendOptions Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20200608094030.670121-2-mlevitsk@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
d2a839ede8
commit
43cbd06df2
6 changed files with 95 additions and 0 deletions
|
@ -150,6 +150,35 @@ qcrypto_block_calculate_payload_offset(QCryptoBlockCreateOptions *create_opts,
|
|||
return crypto != NULL;
|
||||
}
|
||||
|
||||
int qcrypto_block_amend_options(QCryptoBlock *block,
|
||||
QCryptoBlockReadFunc readfunc,
|
||||
QCryptoBlockWriteFunc writefunc,
|
||||
void *opaque,
|
||||
QCryptoBlockAmendOptions *options,
|
||||
bool force,
|
||||
Error **errp)
|
||||
{
|
||||
if (options->format != block->format) {
|
||||
error_setg(errp,
|
||||
"Cannot amend encryption format");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!block->driver->amend) {
|
||||
error_setg(errp,
|
||||
"Crypto format %s doesn't support format options amendment",
|
||||
QCryptoBlockFormat_str(block->format));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return block->driver->amend(block,
|
||||
readfunc,
|
||||
writefunc,
|
||||
opaque,
|
||||
options,
|
||||
force,
|
||||
errp);
|
||||
}
|
||||
|
||||
QCryptoBlockInfo *qcrypto_block_get_info(QCryptoBlock *block,
|
||||
Error **errp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue