* Options for the create. Takes a Map<String, String> with key value
* pairs which are passed on to qemu-img without validation.
* @return void
*/
public void create(QemuImgFile file, QemuImgFile backingFile, Map<String, String> options) throws QemuImgException {
Script s = new Script(_qemuImgPath);
s.add("create");
if (options != null && !options.isEmpty()) {
s.add("-o");
String optionsStr = "";
for (Map.Entry<String, String> option : options.entrySet()) {
optionsStr += option.getKey() + "=" + option.getValue() + ",";
}
s.add(optionsStr);
}
/*
-b for a backing file does not show up in the docs, but it works.
Shouldn't this be -o backing_file=filename instead?
*/
s.add("-f");
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());
if (backingFile == null) {
s.add(Long.toString(file.getSize()));
}
String result = s.execute();
if (result != null) {
throw new QemuImgException(result);
}
}