On 04/10/2013 01:52 PM, liyang wrote:
On 2013-4-9 22:02, Cole Robinson wrote:
On 04/08/2013 09:01 PM, liyang wrote:
On 2013-4-8 23:17, Lucas Meneghel Rodrigues wrote:
On 08/04/13 06:48 AM, liyang wrote:
Signed-off-by: Li Yang<[email protected]>
---
libvirt/tests/cfg/virsh_cpu_compare.cfg | 21
++++++++++++++-------
libvirt/tests/virsh_cpu_compare.py | 18 ++++++++++++++----
2 files changed, 28 insertions(+), 11 deletions(-)
+ if target == "host":
+ domxml = virsh.capabilities()
+ else:
+ domxml = virsh.dumpxml(vm_name)
Turns out dumpxml for the domain has no element 'cpu'
<domain type='kvm'>
<name>virt-tests-vm1</name>
<uuid>ae2a34e2-64f8-62c6-db92-449617c08361</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-1.4'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source
file='/home/lmr/Code/virt-test.git/shared/data/images/jeos-17-64.qcow2'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04'
function='0x0'/>
</disk>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01'
function='0x2'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:bf:c0:c1'/>
<source bridge='virbr0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03'
function='0x0'/>
</interface>
<serial type='file'>
<source path='/tmp/serial-20130408-121506-YySBxhLT'/>
<target port='0'/>
</serial>
<serial type='pty'>
<target port='1'/>
</serial>
<console type='file'>
<source path='/tmp/serial-20130408-121506-YySBxhLT'/>
<target type='serial' port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02'
function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05'
function='0x0'/>
</memballoon>
</devices>
</domain>
Therefore, all tests will fail. I am simply fixing the typo that went
unnoticed and NACKing all the rest of this patch.
There's a problem in the test.:-( Before starting test, please
confirm that
the tested guest's xml definition contains information about cpu.(virsh
dumpxml domain).
If not, you must modify Processor's configuration in virt-manager
manually(Select a model or
use "Copy host CPU configuration" button) .After that,the guest's xml
definition will contain
the cpu information.
Does any body have the way can make the action above be automated?
You can specify<cpu mode='host-model'/> in the XML and libvirt will
do that
step for you automatically. Needs at least libvirt 0.9.10
- Cole
Thanks...According to your suggestion, I just tried it, but it seems
doesn't take effect .
You need to check *'-cpu' option in qemu-kvm process* rather than guest
XML, for example:
# ps aux|grep qemu-kvm|grep -v grep
qemu 6641 17.3 0.3 1322980 25872 ? Sl 15:35 0:00
/usr/libexec/qemu-kvm -name foo-2 -S -M rhel6.2.0 *-cpu
Penryn,+osxsave,+xsave,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme,+kvmclock,-kvm_pv_eoi
*-enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -uuid
cae86633-904f-1c90-6bc4-9c579f70e699 -nodefconfig -nodefaults -chardev
socket,id=charmonitor,path=/var/lib/libvirt/qemu/foo-2.monitor,server,nowait
-mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
-no-shutdown -device
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -device
piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
file=/var/lib/libvirt/images/foo-2,if=none,id=drive-virtio-disk0,format=qcow2
-device
virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
-netdev tap,fd=26,id=hostnet0,vhost=on,vhostfd=27 -device
virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:18:15:00,bus=pci.0,addr=0x3
-chardev pty,id=charserial0 -device
isa-serial,chardev=charserial0,id=serial0 -chardev pty,id=charchannel0
-device
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0
-vnc 127.0.0.1:0 -k en-us -vga cirrus -device
AC97,id=sound0,bus=pci.0,addr=0x4 -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7
I think you need to redefine previous guest with cpu XML clock then use
virsh cpu-compare to check it.
In addition, you also need to add/delete/modify host_cpu.xml then check
it again virsh cpu-compare,
for example:
To copy host cpu XML as host_cpu.xml from virsh capabilities output
[root@localhost ajia]# cat host_cpu.xml
<cpu>
<arch>x86_64</arch>
<model>Penryn</model>
<vendor>Intel</vendor>
<topology sockets='1' cores='2' threads='1'/>
<feature name='osxsave'/>
<feature name='xsave'/>
<feature name='pdcm'/>
<feature name='xtpr'/>
<feature name='tm2'/>
<feature name='est'/>
<feature name='smx'/>
<feature name='vmx'/>
<feature name='ds_cpl'/>
<feature name='monitor'/>
<feature name='dtes64'/>
<feature name='pbe'/>
<feature name='tm'/>
<feature name='ht'/>
<feature name='ss'/>
<feature name='acpi'/>
<feature name='ds'/>
<feature name='vme'/>
</cpu>
1. Normally compare with host_cpu.xml
[root@localhost ajia]# virsh cpu-compare host_cpu.xml
CPU described in host_cpu.xml is identical to host CPU
[root@localhost ajia]# echo $?
0
2. Remove "<feature name='vme'/>" line from host_cpu.xml
[root@localhost ajia]# vim host_cpu.xml
[root@localhost ajia]# virsh cpu-compare host_cpu.xml
Host CPU is a superset of CPU described in host_cpu.xml
[root@localhost ajia]# echo $?
0
3. Append "<feature name='vme'/>" line into host_cpu.xml
[root@localhost ajia]# vim host_cpu.xml
[root@localhost ajia]# virsh cpu-compare host_cpu.xml
error: Failed to compare host CPU with host_cpu.xml
error: internal error CPU feature `vme' specified more than once
[root@localhost ajia]# echo $?
1
4. Append <feature name=''/> into original host_cpu.xml
[root@localhost ajia]# virsh cpu-compare host_cpu.xml
error: Failed to compare host CPU with host_cpu.xml
error: internal error Invalid CPU feature name
5.1 Invalid feature name
[root@localhost ajia]# virsh cpu-compare host_cpu.xml
error: host_cpu.xml:24: xmlParseEntityRef: no name
<feature name='!@#$%^&*'/>
----------------------------^
5.2
[root@localhost ajia]# virsh cpu-compare host_cpu.xml
error: Failed to compare host CPU with host_cpu.xml
error: internal error Unknown CPU feature xyz
[root@localhost ajia]# grep flags /proc/cpuinfo | head -1
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm
constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor
ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dts
tpr_shadow vnmi flexpriority
6. Append new feature name from /proc/cpuinfo such as <feature name='sse2'/>
[root@localhost ajia]# virsh cpu-compare host_cpu.xml
CPU described in host_cpu.xml is identical to host CPU
......
1.Use "virsh edit vm1" command to modify vm1's XML.
[root@63beta-kvm liyang]# virsh edit vm1
.............
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
.............
↓↓↓
↓↓↓
.............
<features>
<acpi/>
<apic/>
<pae/>
</features>
<cpu mode='host-model'/>
<clock offset='utc'/>
.............
2.After saving the XML, use "virsh dumpxml vm1" to check vm1's XML.
[root@63beta-kvm liyang]# virsh dumpxml vm1 > tmp.xml
[root@63beta-kvm liyang]# cat tmp.xml
.............
<features>
<acpi/>
<apic/>
<pae/>
</features>
<cpu mode='host-model'>
<model fallback='allow'/>
</cpu>
<clock offset='utc'/>
.............
3.Execute "virsh cpu-compare tmp.xml" command.
[root@63beta-kvm liyang]# virsh cpu-compare tmp.xml
error: Failed to compare host CPU with tmp.xml
error: Requested operation is not valid: no CPU model specified
Did I miss something in first step? > Cole
dom = parseString(domxml)
cpu_node = dom.getElementsByTagName('cpu')[0]
if mode == "modify":
@@ -45,13 +49,19 @@ def run_virsh_cpu_compare(test, params, env):
# Get all parameters.
ref = params["cpu_compare_ref"]
mode = params.get("cpu_compare_mode", "")
+ target = params.get("cpu_compare_target", "host")
status_error = params.get("status_error", "no")
extra = params.get("cpu_compare_extra", "")
file_name = params.get("cpu_compare_file_name", "cpu.xml")
tmp_file = os.path.join(test.tmpdir, file_name)
+ if target == "guest":
+ vm_name = params.get("main_vm")
+ vm = env.get_vm(vm_name)
+ if vm.is_alive():
+ vm.destroy()
# Prepare temp file.
- get_cpu_xml(mode, tmp_file)
+ get_cpu_xml(target, mode, tmp_file)
if ref == "file":
ref = tmp_file
--
1.7.1
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel