2017-07-18 63 views
1

我在使用qemu-kvm运行并由libvirt管理(主要由virt-manager创建并运行)的虚拟机(guest虚拟机窗口7,x86_64)中遇到了一些问题。问题是,我也不能运行无法获得libvirt域的所有内存统计信息

virsh -c qemu:///system dommemstat win7 

或致电

virDomainMemoryStats(...) 

C++代码(这是,据我了解,或多或少同样的事情)得到充分的内存统计。我也从libvirt aplication dev guide测试libvirt第35个例子。这真的让我担心,因为现在我在项目中工作,目的是为vm自动设置最佳内存大小,因此我需要在我的代码中使用它们。

我从的virsh得到的唯一输出是

actual 4194304 
last_update 1500404513 
rss 4161676 

搜索,我发现,这些都是统计数据,其libvirt的可以获取未向司机膨胀的网络后。不过,我已经在Windows中安装了VirtIO气球驱动程序,并且系统声称它正在运行。我真的不知道,如何确定qemu是否意识到这一点(为您的想法打开)。

另外我发现我需要在系统xml中设置统计周期,我已经做了哪些,哪些没有给出。我还发现,QEMU使用一些“库姆,获得”脚本实际测量统计,但我不能从

virsh # qemu-monitor-command 1 --hmp "qom-get" 

(输出该命令是未知的)使用它,我不能看到它在我的道路。另外pacman -Fo qom-getpkgfile qom-get什么也不给。 我的主机系统是Arch Linux。 win7.xml的内容是

<domain type='kvm'> 
    <name>win7</name> 
    <uuid>438145c1-a2df-4c86-96d6-2bf7b379d70b</uuid> 
    <memory unit='KiB'>4194304</memory> 
    <currentMemory unit='KiB'>4194304</currentMemory> 
    <vcpu placement='static' current='2'>4</vcpu> 
    <os> 
    <type arch='x86_64' machine='pc-i440fx-2.9'>hvm</type> 
    <boot dev='hd'/> 
    </os> 
    <features> 
    <acpi/> 
    <apic/> 
    <hyperv> 
     <relaxed state='on'/> 
     <vapic state='on'/> 
     <spinlocks state='on' retries='8191'/> 
    </hyperv> 
    <vmport state='off'/> 
    </features> 
    <cpu mode='custom' match='exact' check='partial'> 
    <model fallback='allow'>Broadwell-noTSX</model> 
    </cpu> 
    <clock offset='localtime'> 
    <timer name='rtc' tickpolicy='catchup'/> 
    <timer name='pit' tickpolicy='delay'/> 
    <timer name='hpet' present='no'/> 
    <timer name='hypervclock' present='yes'/> 
    </clock> 
    <on_poweroff>destroy</on_poweroff> 
    <on_reboot>restart</on_reboot> 
    <on_crash>destroy</on_crash> 
    <pm> 
    <suspend-to-mem enabled='no'/> 
    <suspend-to-disk enabled='no'/> 
    </pm> 
    <devices> 
    <emulator>/usr/sbin/qemu-system-x86_64</emulator> 
    <disk type='file' device='disk'> 
     <driver name='qemu' type='qcow2'/> 
     <source file='/var/lib/libvirt/images/win7.qcow2'/> 
     <target dev='hda' bus='ide'/> 
     <address type='drive' controller='0' bus='0' target='0' unit='0'/> 
    </disk> 
    <disk type='file' device='cdrom'> 
     <driver name='qemu' type='raw'/> 
     <target dev='hdb' bus='ide'/> 
     <readonly/> 
     <address type='drive' controller='0' bus='0' target='0' unit='1'/> 
    </disk> 
    <disk type='file' device='cdrom'> 
     <driver name='qemu' type='raw'/> 
     <source file='/usr/share/virtio/virtio-win.iso'/> 
     <target dev='hdc' bus='ide'/> 
     <readonly/> 
     <address type='drive' controller='0' bus='1' target='0' unit='0'/> 
    </disk> 
    <controller type='usb' index='0' model='ich9-ehci1'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/> 
    </controller> 
    <controller type='usb' index='0' model='ich9-uhci1'> 
     <master startport='0'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/> 
    </controller> 
    <controller type='usb' index='0' model='ich9-uhci2'> 
     <master startport='2'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/> 
    </controller> 
    <controller type='usb' index='0' model='ich9-uhci3'> 
     <master startport='4'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/> 
    </controller> 
    <controller type='pci' index='0' model='pci-root'/> 
    <controller type='ide' index='0'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> 
    </controller> 
    <controller type='virtio-serial' index='0'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> 
    </controller> 
    <interface type='network'> 
     <mac address='52:54:00:9d:4e:85'/> 
     <source network='default'/> 
     <model type='rtl8139'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> 
    </interface> 
    <serial type='pty'> 
     <target port='0'/> 
    </serial> 
    <console type='pty'> 
     <target type='serial' port='0'/> 
    </console> 
    <channel type='spicevmc'> 
     <target type='virtio' name='com.redhat.spice.0'/> 
     <address type='virtio-serial' controller='0' bus='0' port='1'/> 
    </channel> 
    <input type='tablet' bus='usb'> 
     <address type='usb' bus='0' port='1'/> 
    </input> 
    <input type='mouse' bus='ps2'/> 
    <input type='keyboard' bus='ps2'/> 
    <graphics type='spice' autoport='yes'> 
     <listen type='address'/> 
     <image compression='off'/> 
    </graphics> 
    <sound model='ich6'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> 
    </sound> 
    <video> 
     <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> 
    </video> 
    <redirdev bus='usb' type='spicevmc'> 
     <address type='usb' bus='0' port='2'/> 
    </redirdev> 
    <redirdev bus='usb' type='spicevmc'> 
     <address type='usb' bus='0' port='3'/> 
    </redirdev> 
    <memballoon model='virtio'> 
     <stats period='10'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> 
    </memballoon> 
    </devices> 
</domain> 

我绝对错过了一些东西,但我什么也看不见。任何人都可以给我任何有用的链接或指南吗?我真的很感激。

这是question on Arch Linux newbie forum的重复。如果有人会给出适当的答案,我会与其他网站分享。

============================================== ==

UPD。气球的工作:我可以做这样的事情

virsh # qemu-monitor-command win7 --hmp "info balloon" 
balloon: actual=4096 
virsh # qemu-monitor-command win7 --hmp "balloon 2048" 
virsh # qemu-monitor-command win7 --hmp "info balloon" 
balloon: actual=2048 

但库姆,获得不会做:

virsh # qemu-monitor-command windows7 '{ "execute": "qom-get", "arguments": { "path": "/machine/peripheral/balloon0", "property": "guest-stats" } }' 
{"return":{"stats":{"stat-swap-out":-1,"stat-available-memory":-1,"stat-free-memory":-1,"stat-minor-faults":-1,"stat-major-faults":-1,"stat-total-memory":-1,"stat-swap-in":-1},"last-update":1500639136},"id":"libvirt-396"} 

帮助将非常感激。

回答

0

问题在于Balloon服务安装不正确。如果您遇到同样的问题,可能的解决方案是打开命令行,使用VirtIO驱动程序转到CD-ROM,根据您的系统和体系结构转到Balloon目录并更深入。当你在AMD64()目录,键入

blnsrv.exe -i 

和服务应自行安装。之后,问题将会消失(至少,这对我有用)。

相关问题