int ret = -1;
char *size = NULL;
char *create_tool;
+ int imgformat = -1;
const char *type = virStorageFileFormatTypeToString(vol->target.format);
const char *backingType = vol->backingStore.path ?
return -1;
}
+ imgformat = virStorageBackendQEMUImgBackingFormat(create_tool);
+ if (imgformat < 0)
+ goto cleanup;
+
if (inputvol) {
const char *imgargv[] = {
create_tool,
inputPath,
vol->target.path,
NULL,
+ NULL,
+ NULL
};
+ if (vol->target.encryption != NULL) {
+ if (imgformat == QEMU_IMG_BACKING_FORMAT_FLAG) {
+ imgargv[8] = "-o";
+ imgargv[9] = "encryption=on";
+ } else {
+ imgargv[8] = "-e";
+ }
+ }
+
ret = virStorageBackendCreateExecCommand(pool, vol, imgargv);
} else if (vol->backingStore.path) {
const char *imgargv[] = {
NULL,
NULL
};
- int imgformat = virStorageBackendQEMUImgBackingFormat(create_tool);
- char *optflag = NULL;
- if (imgformat < 0)
- goto cleanup;
+ char *optflag = NULL;
switch (imgformat) {
case QEMU_IMG_BACKING_FORMAT_FLAG:
imgargv[6] = "-F";
virReportOOMError();
goto cleanup;
}
+
+ if (vol->target.encryption != NULL) {
+ char *tmp = NULL;
+ if (virAsprintf(&tmp, "%s,%s", optflag, "encryption=on") < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ VIR_FREE(optflag);
+ optflag = tmp;
+ }
+
imgargv[6] = "-o";
imgargv[7] = optflag;
imgargv[8] = vol->target.path;
imgargv[9] = size;
- if (vol->target.encryption != NULL)
- imgargv[10] = "-e";
- break;
default:
VIR_INFO("Unable to set backing store format for %s with %s",
vol->target.path,
size,
NULL,
+ NULL,
NULL
};
- if (vol->target.encryption != NULL)
- imgargv[6] = "-e";
+
+ if (vol->target.encryption != NULL) {
+ if (imgformat == QEMU_IMG_BACKING_FORMAT_FLAG) {
+ imgargv[6] = "-o";
+ imgargv[7] = "encryption=on";
+ } else {
+ imgargv[6] = "-e";
+ }
+ }
ret = virStorageBackendCreateExecCommand(pool, vol, imgargv);
}