'Set cache mode on LibvirtConfigGuestDisk object.'

def _set_cache_mode(self, conf):

    try:
        source_type = conf.source_type
        driver_cache = conf.driver_cache
    except AttributeError:
        return
    cache_mode = self.disk_cachemodes.get(source_type, driver_cache)
    conf.driver_cache = cache_mode
