openstack kvm WINDOWS虚拟机VDAGENT导致CPU占用100%问题的解决

时间:2021-12-07 00:25:28

虚拟机使用SPICE连接,虚拟机里安装 了vdagent,是从spice官网下载的
使用openstack运行虚拟机后发现虚拟机里CPU占用率100%,查找的话发现是vdagent服务导致的。
查看vdagent日志
openstack kvm WINDOWS虚拟机VDAGENT导致CPU占用100%问题的解决
应该是vio_serial的问题
用virsh dumpxml去看和正常的区别,会发现有channel设备类型是pty,应该是spicevmc才对
所以就暴力的修改源代码来解决吧,虚拟机没有声音,顺便增加了声音设备
修改如下:

    diff -aruN nova-2015.1.0.org/nova/virt/libvirt/config.py nova-2015.1.0/nova/virt/libvirt/config.py
--- nova-2015.1.0.org/nova/virt/libvirt/config.py 2015-10-29 15:01:39.819057624 +0800
+++ nova-2015.1.0/nova/virt/libvirt/config.py 2015-10-29 15:03:36.093143274 +0800
@@ -1329,7 +1329,14 @@

return dev

-
+class LibvirtConfigGuestSound(LibvirtConfigGuestDevice): #wz
+ def __init__(self, **kwargs):
+ super(LibvirtConfigGuestSound, self).__init__(root_name="sound",**kwargs)
+ self.type = "ich6"
+ def format_dom(self):
+ dev = super(LibvirtConfigGuestSound, self).format_dom()
+ dev.set("model", self.type)
+ return dev
class LibvirtConfigMemoryBalloon(LibvirtConfigGuestDevice):
def __init__(self, **kwargs):
super(LibvirtConfigMemoryBalloon, self).__init__(
@@ -1426,13 +1433,14 @@
self.slot = sub.get('slot')
self.function = sub.get('function')

+#class LibvirtConfigGuestCharBase(LibvirtConfigGuestDevice):

class LibvirtConfigGuestCharBase(LibvirtConfigGuestDevice):

def __init__(self, **kwargs):
super(LibvirtConfigGuestCharBase, self).__init__(**kwargs)

- self.type = "pty"
+ self.type = "spicevmc"
self.source_path = None
self.listen_port = None
self.listen_host = None
diff -aruN nova-2015.1.0.org/nova/virt/libvirt/driver.py nova-2015.1.0/nova/virt/libvirt/driver.py
--- nova-2015.1.0.org/nova/virt/libvirt/driver.py 2015-10-29 15:01:39.819057624 +0800
+++ nova-2015.1.0/nova/virt/libvirt/driver.py 2015-10-29 15:03:25.752317678 +0800
@@ -3889,6 +3889,9 @@
if max_vram and video_ram:
video.vram = video_ram * units.Mi / units.Ki
guest.add_device(video)
+ sound = vconfig.LibvirtConfigGuestSound()
+ guest.add_device(sound)
+

def _add_qga_device(self, guest, instance):
qga = vconfig.LibvirtConfigGuestChannel()

参考:
http://dbaxps.blogspot.com/2015/10/switching-to-dashboard-spice-console-in.html
http://textuploader.com/aij31