unsigned long long remain;
char *buf = NULL;
+ if (vol->target.encryption != NULL) {
+ virStorageReportError(conn, VIR_ERR_NO_SUPPORT,
+ "%s", _("storage pool does not support encrypted "
+ "volumes"));
+ return -1;
+ }
+
if ((fd = open(vol->target.path, O_RDWR | O_CREAT | O_EXCL,
vol->target.perms.mode)) < 0) {
virReportSystemError(conn, errno,
NULL;
const char **imgargv;
+ /* The extra NULL field is for indicating encryption (-e). */
const char *imgargvnormal[] = {
NULL, "create",
"-f", type,
vol->target.path,
size,
NULL,
+ NULL
};
/* Extra NULL fields are for including "backingType" when using
- * kvm-img. It's -F backingType
+ * kvm-img (-F backingType), and for indicating encryption (-e).
*/
const char *imgargvbacking[] = {
NULL, "create",
size,
NULL,
NULL,
+ NULL,
NULL
};
const char *convargv[] = {
}
}
+ if (vol->target.encryption != NULL) {
+ if (vol->target.format != VIR_STORAGE_VOL_FILE_QCOW &&
+ vol->target.format != VIR_STORAGE_VOL_FILE_QCOW2) {
+ virStorageReportError(conn, VIR_ERR_NO_SUPPORT,
+ _("qcow volume encryption unsupported with "
+ "volume format %s"), type);
+ return -1;
+ }
+ if (vol->target.encryption->format !=
+ VIR_STORAGE_ENCRYPTION_FORMAT_QCOW) {
+ virStorageReportError(conn, VIR_ERR_NO_SUPPORT,
+ _("unsupported volume encryption format %d"),
+ vol->target.encryption->format);
+ return -1;
+ }
+ if (vol->target.encryption->nsecrets > 1) {
+ virStorageReportError(conn, VIR_ERR_INVALID_STORAGE_VOL,
+ _("too many secrets for qcow encryption"));
+ return -1;
+ }
+ }
+
if ((create_tool = virFindFileInPath("kvm-img")) != NULL)
use_kvmimg = 1;
else if ((create_tool = virFindFileInPath("qemu-img")) != NULL)
imgargvbacking[7] = backingType;
imgargvbacking[8] = vol->target.path;
imgargvbacking[9] = size;
- }
+ if (vol->target.encryption != NULL)
+ imgargvbacking[10] = "-e";
+ } else if (vol->target.encryption != NULL)
+ imgargvbacking[8] = "-e";
imgargv = imgargvbacking;
} else {
imgargvnormal[0] = create_tool;
imgargv = imgargvnormal;
+ if (vol->target.encryption != NULL)
+ imgargv[6] = "-e";
}
"qcow-create"));
return -1;
}
+ if (vol->target.encryption != NULL) {
+ virStorageReportError(conn, VIR_ERR_NO_SUPPORT,
+ "%s", _("encrypted volumes not supported with "
+ "qcow-create"));
+ return -1;
+ }
/* Size in MB - yes different units to qemu-img :-( */
snprintf(size, sizeof(size), "%llu", vol->capacity/1024/1024);