_("too many secrets for qcow encryption"));
return -1;
}
- if (enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT ||
- enc->nsecrets == 0) {
- if (virStorageGenerateQcowEncryption(vol) < 0)
- return -1;
+ if (enc->nsecrets == 0) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("no secret provided for qcow encryption"));
+ return -1;
}
} else if (format == VIR_STORAGE_FILE_RAW) {
if (enc->format != VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
}
+static int
+storageBackendGenerateSecretData(virStorageVolDefPtr vol)
+{
+ virStorageEncryptionPtr enc = vol->target.encryption;
+
+ if (!enc)
+ return 0;
+
+ if ((vol->target.format == VIR_STORAGE_FILE_QCOW ||
+ vol->target.format == VIR_STORAGE_FILE_QCOW2) &&
+ (enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT ||
+ enc->nsecrets == 0)) {
+ if (virStorageGenerateQcowEncryption(vol) < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+
static int
storageBackendCreateQemuImg(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
return -1;
}
+ if (storageBackendGenerateSecretData(vol) < 0)
+ goto cleanup;
+
if (vol->target.format == VIR_STORAGE_FILE_RAW &&
vol->target.encryption &&
vol->target.encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {