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

storage_util: Cleanup usage of target.encryption

Remove the != NULL checks, use !! for setting info.encryption.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 9cfd5073
...@@ -423,7 +423,7 @@ storageBackendCreateRaw(virStoragePoolObjPtr pool, ...@@ -423,7 +423,7 @@ storageBackendCreateRaw(virStoragePoolObjPtr pool,
reflink_copy = true; reflink_copy = true;
if (vol->target.encryption != NULL) { if (vol->target.encryption) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("storage pool does not support encrypted volumes")); _("storage pool does not support encrypted volumes"));
goto cleanup; goto cleanup;
...@@ -707,7 +707,7 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, ...@@ -707,7 +707,7 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
return -1; return -1;
} }
if (vol->target.encryption != NULL) { if (vol->target.encryption) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("encrypted ploop volumes are not supported with " _("encrypted ploop volumes are not supported with "
"ploop init")); "ploop init"));
...@@ -1128,7 +1128,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, ...@@ -1128,7 +1128,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool,
.format = vol->target.format, .format = vol->target.format,
.path = vol->target.path, .path = vol->target.path,
.allocation = vol->target.allocation, .allocation = vol->target.allocation,
.encryption = vol->target.encryption != NULL, .encryption = !!vol->target.encryption,
.preallocate = !!(flags & VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA), .preallocate = !!(flags & VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA),
.compat = vol->target.compat, .compat = vol->target.compat,
.features = vol->target.features, .features = vol->target.features,
...@@ -1169,8 +1169,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, ...@@ -1169,8 +1169,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool,
_("format features only available with qcow2")); _("format features only available with qcow2"));
return NULL; return NULL;
} }
if (info.format == VIR_STORAGE_FILE_RAW && if (info.format == VIR_STORAGE_FILE_RAW && vol->target.encryption) {
vol->target.encryption != NULL) {
if (inputvol) { if (inputvol) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("cannot use inputvol with encrypted raw volume")); _("cannot use inputvol with encrypted raw volume"));
...@@ -1220,8 +1219,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, ...@@ -1220,8 +1219,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool,
if (info.backingPath) if (info.backingPath)
virCommandAddArgList(cmd, "-b", info.backingPath, NULL); virCommandAddArgList(cmd, "-b", info.backingPath, NULL);
if (info.format == VIR_STORAGE_FILE_RAW && if (info.format == VIR_STORAGE_FILE_RAW && vol->target.encryption &&
vol->target.encryption != NULL &&
vol->target.encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) { vol->target.encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
if (virAsprintf(&info.secretAlias, "%s_luks0", vol->name) < 0) if (virAsprintf(&info.secretAlias, "%s_luks0", vol->name) < 0)
goto error; goto error;
...@@ -1415,10 +1413,10 @@ virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol, ...@@ -1415,10 +1413,10 @@ virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol,
*/ */
if ((vol->type == VIR_STORAGE_VOL_FILE && if ((vol->type == VIR_STORAGE_VOL_FILE &&
(vol->target.format != VIR_STORAGE_FILE_RAW || (vol->target.format != VIR_STORAGE_FILE_RAW ||
vol->target.encryption != NULL)) || vol->target.encryption)) ||
(inputvol->type == VIR_STORAGE_VOL_FILE && (inputvol->type == VIR_STORAGE_VOL_FILE &&
(inputvol->target.format != VIR_STORAGE_FILE_RAW || (inputvol->target.format != VIR_STORAGE_FILE_RAW ||
inputvol->target.encryption != NULL))) { inputvol->target.encryption))) {
return storageBackendCreateQemuImg; return storageBackendCreateQemuImg;
} }
...@@ -2105,7 +2103,7 @@ storageBackendVolBuildLocal(virStoragePoolObjPtr pool, ...@@ -2105,7 +2103,7 @@ storageBackendVolBuildLocal(virStoragePoolObjPtr pool,
virStorageBackendBuildVolFrom create_func; virStorageBackendBuildVolFrom create_func;
if (inputvol) { if (inputvol) {
if (vol->target.encryption != NULL) { if (vol->target.encryption) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("storage pool does not support " "%s", _("storage pool does not support "
"building encrypted volumes from " "building encrypted volumes from "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册