From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Wang Subject: Re: [PATCH 2/3] KVM test: Do not use the hard-coded address during unattended installation Date: Fri, 28 May 2010 16:20:59 +0800 Message-ID: <4BFF7CEB.9030307@redhat.com> References: <20100519092036.13721.59023.stgit@dhcp-91-25.nay.redhat.com> <20100519092044.13721.73827.stgit@dhcp-91-25.nay.redhat.com> <1274882296.2599.11.camel@freedom> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: autotest@test.kernel.org, kvm@vger.kernel.org To: Lucas Meneghel Rodrigues Return-path: Received: from mx1.redhat.com ([209.132.183.28]:60094 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755978Ab0E1IPv (ORCPT ); Fri, 28 May 2010 04:15:51 -0400 In-Reply-To: <1274882296.2599.11.camel@freedom> Sender: kvm-owner@vger.kernel.org List-ID: Lucas Meneghel Rodrigues wrote: > On Wed, 2010-05-19 at 17:20 +0800, Jason Wang wrote: > >> When we do the unattended installation in tap mode, we should use >> vm.get_address() instead of the 'localhost' in order the connect to >> the finish program running in the guest. >> >> Signed-off-by: Jason Wang >> --- >> client/tests/kvm/tests/unattended_install.py | 25 +++++++++++++------------ >> 1 files changed, 13 insertions(+), 12 deletions(-) >> >> diff --git a/client/tests/kvm/tests/unattended_install.py b/client/tests/kvm/tests/unattended_install.py >> index e2cec8e..e71f993 100644 >> --- a/client/tests/kvm/tests/unattended_install.py >> +++ b/client/tests/kvm/tests/unattended_install.py >> @@ -17,7 +17,6 @@ def run_unattended_install(test, params, env): >> vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) >> >> port = vm.get_port(int(params.get("guest_port_unattended_install"))) >> - addr = ('localhost', port) >> if params.get("post_install_delay"): >> post_install_delay = int(params.get("post_install_delay")) >> else: >> @@ -31,17 +30,19 @@ def run_unattended_install(test, params, env): >> time_elapsed = 0 >> while time_elapsed < install_timeout: >> client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >> - try: >> - client.connect(addr) >> - msg = client.recv(1024) >> - if msg == 'done': >> - if post_install_delay: >> - logging.debug("Post install delay specified, " >> - "waiting %ss...", post_install_delay) >> - time.sleep(post_install_delay) >> - break >> - except socket.error: >> - pass >> + addr = vm.get_address() >> + if addr: >> > > ^ Per coding style, we should check for is None > > if addr is not None: > > >> + try: >> + client.connect((addr, port)) >> + msg = client.recv(1024) >> + if msg == 'done': >> + if post_install_delay: >> + logging.debug("Post install delay specified, " >> + "waiting %ss...", post_install_delay) >> + time.sleep(post_install_delay) >> + break >> + except socket.error: >> + pass >> > > ^ If vm.get_address() returns None, we'll have to fail the test, if we > don't we'll get a false PASS. > > An vm may not get its ip address during the startup and because we have timeout, I think it's safe here. >> time.sleep(1) >> client.close() >> end_time = time.time() >> >> -- >> To unsubscribe from this list: send the line "unsubscribe kvm" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> > > >