openstack 声卡重定向代码修改
声卡重定向代码修改,如许使用Remote viewer软件就可以播放假造机的声音的
/nova/virt/libvirt/config.py 文件末尾添加
- class LibvirtConfigGuestSound(LibvirtConfigObject):
- def __init__(self, **kwargs):
- super(LibvirtConfigGuestSound,
- self).__init__(root_name='sound')
- self.model = 'ich6'
- def format_dom(self):
- meta = self._new_node('sound')
- meta.set('model', str(self.model))
- return meta
复制代码 nova/virt/libvirt/driver.py 把_guest_add_spice_sound方法添加上
- @staticmethod
- def _guest_add_memory_balloon(guest):
- # Memory balloon device only support 'qemu/kvm' hypervisor
- if (
- CONF.libvirt.virt_type in ('qemu', 'kvm') and
- CONF.libvirt.mem_stats_period_seconds > 0
- ):
- balloon = vconfig.LibvirtConfigMemoryBalloon()
- balloon.model = 'virtio'
- balloon.period = CONF.libvirt.mem_stats_period_seconds
- guest.add_device(balloon)
- #add 添加这个方法
- @staticmethod
- def _guest_add_spice_sound(guest):
- if (
- CONF.spice.enabled and
- CONF.libvirt.virt_type != 'lxc'
- ):
- sounddev = vconfig.LibvirtConfigGuestSound()
- guest.add_device(sounddev)
- #end
- @staticmethod
- def _guest_add_watchdog_action(guest, flavor, image_meta):
- # image meta takes precedence over flavor extra specs; disable the
- # watchdog action by default
- watchdog_action = (flavor.extra_specs.get('hw:watchdog_action') or
- 'disabled')
- watchdog_action = image_meta.properties.get('hw_watchdog_action',
- watchdog_action)
- # NB(sross): currently only actually supported by KVM/QEmu
- if watchdog_action != 'disabled':
- if watchdog_action in fields.WatchdogAction.ALL:
- bark = vconfig.LibvirtConfigGuestWatchdog()
- bark.action = watchdog_action
- guest.add_device(bark)
- else:
- raise exception.InvalidWatchdogAction(action=watchdog_action)
复制代码 nova/virt/libvirt/driver.py 在 self._guest_add_spice_channel(guest)下边添加 self._guest_add_spice_sound(guest)这个方法即可
- self._guest_add_spice_channel(guest)
- self._guest_add_spice_sound(guest)
复制代码 参考github
kerbside-patches/nova/patch020-add-sound-device.patch at develop · shakenfist/kerbside-patches (github.com)
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |