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 .
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
--
Regards,
--------------------------------------------------
Li Yang
TEL:+86+25-86630566-8529
EMail:[email protected]
--------------------------------------------------
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel