def _live_snapshot(self, domain, disk_path, out_path, image_format):
    'Snapshot an instance without downtime.'
    xml = domain.XMLDesc((libvirt.VIR_DOMAIN_XML_INACTIVE | libvirt.VIR_DOMAIN_XML_SECURE))
    try:
        domain.blockJobAbort(disk_path, 0)
    except Exception:
        pass
    src_disk_size = libvirt_utils.get_disk_size(disk_path)
    src_back_path = libvirt_utils.get_disk_backing_file(disk_path, basename=False)
    disk_delta = (out_path + '.delta')
    libvirt_utils.create_cow_image(src_back_path, disk_delta, src_disk_size)
    try:
        if domain.isPersistent():
            domain.undefine()
        domain.blockRebase(disk_path, disk_delta, 0, ((libvirt.VIR_DOMAIN_BLOCK_REBASE_COPY | libvirt.VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT) | libvirt.VIR_DOMAIN_BLOCK_REBASE_SHALLOW))
        while self._wait_for_block_job(domain, disk_path):
            time.sleep(0.5)
        domain.blockJobAbort(disk_path, 0)
        libvirt_utils.chown(disk_delta, os.getuid())
    finally:
        self._conn.defineXML(xml)
    libvirt_utils.extract_snapshot(disk_delta, 'qcow2', out_path, image_format)
Snapshot an instance without downtime.
def _live_snapshot(self, domain, disk_path, out_path, image_format):
    
    xml = domain.XMLDesc((libvirt.VIR_DOMAIN_XML_INACTIVE | libvirt.VIR_DOMAIN_XML_SECURE))
    try:
        domain.blockJobAbort(disk_path, 0)
    except Exception:
        pass
    src_disk_size = libvirt_utils.get_disk_size(disk_path)
    src_back_path = libvirt_utils.get_disk_backing_file(disk_path, basename=False)
    disk_delta = (out_path + '.delta')
    libvirt_utils.create_cow_image(src_back_path, disk_delta, src_disk_size)
    try:
        if domain.isPersistent():
            domain.undefine()
        domain.blockRebase(disk_path, disk_delta, 0, ((libvirt.VIR_DOMAIN_BLOCK_REBASE_COPY | libvirt.VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT) | libvirt.VIR_DOMAIN_BLOCK_REBASE_SHALLOW))
        while self._wait_for_block_job(domain, disk_path):
            time.sleep(0.5)
        domain.blockJobAbort(disk_path, 0)
        libvirt_utils.chown(disk_delta, os.getuid())
    finally:
        self._conn.defineXML(xml)
    libvirt_utils.extract_snapshot(disk_delta, 'qcow2', out_path, image_format)