From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 07/11] virt.virt_env_process: Add libvirt vm handling
Date: Tue, 11 Oct 2011 18:07:13 -0300 [thread overview]
Message-ID: <1318367237-26081-8-git-send-email-lmr@redhat.com> (raw)
In-Reply-To: <1318367237-26081-1-git-send-email-lmr@redhat.com>
With this patch, we make libvirt vm handling integrating
to pre/postprocessing code, making it possible the
execution of a libvirt test. The idea was to try
to abstract some concepts and intrude the least
possible in the pre/postprocessing code.
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
client/virt/virt_env_process.py | 51 +++++++++++++++++++++++++++++---------
1 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/client/virt/virt_env_process.py b/client/virt/virt_env_process.py
index 51c7e8a..6235c4e 100644
--- a/client/virt/virt_env_process.py
+++ b/client/virt/virt_env_process.py
@@ -2,7 +2,7 @@ import os, time, commands, re, logging, glob, threading, shutil
from autotest_lib.client.bin import utils
from autotest_lib.client.common_lib import error
import aexpect, virt_utils, kvm_monitor, ppm_utils, virt_test_setup
-import virt_vm, kvm_vm
+import virt_vm, kvm_vm, libvirt_vm
try:
import PIL.Image
except ImportError:
@@ -51,13 +51,23 @@ def preprocess_vm(test, params, env, name):
"""
logging.debug("Preprocessing VM '%s'", name)
vm = env.get_vm(name)
+ vm_type = params.get('vm_type')
if not vm:
logging.debug("VM object for '%s' does not exist, creating it", name)
- vm_type = params.get('vm_type')
if vm_type == 'kvm':
vm = kvm_vm.VM(name, params, test.bindir, env.get("address_cache"))
+ if vm_type == 'libvirt':
+ vm = libvirt_vm.VM(name, params, test.bindir, env.get("address_cache"))
env.register_vm(name, vm)
+ remove_vm = False
+ if params.get("force_remove_vm") == "yes":
+ logging.debug("'force_remove_vm' specified; removing VM...")
+ remove_vm = True
+
+ if remove_vm and not libvirt_vm.virsh_remove_domain(name):
+ raise error.TestError("Could not remove VM")
+
start_vm = False
if params.get("restart_vm") == "yes":
@@ -68,18 +78,31 @@ def preprocess_vm(test, params, env, name):
"incoming migration mode")
start_vm = True
elif params.get("start_vm") == "yes":
- if not vm.is_alive():
- logging.debug("VM is not alive, starting it")
- start_vm = True
- if vm.needs_restart(name=name, params=params, basedir=test.bindir):
- logging.debug("Current VM specs differ from requested one; "
- "restarting it")
- start_vm = True
+ # need to deal with libvirt VM differently than qemu
+ if vm_type == 'libvirt':
+ if not libvirt_vm.virsh_is_alive(name):
+ logging.debug("VM is not alive; starting it...")
+ start_vm = True
+ else:
+ if not vm.is_alive():
+ logging.debug("VM is not alive, starting it")
+ start_vm = True
+ if vm.needs_restart(name=name, params=params, basedir=test.bindir):
+ logging.debug("Current VM specs differ from requested one; "
+ "restarting it")
+ start_vm = True
if start_vm:
- # Start the VM (or restart it if it's already up)
- vm.create(name, params, test.bindir,
- migration_mode=params.get("migration_mode"))
+ if vm_type == 'libvirt' and params.get("type") != "unattended_install":
+ libvirt_vm.virsh_start(name, vm)
+ # Wait for the domain to be created
+ virt_utils.wait_for(func=vm.is_alive, timeout=60,
+ text=("waiting for domain %s to start" %
+ vm.name))
+ else:
+ # Start the VM (or restart it if it's already up)
+ vm.create(name, params, test.bindir,
+ migration_mode=params.get("migration_mode"))
else:
# Don't start the VM, just update its params
vm.params = params
@@ -277,6 +300,8 @@ def preprocess(test, params, env):
if params.get("setup_hugepages") == "yes":
h = virt_test_setup.HugePageConfig(params)
h.setup()
+ if params.get("vm_type") == "libvirt":
+ libvirt_vm.libvirtd_restart()
# Execute any pre_commands
if params.get("pre_command"):
@@ -377,6 +402,8 @@ def postprocess(test, params, env):
if params.get("setup_hugepages") == "yes":
h = virt_test_setup.HugePageConfig(params)
h.cleanup()
+ if params.get("vm_type") == "libvirt":
+ libvirt_vm.libvirtd_restart()
# Execute any post_commands
if params.get("post_command"):
--
1.7.6.4
next prev parent reply other threads:[~2011-10-11 21:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-11 21:07 [PATCH 00/11] [RFC] Libvirt test v2 Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 02/11] virt: Introducing virt_test.virt_test class Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 03/11] Moving unattended_install test from kvm test to common virt location Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 04/11] Moving get_started code to client.virt.virt_utils Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 05/11] virt: Introducing libvirt VM class Lucas Meneghel Rodrigues
2011-10-12 6:51 ` [Autotest] " Amos Kong
2011-10-12 8:14 ` Daniel P. Berrange
2011-10-13 17:26 ` Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 06/11] virt: Introducing libvirt monitor Lucas Meneghel Rodrigues
2011-10-12 7:48 ` [Autotest] " Amos Kong
2011-10-13 17:12 ` Lucas Meneghel Rodrigues
2011-10-11 21:07 ` Lucas Meneghel Rodrigues [this message]
2011-10-11 21:07 ` [PATCH 08/11] client.tests: Introducing libvirt test Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 09/11] Virt: builtin HTTP server for unattended installs Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 10/11] Virt: support XEN via libvirt and auto url installer Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 11/11] Virt: add support for XEN via libvirt installs and auto url 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=1318367237-26081-8-git-send-email-lmr@redhat.com \
--to=lmr@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kvm@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).