From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Goldish Subject: Re: [PATCH 3/3] KVM test: Test the file transfer during migartion Date: Mon, 01 Nov 2010 17:58:04 +0200 Message-ID: <4CCEE38C.1020605@redhat.com> References: <20100925092836.28158.64788.stgit@dhcp-91-158.nay.redhat.com> <20100925093656.28158.64041.stgit@dhcp-91-158.nay.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: lmr@redhat.com, autotest@test.kernel.org, kvm@vger.kernel.org, mst@redhat.com To: Jason Wang Return-path: Received: from mx1.redhat.com ([209.132.183.28]:13396 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758326Ab0KAP6J (ORCPT ); Mon, 1 Nov 2010 11:58:09 -0400 In-Reply-To: <20100925093656.28158.64041.stgit@dhcp-91-158.nay.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 09/25/2010 11:36 AM, Jason Wang wrote: > This test just do the file transfer from host to guest during migartion in order > to check whether the nic/block state could be saved and loaded correctly. > > Signed-off-by: Jason Wang > --- > .../kvm/tests/migration_with_file_transfer.py | 59 ++++++++++++++++++++ > client/tests/kvm/tests_base.cfg.sample | 7 ++ > 2 files changed, 66 insertions(+), 0 deletions(-) > create mode 100644 client/tests/kvm/tests/migration_with_file_transfer.py > > diff --git a/client/tests/kvm/tests/migration_with_file_transfer.py b/client/tests/kvm/tests/migration_with_file_transfer.py > new file mode 100644 > index 0000000..8a316bf > --- /dev/null > +++ b/client/tests/kvm/tests/migration_with_file_transfer.py > @@ -0,0 +1,59 @@ > +import logging, time > +from autotest_lib.client.common_lib import utils, error > +import kvm_subprocess, kvm_test_utils, kvm_utils > + > + > +def run_migration_with_file_transfer(test, params, env): > + """ > + KVM migration test: > + 1) Get a live VM and clone it. > + 2) Verify that the source VM supports migration. If it does, proceed with > + the test. > + 3) Reboot the VM > + 4) Send a migration command to the source VM and wait until it's finished. > + 5) Kill off the source VM. > + 6) Log into the destination VM after the migration is finished. > + > + @param test: kvm test object. > + @param params: Dictionary with test parameters. > + @param env: Dictionary with the test environment. > + """ > + > + def transfer_test(vm, host_path, guest_path, timeout=120): > + """ > + vm.copy_files_to does not raise exception, so we need a wrapper > + in order to make it to be used by BackgroundTest. > + """ > + if not vm.copy_files_to(host_path, guest_path, timeout=timeout): > + raise error.TestError("Fail to do the file transfer!") > + > + vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) > + timeout = int(params.get("login_timeout", 360)) > + session = kvm_test_utils.wait_for_login(vm, timeout=timeout) > + > + mig_timeout = float(params.get("mig_timeout", "3600")) > + mig_protocol = params.get("migration_protocol", "tcp") > + > + guest_path = params.get("guest_path", "/tmp") > + file_size = params.get("file_size", "1000") > + transfer_timeout = int(params.get("transfer_timeout", "240")) > + bg = None > + > + try: > + utils.run("dd if=/dev/zero of=/tmp/file bs=1M count=%s" % file_size) Wouldn't it be useful to read from /dev/urandom instead of /dev/zero, and compare the md5 hash of the file generated on the host with the md5 hash of the file that arrives in the guest? > + > + # Transfer file from host to guest > + bg = kvm_test_utils.BackgroundTest(transfer_test, > + (vm, "/tmp/file", guest_path, > + transfer_timeout)) > + bg.start() > + > + while bg.is_alive(): > + logging.info("File transfer is not ended, start a round of migration ...") > + # Migrate the VM > + dest_vm = kvm_test_utils.migrate(vm, env, mig_timeout, mig_protocol, False) > + vm = dest_vm > + finally: > + if bg: bg.join() > + session.close() > + utils.run("rm -rf /tmp/zero")