static int
-storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr enc,
+storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr encinfo,
char **opts,
struct _virStorageBackendQemuImgInfo info)
{
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,");
static int
storageBackendCreateQemuImgSetOptions(virCommandPtr cmd,
- virStorageEncryptionInfoDefPtr enc,
+ virStorageEncryptionInfoDefPtr encinfo,
struct _virStorageBackendQemuImgInfo info)
{
char *opts = NULL;
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);
.secretPath = secretPath,
.secretAlias = NULL,
};
- virStorageEncryptionInfoDefPtr enc = NULL;
+ virStorageEncryptionPtr enc = vol->target.encryption;
+ virStorageEncryptionInfoDefPtr encinfo = NULL;
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
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"));
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);
/**
* 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
*/
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, ",");
}
}