On 09/04/2013 11:05 PM, Laszlo Ersek wrote:
Before upstream qemu commit
commit 56c4bfb3f07f3107894c00281276aea4f5e8834d
Author: Laszlo Ersek <[email protected]>
Date: Tue Aug 6 12:37:11 2013 +0200
dump: rebase from host-private RAMBlock offsets to guest-physical
addresses
the dump-guest-memory QMP command used to write incorrect vmcores for
x86_64 guests with more than 3.5GB RAM. Add a testcase that creates a 4GB
guest, dumps its core, copies it into the guest, and analyzes it there
with the "crash" utility.
Overall I'm impressed with the quality of this test, Lazlo. It was well
written, documented, referenced, and it works like a charm. It also
appears to not contain python 2.4 incompatible statements. Kudos!
Thanks for taking the time to write it. In fact, there were so little
things that needed fixing that I opted for just fix them quickly and
push them to next.
Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=981582
Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=990118
Suggested-by: Ademar de Souza Reis Jr. <[email protected]>
Signed-off-by: Laszlo Ersek <[email protected]>
---
qemu/tests/cfg/guest_memory_dump_analysis.cfg | 7 +
qemu/tests/guest_memory_dump_analysis.py | 293 +++++++++++++++++++++++++
2 files changed, 300 insertions(+), 0 deletions(-)
create mode 100644 qemu/tests/cfg/guest_memory_dump_analysis.cfg
create mode 100644 qemu/tests/guest_memory_dump_analysis.py
diff --git a/qemu/tests/cfg/guest_memory_dump_analysis.cfg
b/qemu/tests/cfg/guest_memory_dump_analysis.cfg
new file mode 100644
index 0000000..c9572d0
--- /dev/null
+++ b/qemu/tests/cfg/guest_memory_dump_analysis.cfg
@@ -0,0 +1,7 @@
+- guest_memory_dump_analysis: install setup image_copy unattended_install.cdrom
+ only x86_64
+ only JeOS, Fedora, RHEL
+ type = guest_memory_dump_analysis
+ mem = 4096
+ monitors = qmp1
+ monitor_type = qmp
diff --git a/qemu/tests/guest_memory_dump_analysis.py
b/qemu/tests/guest_memory_dump_analysis.py
new file mode 100644
index 0000000..8f4bf53
--- /dev/null
+++ b/qemu/tests/guest_memory_dump_analysis.py
@@ -0,0 +1,293 @@
+"""
+Integrity test of a big guest vmcore, using the dump-guest-memory QMP
+command and the "crash" utility.
+
+@copyright: 2013 Red Hat, Inc.
+@author: Laszlo Ersek <[email protected]>
+
+Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=990118
+"""
+
+import logging
+from virttest.aexpect import ShellCmdError
+from autotest.client.shared import error
+import string
+import os
+import gzip
+import threading
+
+REQ_GUEST_MEM = 4096 # exact size of guest RAM required
+REQ_GUEST_ARCH = "x86_64" # the only supported guest arch
+REQ_GUEST_DF = 6144 # minimum guest disk space required
+ # after package installation
+LONG_TIMEOUT = 10*60 # timeout for long operations
+VMCORE_BASE = "vmcore" # basename of the host-side file the
+ # guest vmcore is written to, .gz
+ # suffix will be appended. No
+ # metacharacters or leading dashes
+ # please.
+VMCORE_FD_NAME = "vmcore_fd" # fd identifier used in the monitor
+CRASH_SCRIPT = "crash.cmd" # guest-side filename of the minimal
+ # crash script
+
+def run_guest_memory_dump_analysis(test, params, env):
+ """
+ Verify the vmcore written by dump-guest-memory for a big guests.
+
+ @param test: QEMU test object.
+ @param params: Dictionary with the test parameters.
+ @param env: Dictionary with test environment.
^ This past week we finally managed to migrate the docstring format to
the sphinx format, which in practice only means that the "@" signs have
to be exchanged with ":". Easy fix.
+ """
+ def check_requirements(vm, session):
+ """
+ Check guest RAM size and guest architecture.
+
+ @param vm: virtual machine.
+ @param session: login shell session.
+ @raise: error.TestError if the test is misconfigured.
+ """
+ mem_size = vm.get_memory_size()
+ if (mem_size != REQ_GUEST_MEM):
+ raise error.TestError("the guest must have %d MB RAM exactly "
+ "(current: %d MB)" % (REQ_GUEST_MEM,
+ mem_size))
+ arch = session.cmd("uname -m").rstrip()
+ if (arch != REQ_GUEST_ARCH):
+ raise error.TestError("this test only supports %s guests "
+ "(current: %s)" % (REQ_GUEST_ARCH, arch))
^ I feel like this is rather a TestNAError (that will show as SKIP in
the test runner) than a TestError, since the test simply does not apply
to this particular guest. This is very easy to fix though.
+ def install_kernel_debuginfo(vm, session, login_timeout):
+ """
+ In the guest, install a kernel debuginfo package that matches
+ the running kernel.
+
+ Debuginfo packages are available for the most recent kernels
+ only, so this step may need a kernel upgrade and a corresponding
+ VM reboot. Also, the "debuginfo-install" yum utility is not good
+ enough for this, because its exit status doesn't seem to reflect
+ any failure to find a matching debuginfo package. Only "yum
+ install" seems to do that, and only if an individual package is
+ requested.
+
+ @param vm: virtual machine. Can be None if the caller demands a
+ debuginfo package for the running kernel.
+ @param session: login shell session.
+ @param login_timeout: passed to vm.reboot() as timeout. Can be
+ None if vm is None.
+ @return: If the debuginfo package has been successfully
+ installed, None is returned. If no debuginfo package matching
+ the running guest kernel is available: if vm is None, an
+ exception is raised; otherwise, the guest kernel is upgraded,
+ and a new session is returned for the rebooted guest. In this
+ case the next call to this function should succeed, using the
+ new session and with vm=None.
+ @raise: error.TestError (guest uname command failed),
+ ShellCmdError (unexpected guest yum command failure), exceptions
+ from vm.reboot().
+ """
+ def install_matching_debuginfo(session):
+ try:
+ guest_kernel = session.cmd("uname -r").rstrip()
+ except ShellCmdError, details:
+ raise error.TestError("guest uname command failed: %s" %
+ details)
+ return session.cmd("yum -y install --enablerepo='*debuginfo' "
+ "kernel-debuginfo-%s" % guest_kernel,
+ timeout=LONG_TIMEOUT)
+
+ try:
+ output = install_matching_debuginfo(session)
+ logging.debug("%s", output)
+ new_sess = None
+ except ShellCmdError, details:
+ if (vm is None):
+ raise
+ logging.info("failed to install matching debuginfo, "
+ "upgrading kernel")
+ logging.debug("shell error was: %s", details)
+ output = session.cmd("yum -y upgrade kernel",
+ timeout=LONG_TIMEOUT)
+ logging.debug("%s", output)
+ new_sess = vm.reboot(session, timeout=login_timeout)
+ return new_sess
+
+ def install_crash(session):
+ """
+ Install the "crash" utility in the guest.
+
+ @param session: login shell session.
+ @raise: exceptions from session.cmd().
+ """
+ output = session.cmd("yum -y install crash")
+ logging.debug("%s", output)
+
+ def check_disk_space(session):
+ """
+ Check free disk space in the guest before uploading,
+ uncompressing and analyzing the vmcore.
+
+ @param session: login shell session.
+ @raise: exceptions from session.cmd(); error.TestError if free
+ space is insufficient.
+ """
+ output = session.cmd("rm -f -v %s %s.gz" % (VMCORE_BASE, VMCORE_BASE))
+ logging.debug("%s", output)
+ output = session.cmd("yum clean all")
+ logging.debug("%s", output)
+ output = session.cmd("LC_ALL=C df --portability --block-size=1M .")
^ I like that you set up the locale to avoid surprises here.
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel