提交 af0e6580 编写于 作者: J John Ferlan

storage: Rename encryption info variable for clarity

Change from @enc to @encinfo leaving @enc for the vol->target.encryption
in the storageBackendCreateQemuImgSetOptions code path.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
ACKed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 23e9aa72
......@@ -817,7 +817,7 @@ struct _virStorageBackendQemuImgInfo {
static int
storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr enc,
storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr encinfo,
char **opts,
struct _virStorageBackendQemuImgInfo info)
{
......@@ -827,8 +827,8 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr enc,
virBufferAsprintf(&buf, "backing_fmt=%s,",
virStorageFileFormatTypeToString(info.backingFormat));
if (info.format == VIR_STORAGE_FILE_RAW && enc) {
virQEMUBuildQemuImgKeySecretOpts(&buf, enc, info.secretAlias);
if (info.format == VIR_STORAGE_FILE_RAW && encinfo) {
virQEMUBuildQemuImgKeySecretOpts(&buf, encinfo, info.secretAlias);
} else {
if (info.encryption)
virBufferAddLit(&buf, "encryption=on,");
......@@ -1037,7 +1037,7 @@ storageBackendCreateQemuImgSetBacking(virStoragePoolObjPtr pool,
static int
storageBackendCreateQemuImgSetOptions(virCommandPtr cmd,
virStorageEncryptionInfoDefPtr enc,
virStorageEncryptionInfoDefPtr encinfo,
struct _virStorageBackendQemuImgInfo info)
{
char *opts = NULL;
......@@ -1045,7 +1045,7 @@ storageBackendCreateQemuImgSetOptions(virCommandPtr cmd,
if (info.format == VIR_STORAGE_FILE_QCOW2 && !info.compat)
info.compat = "0.10";
if (storageBackendCreateQemuImgOpts(enc, &opts, info) < 0)
if (storageBackendCreateQemuImgOpts(encinfo, &opts, info) < 0)
return -1;
if (opts)
virCommandAddArgList(cmd, "-o", opts, NULL);
......@@ -1209,7 +1209,8 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool,
.secretPath = secretPath,
.secretAlias = NULL,
};
virStorageEncryptionInfoDefPtr enc = NULL;
virStorageEncryptionPtr enc = vol->target.encryption;
virStorageEncryptionInfoDefPtr encinfo = NULL;
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
......@@ -1231,8 +1232,8 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool,
if (info.backingPath)
virCommandAddArgList(cmd, "-b", info.backingPath, NULL);
if (info.format == VIR_STORAGE_FILE_RAW && vol->target.encryption &&
vol->target.encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
if (info.format == VIR_STORAGE_FILE_RAW && enc &&
enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
if (!info.secretPath) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("path to secret data file is required"));
......@@ -1243,10 +1244,10 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool,
if (storageBackendCreateQemuImgSecretObject(cmd, info.secretPath,
info.secretAlias) < 0)
goto error;
enc = &vol->target.encryption->encinfo;
encinfo = &enc->encinfo;
}
if (storageBackendCreateQemuImgSetOptions(cmd, enc, info) < 0)
if (storageBackendCreateQemuImgSetOptions(cmd, encinfo, info) < 0)
goto error;
VIR_FREE(info.secretAlias);
......
......@@ -315,7 +315,7 @@ virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str)
/**
* virQEMUBuildQemuImgKeySecretOpts:
* @buf: buffer to build the string into
* @enc: pointer to encryption info
* @encinfo: pointer to encryption info
* @alias: alias to use
*
* Generate the string for id=$alias and any encryption options for
......@@ -334,37 +334,37 @@ virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str)
*/
void
virQEMUBuildQemuImgKeySecretOpts(virBufferPtr buf,
virStorageEncryptionInfoDefPtr enc,
virStorageEncryptionInfoDefPtr encinfo,
const char *alias)
{
virBufferAsprintf(buf, "key-secret=%s,", alias);
if (!enc->cipher_name)
if (!encinfo->cipher_name)
return;
virBufferAddLit(buf, "cipher-alg=");
virQEMUBuildBufferEscapeComma(buf, enc->cipher_name);
virBufferAsprintf(buf, "-%u,", enc->cipher_size);
if (enc->cipher_mode) {
virQEMUBuildBufferEscapeComma(buf, encinfo->cipher_name);
virBufferAsprintf(buf, "-%u,", encinfo->cipher_size);
if (encinfo->cipher_mode) {
virBufferAddLit(buf, "cipher-mode=");
virQEMUBuildBufferEscapeComma(buf, enc->cipher_mode);
virQEMUBuildBufferEscapeComma(buf, encinfo->cipher_mode);
virBufferAddLit(buf, ",");
}
if (enc->cipher_hash) {
if (encinfo->cipher_hash) {
virBufferAddLit(buf, "hash-alg=");
virQEMUBuildBufferEscapeComma(buf, enc->cipher_hash);
virQEMUBuildBufferEscapeComma(buf, encinfo->cipher_hash);
virBufferAddLit(buf, ",");
}
if (!enc->ivgen_name)
if (!encinfo->ivgen_name)
return;
virBufferAddLit(buf, "ivgen-alg=");
virQEMUBuildBufferEscapeComma(buf, enc->ivgen_name);
virQEMUBuildBufferEscapeComma(buf, encinfo->ivgen_name);
virBufferAddLit(buf, ",");
if (enc->ivgen_hash) {
if (encinfo->ivgen_hash) {
virBufferAddLit(buf, "ivgen-hash-alg=");
virQEMUBuildBufferEscapeComma(buf, enc->ivgen_hash);
virQEMUBuildBufferEscapeComma(buf, encinfo->ivgen_hash);
virBufferAddLit(buf, ",");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册