mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu: block: Split up formatting of JSON props for 'raw' and 'luks' drivers
qemuBlockStorageSourceGetFormatRawProps aggregated both formats but since we now have props specific for either of those formats it's unwanted to aggregate the code such way. Split out the 'luks' props formatter into qemuBlockStorageSourceGetFormatLUKSProps. The wrong separation demonstrates istself on formatting of the 'size' and 'offset' attributes for the 'luks' driver which does not conform to the qapi schema. https://bugzilla.redhat.com/show_bug.cgi?id=1814975 Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7393be3bbc
commit
1a86e3b24a
@ -1200,24 +1200,32 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
|
||||
|
||||
|
||||
static int
|
||||
qemuBlockStorageSourceGetFormatRawProps(virStorageSourcePtr src,
|
||||
qemuBlockStorageSourceGetFormatLUKSProps(virStorageSourcePtr src,
|
||||
virJSONValuePtr props)
|
||||
{
|
||||
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
|
||||
const char *driver = "raw";
|
||||
const char *secretalias = NULL;
|
||||
|
||||
if (src->encryption &&
|
||||
src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS &&
|
||||
srcPriv &&
|
||||
srcPriv->encinfo) {
|
||||
driver = "luks";
|
||||
secretalias = srcPriv->encinfo->s.aes.alias;
|
||||
if (!srcPriv || !srcPriv->encinfo || !srcPriv->encinfo->s.aes.alias) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("missing secret info for 'luks' driver"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectAdd(props,
|
||||
"s:driver", driver,
|
||||
"S:key-secret", secretalias, NULL) < 0)
|
||||
"s:driver", "luks",
|
||||
"s:key-secret", srcPriv->encinfo->s.aes.alias,
|
||||
NULL) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBlockStorageSourceGetFormatRawProps(virStorageSourcePtr src,
|
||||
virJSONValuePtr props)
|
||||
{
|
||||
if (virJSONValueObjectAdd(props, "s:driver", "raw", NULL) < 0)
|
||||
return -1;
|
||||
|
||||
/* Currently only storage slices are supported. We'll have to calculate
|
||||
@ -1371,8 +1379,14 @@ qemuBlockStorageSourceGetBlockdevFormatProps(virStorageSourcePtr src)
|
||||
/* The fat layer is emulated by the storage access layer, so we need to
|
||||
* put a raw layer on top */
|
||||
case VIR_STORAGE_FILE_RAW:
|
||||
if (src->encryption &&
|
||||
src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
|
||||
if (qemuBlockStorageSourceGetFormatLUKSProps(src, props) < 0)
|
||||
return NULL;
|
||||
} else {
|
||||
if (qemuBlockStorageSourceGetFormatRawProps(src, props) < 0)
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_STORAGE_FILE_QCOW2:
|
||||
|
@ -56,7 +56,7 @@ keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
|
||||
"size":321,"file":"libvirt-1-storage","auto-read-only":true,\
|
||||
"discard":"unmap"}' \
|
||||
-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"luks",\
|
||||
"key-secret":"libvirt-1-format-encryption-secret0","offset":1234,"size":321,\
|
||||
"key-secret":"libvirt-1-format-encryption-secret0",\
|
||||
"file":"libvirt-1-slice-sto"}' \
|
||||
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=libvirt-1-format,\
|
||||
id=virtio-disk2 \
|
||||
|
Loading…
Reference in New Issue
Block a user