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(-)
diff --git a/libvirt/tests/cfg/virsh_cpu_compare.cfg
b/libvirt/tests/cfg/virsh_cpu_compare.cfg
index 7fd9184..a7dd4bb 100644
--- a/libvirt/tests/cfg/virsh_cpu_compare.cfg
+++ b/libvirt/tests/cfg/virsh_cpu_compare.cfg
@@ -1,18 +1,12 @@
- virsh_cpu_compare:
type = virsh_cpu_compare
- vms = ""
- main_vm = ""
- kill_vm = "no"
- kill_unresponsive_vms = "no"
- encode_video_files = "no"
- skip_image_processing = "yes"
take_regular_screendumps = "no"
cpu_compare_ref = "file"
cpu_compare_extra = ""
cpu_compare_mode = ""
cpu_compare_file_name = "cpu.xml"
variants:
- - expected_test:
+ - normal_test:
status_error = "no"
- error_test:
status_error = "yes"
@@ -29,3 +23,16 @@
cpu_compare_extra = "--xyz"
- invalid_ref_option:
cpu_compare_ref = "xyz"
+ variants:
+ - host_cpu:
+ cpu_compare_target = "host"
+ vms = ""
+ main_vm = ""
+ kill_vm = "no"
+ kill_unresponsive_vms = "no"
+ encode_video_files = "no"
+ skip_image_processing = "yes"
+ - guest_cpu:
+ cpu_compare_target = "guest"
+ start_vm = "no"
+ kill_vm = "yes"
diff --git a/libvirt/tests/virsh_cpu_compare.py
b/libvirt/tests/virsh_cpu_compare.py
index d64448b..d7aec70 100644
--- a/libvirt/tests/virsh_cpu_compare.py
+++ b/libvirt/tests/virsh_cpu_compare.py
@@ -11,18 +11,22 @@ def run_virsh_cpu_compare(test, params, env):
Compare host CPU with a CPU described by an XML file.
1.Get all parameters from configuration.
2.Prepare temp file saves of CPU infomation.
- 3.Perform virsh net-compare operation.
+ 3.Perform virsh cpu-compare operation.
4.Confirm the result.
"""
- def get_cpu_xml(mode, tmp_file):
+ def get_cpu_xml(target, mode, tmp_file):
"""
Get CPU infomation and put it into a file.
+ @param: target: Test target, host or guest's cpu description.
@param: mode: Test mode, decides file's detail.
@param: tmp_file: File saves CPU infomation.
"""
cpu_xml_file = open(tmp_file, 'wb')
- domxml = virsh.capabilities()
+ 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.
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