In order to resolve the question, 'how will the guest operating system tell the host operating system that the unattended install process finish', we took the simple approach and created a simple socket communication ack process: The test instantiates a server tcp socket on port 12323, and waits during a specified amount of time. For guests, the vast majority of the unattended install processes can deal with executing commands at the end of the install process. Let's take advantage of that and make clients tell the server about the end of the process using simple programs that can do that. The implementation of that strategy varies trough different operating systems. This is the kvm test implementation code, client programs will follow on later patches. Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx> --- client/tests/kvm/tests/unattended_install.py | 45 ++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/unattended_install.py diff --git a/client/tests/kvm/tests/unattended_install.py b/client/tests/kvm/tests/unattended_install.py new file mode 100644 index 0000000..60e2a35 --- /dev/null +++ b/client/tests/kvm/tests/unattended_install.py @@ -0,0 +1,45 @@ +import logging, time, socket +from autotest_lib.client.common_lib import error +import kvm_utils, kvm_test_utils + + +def run_unattended_install(test, params, env): + """ + Unattended install test: + 1) Starts a VM with an appropriated setup to start an unattended OS install. + 2) Wait until the install reports to the install watcher its end. + + @param test: KVM test object. + @param params: Dictionary with the test parameters. + @param env: Dictionary with test environment. + """ + vm = kvm_utils.env_get_vm(env, params.get("main_vm")) + if not vm: + raise error.TestError("VM object not found in environment") + if not vm.is_alive(): + raise error.TestError("VM seems to be dead; Test requires a living VM") + + logging.info("Starting unattended install watch process") + server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server.bind(('', 12323)) + server.listen(1) + + end_time = time.time() + float(params.get("timeout", 3000)) + + while True: + server.settimeout(end_time - time.time()) + try: + (client, addr) = server.accept() + except socket.timeout: + server.close() + raise error.TestFail('Timeout elapsed while waiting for install to ' + 'finish.') + msg = client.recv(1024) + logging.debug("Received '%s' from %s", msg, addr) + if msg == 'done': + logging.info('Guest reported successful installation') + server.close() + break + else: + logging.error('Got invalid string from client: %s.' % msg) + -- 1.6.2.5 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html