Federico Simoncelli has posted comments on this change.
Change subject: lib: add create function to the qemuImg module ......................................................................
Patch Set 1:
(1 comment)
.................................................... File lib/vdsm/qemuImg.py Line 87: Line 88: return info Line 89: Line 90: Line 91: def create(image, size=None, format=None, backing=None, backingFormat=None): On the contrary, I don't think it's awkward, it's just how qemu-img works. The mandatory arguments are image and size:
qemuImg.create("myimage.img", 1024**3)
The format by default is "raw", so you can omit it, but if you want you can still specify it easily:
qemuImg.create("myimage.img", 1024**3, qemuImg.FORMAT.QCOW2)
Now you might say that you prefer always being explicit about the format, that's a good practice, agreed, but it has nothing to do with writing a wrapper where the goal is to expose the exact behavior of the command.
The only reason for size being optional is that it can be automatically detected when a backing file is specified:
qemuImg.create("myimage.img", ..., backing="mybacking.img")
Now, the reason for not checking the size/backing presence is that we don't want to re-write checks, we'll rely on qemu-img failing (triggering the QImgError exception). Line 92: cmd = [_qemuimg.cmd, "create"] Line 93: Line 94: if format: Line 95: cmd.extend(("-f", format))