Add a backingFile for create
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/7c14cafb Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/7c14cafb Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/7c14cafb Branch: refs/heads/qemu-img Commit: 7c14cafb03ee09622935087297ee8c2d0d254b15 Parents: 500bba8 Author: Wido den Hollander <[email protected]> Authored: Thu Feb 14 21:33:36 2013 +0100 Committer: Wido den Hollander <[email protected]> Committed: Thu Feb 14 21:33:36 2013 +0100 ---------------------------------------------------------------------- .../org/apache/cloudstack/utils/qemu/QemuImg.java | 27 ++++++++++++-- 1 files changed, 23 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7c14cafb/utils/src/org/apache/cloudstack/utils/qemu/QemuImg.java ---------------------------------------------------------------------- diff --git a/utils/src/org/apache/cloudstack/utils/qemu/QemuImg.java b/utils/src/org/apache/cloudstack/utils/qemu/QemuImg.java index daa62ab..d32507e 100644 --- a/utils/src/org/apache/cloudstack/utils/qemu/QemuImg.java +++ b/utils/src/org/apache/cloudstack/utils/qemu/QemuImg.java @@ -58,17 +58,36 @@ public class QemuImg { } /* Create a new disk image */ - public void create(QemuImgFile file, List<Map<String, String>> options) { + public void create(QemuImgFile file, QemuImgFile backingFile, List<Map<String, String>> options) { Script s = new Script(_qemuImgPath); s.add("create"); s.add("-f"); - s.add(file.getFormat().toString()); + + /* + -b for a backing file does not show up in the docs, but it works. + Shouldn't this be -o backing_file=filename instead? + */ + if (backingFile != null) { + s.add(backingFile.getFormat().toString()); + s.add("-b"); + s.add(backingFile.getFileName()); + } else { + s.add(file.getFormat().toString()); + } + s.add(file.getFileName()); - s.add(Long.toString(file.getSize())); + + if (backingFile == null) { + s.add(Long.toString(file.getSize())); + } } public void create(QemuImgFile file) { - this.create(file, null); + this.create(file, null, null); + } + + public void create(QemuImgFile file, QemuImgFile backingFile) { + this.create(file, backingFile, null); } /* Convert the disk image filename or a snapshot snapshot_name to disk image output_filename using format output_fmt. */
