如何在Python中使用Libvirt录制VM屏幕?
我正在使用Python进行Testautomation,在那里我正在与KVM服务器上的各种主机一起工作。为了实现这一目标,我正在使用libvirt和Python3。现在,我想记录测试以查看以后发生的事情。
我尝试了类似的事情
import libvirt
conn = libvirt.open("...")
vm = conn.lookupByName('win10')
stream = conn.newStream()
while True:
img = vm.screenshot(stream, 0)
....
,但这只会呈现约9张图像,因此非常懒惰。有没有办法更快 /更快地完成此操作?
虚拟机设置为使用Spice Display服务器。
I'm doing testautomation with python where I'm working with various hosts on a kvm server. To achieve this, I'm using libvirt and python3. Now I want to record the tests to see whats going on afterwards.
I tried something like
import libvirt
conn = libvirt.open("...")
vm = conn.lookupByName('win10')
stream = conn.newStream()
while True:
img = vm.screenshot(stream, 0)
....
but this only renders about 9 images per second, thus its very laggy. Is there a way get this done faster / more performant?
The virtual machines are set to use the spice display server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设VM配置了VNC服务器,则打开与VNC的连接并以这种方式接收屏幕更新会更有效,从服务器推开。如果已经存在某个地方可以连接到VNC并记录到视频流的地方,我不会感到惊讶。如果不是,则“ GTK-VNC”库通过Python导出其API,可用于构建此类工具。
Assuming the VM has a VNC server configured, it would be far more effective to open a connection to VNC and receive the screen updates on the fly that way, pushed from the server. I wouldn't be surprised if there's already python code that exists somewhere to connect to VNC and record to a video stream. If not, the 'gtk-vnc' library exports its API via python and could be used to build such a tool.