Federico Simoncelli has uploaded a new change for review. Change subject: volume: use qemuimg and remove custom createVolume ......................................................................
volume: use qemuimg and remove custom createVolume Change-Id: I960276ec6bd654be4f427425c95603189c0d6a99 Signed-off-by: Federico Simoncelli <[email protected]> --- M lib/vdsm/qemuimg.py M vdsm/storage/volume.py 2 files changed, 12 insertions(+), 66 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/26871/1 diff --git a/lib/vdsm/qemuimg.py b/lib/vdsm/qemuimg.py index f0f2b35..4d3824c 100644 --- a/lib/vdsm/qemuimg.py +++ b/lib/vdsm/qemuimg.py @@ -96,13 +96,13 @@ if format: cmd.extend(("-f", format)) + if backingFormat: + cmd.extend(("-F", backingFormat)) + if backing: if not os.path.isabs(backing): cwdPath = os.path.dirname(image) cmd.extend(("-b", backing)) - - if backingFormat: - cmd.extend(("-F", backingFormat)) cmd.append(image) diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py index 7f1eaf1..4969f1c 100644 --- a/vdsm/storage/volume.py +++ b/vdsm/storage/volume.py @@ -91,7 +91,10 @@ log = logging.getLogger('Storage.Volume') -FMT2STR = {COW_FORMAT: 'qcow2', RAW_FORMAT: 'raw'} +FMT2STR = { + COW_FORMAT: qemuimg.FORMAT.QCOW2, + RAW_FORMAT: qemuimg.FORMAT.RAW, +} # At the moment this is static and it has been introduced to group all the # previous implicit references to the block size in FileVolume. In the future @@ -268,14 +271,14 @@ dst_path = os.path.join(dst_image_dir, dst_volUUID) self.log.debug('cloning volume %s to %s', self.volumePath, dst_path) - size = int(self.getMetaParam(SIZE)) parent = self.getVolumePath() parent_format = fmt2str(self.getFormat()) # We should use parent's relative path instead of full path - parent = os.path.join(os.path.basename(os.path.dirname(parent)), - os.path.basename(parent)) - createVolume(parent, parent_format, dst_path, - size, volFormat, preallocate) + parent = os.path.join( + '..', os.path.basename(os.path.dirname(parent)), + os.path.basename(parent)) + qemuimg.create(dst_path, format=fmt2str(volFormat), + backing=parent, backingFormat=parent_format) self.teardown(self.sdUUID, self.volUUID) except Exception as e: self.log.exception('cannot clone volume %s to %s', @@ -980,63 +983,6 @@ by reducing the lv to minimal size required """ pass - - -def createVolume(parent, parent_format, volume, size, format, prealloc): - """ - --- Create new volume. - 'parent' - backing volume name - 'parent_format' - backing volume format - 'volume' - new volume name - 'format' - volume format [ 'COW' or 'RAW' ] - 'size' - in sectors, always multiple of the grain size (64KB) - 'preallocate' - flag PREALLOCATED_VOL/SPARSE_VOL, - defines actual storage device type. - PREALLOCATED_VOL = preallocated storage using - non-sparse format (+ DD for file, use raw LV for SAN) - - # SAN - - Prealloc/RAW = Normal LV (if snapshot => create copy of LV) - Sparse/RAW = if snapshot create LVM snapshot - (in the future, use storage backend thin provisioning), - else create Normal LV <== Not supported - Prealloc/COW = build qcow2 image within a preallocated space - - used only for COPY - Sparse/COW = QCOW2 over LV - - # File - - Prealloc/RAW = Normal file + DD (implicit pre-zero) - Sparse/RAW = Normal file (touch) - Prealloc/COW = QCOW2 + DD <== Not supported - Sparse/COW = QCOW2 - - """ - # TODO: accept size only in bytes and convert before call to qemu-img - cmd = [constants.EXT_QEMUIMG, "create", "-f", fmt2str(format)] - cwd = None - if format == COW_FORMAT and parent: - # cmd += ["-b", parent, volume] - # cwd = os.path.split(os.path.split(volume)[0])[0] - - # Temporary fix for qemu-img creation problem - cmd += ["-F", parent_format, "-b", os.path.join("..", parent), volume] - cwd = os.path.split(volume)[0] - else: - size = int(size) - if size < 1: - raise se.createVolumeSizeError() - - # qemu-img expects size to be in kilobytes by default, - # can also accept size in M or G with appropriate suffix - # +1 is so that odd numbers will round upwards. - cmd += [volume, "%uK" % ((size + 1) / 2)] - - (rc, out, err) = misc.execCmd(cmd, cwd=cwd, deathSignal=signal.SIGKILL) - if rc: - raise se.VolumeCreationError(out) - return True def baseAsyncTasksRollback(proc): -- To view, visit http://gerrit.ovirt.org/26871 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I960276ec6bd654be4f427425c95603189c0d6a99 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
