[PATCH 1/2] Add support for creating qcow2 images
Brian C. Lane
bcl at redhat.com
Wed Mar 12 23:42:07 UTC 2014
---
src/pylorax/imgutils.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/pylorax/imgutils.py b/src/pylorax/imgutils.py
index 1a6c788..6d79b73 100644
--- a/src/pylorax/imgutils.py
+++ b/src/pylorax/imgutils.py
@@ -75,6 +75,19 @@ def mksparse(outfile, size):
fobj = open(outfile, "w")
os.ftruncate(fobj.fileno(), size)
+def mkqcow2(outfile, size, options=None):
+ '''use qemu-img to create a file of the given size.
+ options is a list of options passed to qemu-img
+
+ Default format is qcow2, override by passing "-f", fmt
+ in options.
+ '''
+ if not options:
+ options = []
+ if "-f" not in options:
+ options.extend(["-f", "qcow2"])
+ runcmd(["qemu-img", "create"] + options + [outfile, str(size)])
+
def loop_attach(outfile):
'''Attach a loop device to the given file. Return the loop device name.
Raises CalledProcessError if losetup fails.'''
--
1.8.5.3
More information about the anaconda-patches
mailing list