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)
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-8526
EMail:[email protected]
--------------------------------------------------
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel