From patchwork Thu Jun 3 11:03:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 104073 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 o53B3Z96004873 for ; Thu, 3 Jun 2010 11:03:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752556Ab0FCLDc (ORCPT ); Thu, 3 Jun 2010 07:03:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7054 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752069Ab0FCLDb (ORCPT ); Thu, 3 Jun 2010 07:03:31 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o53B3UC7019255 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Jun 2010 07:03:30 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o53B3Twt031900; Thu, 3 Jun 2010 07:03:30 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o53B3QFc025307; Thu, 3 Jun 2010 07:03:28 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 2/4] KVM test: add boolean 'testdev' VM parameter for RHEL-6 style unit tests Date: Thu, 3 Jun 2010 14:03:15 +0300 Message-Id: <1275562997-26311-2-git-send-email-mgoldish@redhat.com> In-Reply-To: <1275562997-26311-1-git-send-email-mgoldish@redhat.com> References: <1275562997-26311-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 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]); Thu, 03 Jun 2010 11:03:35 +0000 (UTC) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index f3c05f3..af45a81 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -118,12 +118,16 @@ class VM: # Find available monitor filename while True: - # The monitor filename should be unique + # A unique identifier for this VM 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): + # Monitor + self.monitor_file_name = "/tmp/monitor-" + self.instance + # Test log for unit tests + self.testlog_file_name = "/tmp/testlog-" + self.instance + # Verify uniqueness + if True not in map(os.path.exists, [self.monitor_file_name, + self.testlog_file_name]): break @@ -274,6 +278,10 @@ class VM: def add_kernel_cmdline(help, cmdline): return " -append %s" % cmdline + def add_testdev(help, filename): + return (" -chardev file,id=testlog,path=%s" + " -device testdev,chardev=testlog" % filename) + # End of command line option wrappers if name is None: name = self.name @@ -393,6 +401,9 @@ class VM: elif params.get("uuid"): qemu_cmd += add_uuid(help, params.get("uuid")) + if params.get("testdev") == "yes": + qemu_cmd += add_testdev(help, self.testlog_file_name) + # If the PCI assignment step went OK, add each one of the PCI assigned # devices to the qemu command line. if self.pci_assignable: @@ -728,10 +739,11 @@ class VM: self.pci_assignable.release_devs() if self.process: self.process.close() - try: - os.unlink(self.monitor_file_name) - except OSError: - pass + for f in [self.monitor_file_name, self.testlog_file_name]: + try: + os.unlink(f) + except OSError: + pass def is_alive(self):