From patchwork Mon Apr 26 10:03:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 95031 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3Q9xSYN010296 for ; Mon, 26 Apr 2010 09:59:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753640Ab0DZJ7J (ORCPT ); Mon, 26 Apr 2010 05:59:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36663 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753214Ab0DZJ7I (ORCPT ); Mon, 26 Apr 2010 05:59:08 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3Q9x7AN028740 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 26 Apr 2010 05:59:07 -0400 Received: from localhost.localdomain ([10.66.91.25]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o3Q9x5wW018005; Mon, 26 Apr 2010 05:59:05 -0400 Subject: [PATCH 4/9] KVM test: Redirect the serial to the unix domain socket To: autotest@test.kernel.org, lmr@redhat.com From: Jason Wang Cc: kvm@vger.kernel.org Date: Mon, 26 Apr 2010 18:03:54 +0800 Message-ID: <20100426100354.26268.97488.stgit@localhost.localdomain> In-Reply-To: <20100426095656.26268.50549.stgit@localhost.localdomain> References: <20100426095656.26268.50549.stgit@localhost.localdomain> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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.3 (demeter.kernel.org [140.211.167.41]); Mon, 26 Apr 2010 09:59:31 +0000 (UTC) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 6bc7987..8f4753f 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -116,17 +116,20 @@ class VM: self.address_cache = address_cache self.pci_assignable = None - # Find available monitor filename + # Find available filenames for monitor and guest serial redirection while True: - # The monitor filename should be unique + # The filenames should be unique self.instance = (time.strftime("%Y%m%d-%H%M%S-") + kvm_utils.generate_random_string(4)) - self.monitor_file_name = os.path.join("/tmp", - "monitor-" + self.instance) - if not os.path.exists(self.monitor_file_name): - break - + names = [os.path.join("/tmp", type + self.instance) for type in + "monitor-", "serial-"] + if True in [os.path.exists(file) for file in names]: + continue + else: + [self.monitor_file_name, self.serial_file_name] = names + break + def clone(self, name=None, params=None, root_dir=None, address_cache=None): """ Return a clone of the VM object with optionally modified parameters. @@ -316,6 +319,8 @@ class VM: for pci_id in self.pa_pci_ids: qemu_cmd += " -pcidevice host=%s" % pci_id + qemu_cmd += " -serial unix:%s,server,nowait" % self.serial_file_name + return qemu_cmd