'Rebase a device tied to a guest using qemu-img.
:param guest:the Guest which owns the device being rebased
:type guest: nova.virt.libvirt.guest.Guest
:param device: the guest block device to rebase
:type device: nova.virt.libvirt.guest.BlockDevice
:param active_disk_object: the guest block device to rebase
:type active_disk_object: nova.virt.libvirt.config.                                    LibvirtConfigGuestDisk
:param rebase_base: the new parent in the backing chain
:type rebase_base: None or string'

@staticmethod
def _rebase_with_qemu_img(guest, device, active_disk_object, rebase_base):

    active_protocol = active_disk_object.source_protocol
    if (active_protocol is not None):
        msg = (_('Something    went    wrong    when    deleting    a    volume    snapshot:    rebasing    a    %(protocol)s    network    disk    using    qemu-img    has    not    been    fully    tested') % {'protocol': active_protocol})
        LOG.error(msg)
        raise exception.InternalError(msg)
    if (rebase_base is None):
        backing_file = ''
        qemu_img_extra_arg = []
    else:
        backing_file = rebase_base
        b_file_fmt = images.qemu_img_info(backing_file).file_format
        qemu_img_extra_arg = ['-F', b_file_fmt]
    qemu_img_extra_arg.append(active_disk_object.source_path)
    utils.execute('qemu-img', 'rebase', '-b', backing_file, *qemu_img_extra_arg)
