struct _virStorageBackendQemuImgInfo {
int format;
const char *type;
+ const char *inputType;
const char *path;
unsigned long long size_arg;
unsigned long long allocation;
return -1;
}
+ if (inputvol &&
+ !(info->inputType =
+ virStorageFileFormatTypeToString(inputvol->target.format))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown inputvol storage vol type %d"),
+ inputvol->target.format);
+ return -1;
+ }
+
if (info->preallocate && info->format != VIR_STORAGE_FILE_QCOW2) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("metadata preallocation only available with qcow2"));
struct _virStorageBackendQemuImgInfo info = {
.format = vol->target.format,
.type = NULL,
+ .inputType = NULL,
.path = vol->target.path,
.allocation = vol->target.allocation,
.encryption = !!vol->target.encryption,
virCommandAddArgFormat(cmd, "%lluK", info.size_arg);
} else {
/* source */
- virCommandAddArgFormat(cmd, "driver=raw,file.filename=%s",
+ virCommandAddArgFormat(cmd, "driver=%s,file.filename=%s",
+ info.inputType ? info.inputType : "raw",
info.inputPath);
/* dest */
--- /dev/null
+qemu-img create -f luks \
+--object secret,id=OtherDemo.img_encrypt0,file=/path/to/secretFile \
+-o key-secret=OtherDemo.img_encrypt0 \
+/var/lib/libvirt/images/OtherDemo.img 5242880K
+qemu-img convert --image-opts -n --target-image-opts \
+--object secret,id=OtherDemo.img_encrypt0,file=/path/to/secretFile \
+driver=qcow2,file.filename=/var/lib/libvirt/images/sparse-qcow2.img \
+driver=luks,file.filename=/var/lib/libvirt/images/OtherDemo.img,\
+key-secret=OtherDemo.img_encrypt0
"pool-dir", "vol-file",
"luks-convert", 0);
+ DO_TEST("pool-dir", "vol-luks-convert",
+ "pool-dir", "vol-file-qcow2",
+ "luks-convert-qcow2", 0);
+
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
--- /dev/null
+<volume>
+ <name>sparse-qcow2.img</name>
+ <source/>
+ <capacity unit="TiB">1</capacity>
+ <allocation unit="bytes">0</allocation>
+ <target>
+ <path>/var/lib/libvirt/images/sparse-qcow2.img</path>
+ <format type="qcow2"/>
+ <permissions>
+ <mode>0</mode>
+ <owner>0744</owner>
+ <group>0</group>
+ <label>virt_image_t</label>
+ </permissions>
+ <timestamps>
+ <atime>1341933637.273190990</atime>
+ <mtime>1341930622.047245868</mtime>
+ <ctime>1341930622.047245868</ctime>
+ </timestamps>
+ </target>
+</volume>