From: Michael Goldish <mgoldish@redhat.com>
To: Lucas Meneghel Rodrigues <lmr@redhat.com>
Cc: autotest@test.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH 1/3] KVM test: Introduce check_image postprocess directive
Date: Wed, 19 Jan 2011 07:56:36 +0200 [thread overview]
Message-ID: <4D367D14.6030202@redhat.com> (raw)
In-Reply-To: <1295394353-11688-2-git-send-email-lmr@redhat.com>
On 01/19/2011 01:45 AM, Lucas Meneghel Rodrigues wrote:
> With check_image_foo = yes, KVM autotest will use
> qemu-img to perform checks on the qcow2 image.
>
> This new functionality intends to replace the
> script check_image.py. The plan is to supersede most
> of the pre/post scripts in place throughout KVM
> autotest.
>
> Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
> ---
> client/tests/kvm/kvm_preprocessing.py | 3 +-
> client/tests/kvm/kvm_vm.py | 62 ++++++++++++++++++++++++++++++++
> client/tests/kvm/tests_base.cfg.sample | 7 ++--
> 3 files changed, 67 insertions(+), 5 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
> index 56acf0c..4a6e0f8 100644
> --- a/client/tests/kvm/kvm_preprocessing.py
> +++ b/client/tests/kvm/kvm_preprocessing.py
> @@ -93,11 +93,12 @@ def preprocess_vm(test, params, env, name):
> def postprocess_image(test, params):
> """
> Postprocess a single QEMU image according to the instructions in params.
> - Currently this function just removes an image if requested.
>
> @param test: An Autotest test object.
> @param params: A dict containing image postprocessing parameters.
> """
> + if params.get("check_image") == "yes":
> + kvm_vm.check_image(params, test.bindir)
> if params.get("remove_image") == "yes":
> kvm_vm.remove_image(params, test.bindir)
>
> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> index 18d10ef..767c6d4 100755
> --- a/client/tests/kvm/kvm_vm.py
> +++ b/client/tests/kvm/kvm_vm.py
> @@ -47,6 +47,15 @@ class VMImageMissingError(VMError):
> return "CD image file not found: %r" % self.filename
>
>
> +class VMImageCheckError(VMError):
> + def __init__(self, filename):
> + VMError.__init__(self, filename)
> + self.filename = filename
> +
> + def __str__(self):
> + return "Errors found on image: %r" % self.filename
> +
> +
> class VMBadPATypeError(VMError):
> def __init__(self, pa_type):
> VMError.__init__(self, pa_type)
> @@ -239,6 +248,59 @@ def remove_image(params, root_dir):
> logging.debug("Image file %s not found")
>
>
> +def check_image(params, root_dir):
> + """
> + Check an image using qemu-img.
> +
> + @param params: Dictionary containing the test parameters.
> + @param root_dir: Base directory for relative filenames.
> +
> + @note: params should contain:
> + image_name -- the name of the image file, without extension
> + image_format -- the format of the image (qcow2, raw etc)
> + """
> + image_filename = get_image_filename(params, root_dir)
> + logging.debug("Checking image file %s..." % image_filename)
> + qemu_img_cmd = kvm_utils.get_path(root_dir,
> + params.get("qemu_img_binary", "qemu-img"))
> + check_critical = params.get("check_image_critical") == 'yes'
> + image_is_qcow2 = params.get("image_format") == 'qcow2'
> + if os.path.exists(image_filename) and image_is_qcow2:
> + # Verifying if qemu-img supports 'check'
> + q_result = utils.run(qemu_img_cmd, ignore_status=True)
> + q_output = q_result.stdout
> + check_img = True
> + if not "check" in q_output:
> + logging.error("qemu-img does not support 'check', "
> + "skipping check...")
> + check_img = False
> + if not "info" in q_output:
> + logging.error("qemu-img does not support 'info', "
> + "skipping check...")
> + check_img = False
> + if check_img:
> + try:
> + utils.system("%s info %s" % (qemu_img_cmd, image_filename))
> + except error.CmdError:
> + logging.error("Error getting info from image %s",
> + image_filename)
> + try:
> + utils.system("%s check %s" % (qemu_img_cmd, image_filename))
> + except error.CmdError:
> + if check_critical:
> + raise VMImageCheckError(image_filename)
> + else:
> + logging.error("Error checking image %s", image_filename)
> +
> + else:
> + if not os.path.exists(image_filename):
> + logging.debug("Image file %s not found, skipping check...",
> + image_filename)
> + elif not image_is_qcow2:
> + logging.debug("Image file %s not qcow2, skipping check...",
> + image_filename)
> +
> +
> class VM:
> """
> This class handles all basic VM operations.
> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
> index 28064a8..8b67256 100644
> --- a/client/tests/kvm/tests_base.cfg.sample
> +++ b/client/tests/kvm/tests_base.cfg.sample
> @@ -2357,11 +2357,10 @@ kdump:
> variants:
> - @qcow2:
> image_format = qcow2
> - post_command += " python scripts/check_image.py;"
> - post_command_timeout = 600
> - post_command_noncritical = yes
> + check_image = yes
> + check_image_critical = no
> ioquit:
> - post_command_noncritical = no
> + check_image_critical = yes
> - vmdk:
> no ioquit
> only Fedora Ubuntu Windows
I know it's always been this way, but why is image_check noncritical?
If we just don't want the image_check exception to override the test's
failure exception, we can either set
image_check_critical = yes
image_check_critical_on_error = no
or, better yet, we can ignore all exceptions raised during
postprocessing after test failure (in kvm.py).
next prev parent reply other threads:[~2011-01-19 5:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-18 23:45 [PATCH 0/3] Removing scripts/check_image.py Lucas Meneghel Rodrigues
2011-01-18 23:45 ` [PATCH 1/3] KVM test: Introduce check_image postprocess directive Lucas Meneghel Rodrigues
2011-01-18 23:58 ` Amos Kong
2011-01-19 5:56 ` Michael Goldish [this message]
2011-01-18 23:45 ` [PATCH 2/3] KVM test: Modify enospc test to not require scripts/check_image.py Lucas Meneghel Rodrigues
2011-01-19 6:05 ` [Autotest] " Michael Goldish
2011-01-18 23:45 ` [PATCH 3/3] KVM test: Removing scripts/check_image.py Lucas Meneghel Rodrigues
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D367D14.6030202@redhat.com \
--to=mgoldish@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=lmr@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox