def create_snapshot(disk_path, snapshot_name):
"""Create a snapshot in a disk p_w_picpath :param disk_path: Path to disk p_w_picpath :param snapshot_name: Name of snapshot in disk p_w_picpath """ qemu_img_cmd = ('qemu-img', 'snapshot', '-c', snapshot_name, disk_path) # NOTE(vish): libvirt changes ownership of p_w_picpaths execute(*qemu_img_cmd, run_as_root=True)def delete_snapshot(disk_path, snapshot_name): """Create a snapshot in a disk p_w_picpath :param disk_path: Path to disk p_w_picpath :param snapshot_name: Name of snapshot in disk p_w_picpath """ qemu_img_cmd = ('qemu-img', 'snapshot', '-d', snapshot_name, disk_path) # NOTE(vish): libvirt changes ownership of p_w_picpaths execute(*qemu_img_cmd, run_as_root=True)def extract_snapshot(disk_path, source_fmt, snapshot_name, out_path, dest_fmt):
"""Extract a named snapshot from a disk p_w_picpath :param disk_path: Path to disk p_w_picpath :param snapshot_name: Name of snapshot in disk p_w_picpath :param out_path: Desired path of extracted snapshot """ # NOTE(markmc): ISO is just raw to qemu-img if dest_fmt == 'iso': dest_fmt = 'raw' qemu_img_cmd = ('qemu-img', 'convert', '-f', source_fmt, '-O', dest_fmt) # Conditionally enable compression of snapshots. if CONF.libvirt_snapshot_compression and dest_fmt == "qcow2": qemu_img_cmd += ('-c',) # When snapshot name is omitted we do a basic convert, which # is used by live snapshots. if snapshot_name is not None: qemu_img_cmd += ('-s', snapshot_name) qemu_img_cmd += (disk_path, out_path) execute(*qemu_img_cmd)waring: execute
subprocess.Popen('',shell=True)