def qemuRebase(src, srcFormat, backingFile, backingFormat, unsafe, stop, rollback): """ Rebase the 'src' volume on top of the new 'backingFile' with new 'backingFormat' """ backingFormat = fmt2str(backingFormat) srcFormat = fmt2str(srcFormat) cwd = os.path.dirname(src) log.debug('(qemuRebase): REBASE %s (fmt=%s) on top of %s (%s) START' % (src, srcFormat, backingFile, backingFormat)) cmd = [constants.EXT_QEMUIMG, "rebase", "-t", "none", "-f", srcFormat, "-b", backingFile, "-F", backingFormat] if unsafe: cmd += ["-u"] cmd += [src] recoveryCallback = None if rollback: recoveryCallback = baseAsyncTasksRollback (rc, out, err) = misc.watchCmd(cmd, stop=stop, cwd=cwd, recoveryCallback=recoveryCallback, ioclass=utils.IOCLASS.IDLE, nice=utils.NICENESS.HIGH) log.debug('(qemuRebase): REBASE %s DONE' % (src)) return (rc, out, err)
def qemuConvert(src, dst, src_fmt, dst_fmt, stop, size, dstvolType): """ Convert the 'src' image (or chain of images) into a new single 'dst' """ src_fmt = fmt2str(src_fmt) dst_fmt = fmt2str(dst_fmt) log.debug('(qemuConvert): COPY %s (%s) to %s (%s) START' % (src, src_fmt, dst, dst_fmt)) if (src_fmt == "raw" and dst_fmt == "raw" and dstvolType == PREALLOCATED_VOL): (rc, out, err) = misc.ddWatchCopy( src=src, dst=dst, stop=stop, size=size, recoveryCallback=baseAsyncTasksRollback) else: cmd = [constants.EXT_QEMUIMG, "convert", "-t", "none", "-f", src_fmt, src, "-O", dst_fmt, dst] (rc, out, err) = misc.watchCmd(cmd, stop=stop, recoveryCallback=baseAsyncTasksRollback, ioclass=utils.IOCLASS.IDLE, nice=utils.NICENESS.HIGH) log.debug('(qemuConvert): COPY %s to %s DONE' % (src, dst)) return (rc, out, err)