static int
-qemuBlockStorageSourceGetFormatRawProps(virStorageSourcePtr src,
- virJSONValuePtr props)
+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
/* 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 (qemuBlockStorageSourceGetFormatRawProps(src, props) < 0)
- return NULL;
+ 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:
"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 \