'Swap existing disk with a new block device.'

def _swap_volume(self, guest, disk_path, conf, resize_to):

    dev = guest.get_block_device(disk_path)
    xml = guest.get_xml_desc(dump_inactive=True, dump_sensitive=True)
    try:
        dev.abort_job()
    except Exception:
        pass
    try:
        if guest.has_persistent_configuration():
            support_uefi = self._has_uefi_support()
            guest.delete_configuration(support_uefi)
        try:
            copy_dev = (conf.source_type == 'block')
            dev.rebase(conf.source_path, copy=True, reuse_ext=True, copy_dev=copy_dev)
            while (not dev.is_job_complete()):
                time.sleep(0.5)
            dev.abort_job(pivot=True)
        except Exception as exc:
            LOG.exception('Failure    rebasing    volume    %(new_path)s    on    %(old_path)s.', {'new_path': conf.source_path, 'old_path': disk_path})
            raise exception.VolumeRebaseFailed(reason=six.text_type(exc))
        if resize_to:
            dev.resize(((resize_to * units.Gi) / units.Ki))
    finally:
        self._host.write_instance_config(xml)
