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(-)

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.
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?

          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
No. 6 Wenzhu Road, Nanjing, 210012, China
TEL:+86+25-86630566-8526
FUJITSU INTERNAL:7998-8526
FAX:+86+25-83317685
EMail:[email protected]
--------------------------------------------------
This communication is for use by the intended recipient(s) only and may contain 
information that is privileged, confidential and exempt from disclosure under 
applicable law. If you are not an intended recipient of this communication, you 
are hereby notified that any dissemination, distribution or copying hereof is 
strictly prohibited.  If you have received this communication in error, please 
notify me by reply e-mail, permanently delete this communication from your 
system, and destroy any hard copies you may have printed



_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel

Reply via email to