From patchwork Tue Jun 8 21:50:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 105048 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 o58Loklx001991 for ; Tue, 8 Jun 2010 21:50:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754530Ab0FHVuo (ORCPT ); Tue, 8 Jun 2010 17:50:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44447 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751385Ab0FHVum (ORCPT ); Tue, 8 Jun 2010 17:50:42 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o58Loftf024629 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 8 Jun 2010 17:50:41 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o58LofiD016613; Tue, 8 Jun 2010 17:50:41 -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 o58LobsP018636; Tue, 8 Jun 2010 17:50:39 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH v2 2/4] KVM test: add boolean 'testdev' VM parameter for RHEL-6 style unit tests Date: Wed, 9 Jun 2010 00:50:05 +0300 Message-Id: <1276033807-22718-2-git-send-email-mgoldish@redhat.com> In-Reply-To: <1276033807-22718-1-git-send-email-mgoldish@redhat.com> References: <1276033807-22718-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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]); Tue, 08 Jun 2010 21:50:46 +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):