From patchwork Mon Apr 18 22:40:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 716631 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3IMf2qH024696 for ; Mon, 18 Apr 2011 22:41:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753366Ab1DRWk4 (ORCPT ); Mon, 18 Apr 2011 18:40:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44372 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753161Ab1DRWky (ORCPT ); Mon, 18 Apr 2011 18:40:54 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3IMer1s031969 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 18 Apr 2011 18:40:53 -0400 Received: from freedom.redhat.com (vpn-10-142.rdu.redhat.com [10.11.10.142]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3IMemIB003557; Mon, 18 Apr 2011 18:40:52 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 2/5] KVM test: Unattended install Give Linux VMs time to shutdown cleanly v2 Date: Mon, 18 Apr 2011 19:40:42 -0300 Message-Id: <1303166445-17898-3-git-send-email-lmr@redhat.com> In-Reply-To: <1303166445-17898-1-git-send-email-lmr@redhat.com> References: <1303166445-17898-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 18 Apr 2011 22:41:03 +0000 (UTC) During unattended install, right after we receive the ACK from the guest the test is deemed to be finished, and as shutdown_vm = yes, it'll try to end the vm issuing a shutdown command to it. However, on virtually all Linux guests an SSH server is not available at the end of install, so KVM autotest will end the VM forcefully, which is not really safe, although it has served us well so far. We did not fix this 'problem' so far because on RHEL3, a supported guest, the anaconda syntax does not support the 'poweroff' directive, only 'reboot', so if we don't finish the VM right after the ACK from guest we really can't prevent it from starting the install again, getting an infinite loop. Well then, let's restrict this behavior only to RHEL 3, and fix this properly for all other systems, by introducing a 'shutdown_cleanly' param and setting it to 'yes' to everybody but RHEL 3. Windows doesn't need this at all, as when the ACK is received the system is fully booted up and functional, so the postprocessing will take care of shutting down the VM cleanly. I've fixed all Fedora and RHEL unattended files as part of this change. With this change, we can get rid of another parameter, post_install_delay, that was created with the only purpose of handling the fact that on autoyast install, when the ACK is sent to host, the system is not fully done with install. So we end up fixing yet another problem :) Changes from v1: * Properly convert the post ack timeout to an int * Don't fix SLES unattended files, they'll be fixed in posterior patches Signed-off-by: Lucas Meneghel Rodrigues --- client/tests/kvm/tests/unattended_install.py | 10 ++++++---- client/tests/kvm/tests_base.cfg.sample | 8 ++++++-- client/tests/kvm/unattended/Fedora-10.ks | 1 + client/tests/kvm/unattended/Fedora-11.ks | 1 + client/tests/kvm/unattended/Fedora-12.ks | 1 + client/tests/kvm/unattended/Fedora-13.ks | 1 + client/tests/kvm/unattended/Fedora-14.ks | 1 + client/tests/kvm/unattended/Fedora-9.ks | 1 + client/tests/kvm/unattended/RHEL-4-series.ks | 2 +- client/tests/kvm/unattended/RHEL-5-series.ks | 2 +- client/tests/kvm/unattended/RHEL-6-series.ks | 2 +- 11 files changed, 21 insertions(+), 9 deletions(-) diff --git a/client/tests/kvm/tests/unattended_install.py b/client/tests/kvm/tests/unattended_install.py index 2d58cf2..fe7222e 100644 --- a/client/tests/kvm/tests/unattended_install.py +++ b/client/tests/kvm/tests/unattended_install.py @@ -558,7 +558,9 @@ def run_unattended_install(test, params, env): logging.info("Guest reported successful installation after %d s (%d min)", time_elapsed, time_elapsed/60) - if post_install_delay: - logging.debug("Post install delay specified, waiting %s s...", - post_install_delay) - time.sleep(post_install_delay) + if params.get("shutdown_cleanly", "yes") == "yes": + shutdown_cleanly_timeout = int(params.get("shutdown_cleanly_timeout", + 120)) + logging.info("Wait for guest to shudown cleanly...") + if kvm_utils.wait_for(vm.is_dead, shutdown_cleanly_timeout, 1, 1): + logging.info("Guest managed to shutdown cleanly") diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index 6397590..b96755d 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -101,6 +101,8 @@ variants: kill_vm = yes kill_vm_gracefully = yes kill_vm_on_error = yes + shutdown_cleanly = yes + shutdown_cleanly_timeout = 120 force_create_image = yes extra_params += " -boot d" guest_port_unattended_install = 12323 @@ -1294,7 +1296,6 @@ variants: # hold your autoyast file extra_params += " --append 'autoyast=floppy console=ttyS0,115200 console=tty0'" #extra_params += " --append 'autoyast=cdrom console=ttyS0,115200 console=tty0'" - post_install_delay = 10 variants: - 11.0.32: @@ -1434,7 +1435,6 @@ variants: # hold your autoyast file extra_params += " --append 'autoyast=floppy console=ttyS0,115200 console=tty0'" #extra_params += " --append 'autoyast=cdrom console=ttyS0,115200 console=tty0'" - post_install_delay = 10 kernel = linux initrd = initrd @@ -1563,6 +1563,8 @@ variants: cdrom_unattended = images/rhel39-32/ks.iso kernel = images/rhel39-32/vmlinuz initrd = images/rhel39-32/initrd.img + # 3.X anaconda does not support 'poweroff' on ks + shutdown_cleanly = no unattended_install.cdrom: cdrom_cd1 = isos/linux/RHEL-3.9-i386-DVD.iso md5sum_cd1 = ddd11a1cb104119039b0fa05df6d52b8 @@ -1583,6 +1585,8 @@ variants: cdrom_unattended = images/rhel39-64/ks.iso kernel = images/rhel39-64/vmlinuz initrd = images/rhel39-64/initrd.img + # 3.X anaconda does not support 'poweroff' on ks + shutdown_cleanly = no unattended_install.cdrom: cdrom_cd1 = isos/linux/RHEL-3.9-x86_64-DVD.iso md5sum_cd1 = bf4635e4a4bd3b43838e72bc8c329d55 diff --git a/client/tests/kvm/unattended/Fedora-10.ks b/client/tests/kvm/unattended/Fedora-10.ks index 5dffccd..081d41a 100644 --- a/client/tests/kvm/unattended/Fedora-10.ks +++ b/client/tests/kvm/unattended/Fedora-10.ks @@ -16,6 +16,7 @@ zerombr clearpart --all --initlabel autopart reboot +poweroff %packages @base diff --git a/client/tests/kvm/unattended/Fedora-11.ks b/client/tests/kvm/unattended/Fedora-11.ks index c7d43b3..c339220 100644 --- a/client/tests/kvm/unattended/Fedora-11.ks +++ b/client/tests/kvm/unattended/Fedora-11.ks @@ -12,6 +12,7 @@ timezone --utc America/New_York firstboot --disable bootloader --location=mbr --append="console=tty0 console=ttyS0,115200" zerombr +poweroff clearpart --all --initlabel autopart diff --git a/client/tests/kvm/unattended/Fedora-12.ks b/client/tests/kvm/unattended/Fedora-12.ks index c7d43b3..c339220 100644 --- a/client/tests/kvm/unattended/Fedora-12.ks +++ b/client/tests/kvm/unattended/Fedora-12.ks @@ -12,6 +12,7 @@ timezone --utc America/New_York firstboot --disable bootloader --location=mbr --append="console=tty0 console=ttyS0,115200" zerombr +poweroff clearpart --all --initlabel autopart diff --git a/client/tests/kvm/unattended/Fedora-13.ks b/client/tests/kvm/unattended/Fedora-13.ks index c7d43b3..c339220 100644 --- a/client/tests/kvm/unattended/Fedora-13.ks +++ b/client/tests/kvm/unattended/Fedora-13.ks @@ -12,6 +12,7 @@ timezone --utc America/New_York firstboot --disable bootloader --location=mbr --append="console=tty0 console=ttyS0,115200" zerombr +poweroff clearpart --all --initlabel autopart diff --git a/client/tests/kvm/unattended/Fedora-14.ks b/client/tests/kvm/unattended/Fedora-14.ks index db4298b..816428e 100644 --- a/client/tests/kvm/unattended/Fedora-14.ks +++ b/client/tests/kvm/unattended/Fedora-14.ks @@ -12,6 +12,7 @@ timezone --utc America/New_York firstboot --disable bootloader --location=mbr --append="rd_NO_PLYMOUTH console=tty0 console=ttyS0,115200" zerombr +poweroff clearpart --all --initlabel autopart diff --git a/client/tests/kvm/unattended/Fedora-9.ks b/client/tests/kvm/unattended/Fedora-9.ks index 9403191..a7d5399 100644 --- a/client/tests/kvm/unattended/Fedora-9.ks +++ b/client/tests/kvm/unattended/Fedora-9.ks @@ -16,6 +16,7 @@ zerombr clearpart --all --initlabel autopart reboot +poweroff %packages @base diff --git a/client/tests/kvm/unattended/RHEL-4-series.ks b/client/tests/kvm/unattended/RHEL-4-series.ks index 4583c76..2f7853e 100644 --- a/client/tests/kvm/unattended/RHEL-4-series.ks +++ b/client/tests/kvm/unattended/RHEL-4-series.ks @@ -15,7 +15,7 @@ bootloader --location=mbr --append="console=tty0 console=ttyS0,115200" zerombr clearpart --all --initlabel autopart -reboot +poweroff %packages @ base diff --git a/client/tests/kvm/unattended/RHEL-5-series.ks b/client/tests/kvm/unattended/RHEL-5-series.ks index c528d8a..a7be569 100644 --- a/client/tests/kvm/unattended/RHEL-5-series.ks +++ b/client/tests/kvm/unattended/RHEL-5-series.ks @@ -15,7 +15,7 @@ bootloader --location=mbr --append="console=tty0 console=ttyS0,115200" zerombr clearpart --all --initlabel autopart -reboot +poweroff %packages @base diff --git a/client/tests/kvm/unattended/RHEL-6-series.ks b/client/tests/kvm/unattended/RHEL-6-series.ks index 04f0672..fc41057 100644 --- a/client/tests/kvm/unattended/RHEL-6-series.ks +++ b/client/tests/kvm/unattended/RHEL-6-series.ks @@ -15,7 +15,7 @@ bootloader --location=mbr --append="console=tty0 console=ttyS0,115200" zerombr clearpart --all --initlabel autopart -reboot +poweroff %packages @base