提交 3d1db851 编写于 作者: J John Ferlan

storage_util: Generate the qcow secret earlier

Rather than having storageBackendCreateQemuImgCheckEncryption
perform the virStorageGenerateQcowEncryption, let's just do that
earlier during storageBackendCreateQemuImg so that the check
helper is just a check helper rather doing something different
based on whether the format is qcow[2] or raw based encryption.

This fixes an issue in the storageBackendResizeQemuImg processing
for qcow encryption where if a secret was not available for a
volume, a new secret will not be generated and instead an error
message will be generated.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 9629fe25
...@@ -901,9 +901,9 @@ storageBackendCreateQemuImgCheckEncryption(int format, ...@@ -901,9 +901,9 @@ storageBackendCreateQemuImgCheckEncryption(int format,
_("too many secrets for qcow encryption")); _("too many secrets for qcow encryption"));
return -1; return -1;
} }
if (enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT || if (enc->nsecrets == 0) {
enc->nsecrets == 0) { virReportError(VIR_ERR_XML_ERROR, "%s",
if (virStorageGenerateQcowEncryption(vol) < 0) _("no secret provided for qcow encryption"));
return -1; return -1;
} }
} else if (format == VIR_STORAGE_FILE_RAW) { } else if (format == VIR_STORAGE_FILE_RAW) {
...@@ -1309,6 +1309,26 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolObjPtr pool, ...@@ -1309,6 +1309,26 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolObjPtr pool,
} }
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 static int
storageBackendCreateQemuImg(virStoragePoolObjPtr pool, storageBackendCreateQemuImg(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol, virStorageVolDefPtr vol,
...@@ -1330,6 +1350,9 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr pool, ...@@ -1330,6 +1350,9 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr pool,
return -1; return -1;
} }
if (storageBackendGenerateSecretData(vol) < 0)
goto cleanup;
if (vol->target.format == VIR_STORAGE_FILE_RAW && if (vol->target.format == VIR_STORAGE_FILE_RAW &&
vol->target.encryption && vol->target.encryption &&
vol->target.encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) { vol->target.encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册