From patchwork Thu Oct 4 10:29:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiri Zupka X-Patchwork-Id: 1545971 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 14B1D3FC1A for ; Thu, 4 Oct 2012 10:29:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753557Ab2JDK3l (ORCPT ); Thu, 4 Oct 2012 06:29:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65533 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753503Ab2JDK3i (ORCPT ); Thu, 4 Oct 2012 06:29:38 -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.14.4/8.14.4) with ESMTP id q94ATHPu006767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 4 Oct 2012 06:29:17 -0400 Received: from jzupka-pc.local.com (vpn1-5-104.ams2.redhat.com [10.36.5.104]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q94ATAqi030456; Thu, 4 Oct 2012 06:29:16 -0400 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=BDupka?= To: autotest@test.kernel.org, kvm@vger.kernel.org, kvm-autotest@redhat.com, lmr@redhat.com, ldoktor@redhat.com, jzupka@redhat.com Subject: [virt][PATCH 3/4] virt: Adds kvm,libvirt check of machine model Date: Thu, 4 Oct 2012 12:29:07 +0200 Message-Id: <1349346548-25288-4-git-send-email-jzupka@redhat.com> In-Reply-To: <1349346548-25288-1-git-send-email-jzupka@redhat.com> References: <1349346548-25288-1-git-send-email-jzupka@redhat.com> 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 Signed-off-by: Ji?í Župka --- virttest/kvm_vm.py | 12 ++++++++++-- virttest/libvirt_vm.py | 13 +++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/virttest/kvm_vm.py b/virttest/kvm_vm.py index 9877d55..c51cd1b 100644 --- a/virttest/kvm_vm.py +++ b/virttest/kvm_vm.py @@ -830,7 +830,6 @@ class VM(virt_vm.BaseVM): cmd = "" return cmd - def add_machine_type(hlp, machine_type): if has_option(hlp, "machine") or has_option(hlp, "M"): return " -M %s" % machine_type @@ -916,6 +915,7 @@ class VM(virt_vm.BaseVM): self.qemu_binary = qemu_binary hlp = commands.getoutput("%s -help" % qemu_binary) support_cpu_model = commands.getoutput("%s -cpu ?list" % qemu_binary) + support_machine_type = commands.getoutput("%s -M ?" % qemu_binary) device_help = "" if has_option(hlp, "device"): @@ -1165,7 +1165,15 @@ class VM(virt_vm.BaseVM): machine_type = params.get("machine_type") if machine_type: - qemu_cmd += add_machine_type(hlp, machine_type) + m_types = [] + for m in support_machine_type.splitlines()[1:]: + m_types.append(m.split()[0]) + + if machine_type in m_types: + qemu_cmd += add_machine_type(hlp, machine_type) + else: + raise error.TestNAError("Not supported machine type %s." % + (machine_type)) for cdrom in params.objects("cdroms"): cd_format = params.get("cd_format", "") diff --git a/virttest/libvirt_vm.py b/virttest/libvirt_vm.py index 4e03835..c46c139 100644 --- a/virttest/libvirt_vm.py +++ b/virttest/libvirt_vm.py @@ -8,7 +8,7 @@ import time, os, logging, fcntl, re, shutil, urlparse, tempfile from autotest.client.shared import error from autotest.client import utils, os_dep from xml.dom import minidom -import utils_misc, virt_vm, storage, aexpect, remote, virsh +import utils_misc, virt_vm, storage, aexpect, remote, virsh, libvirt_xml def libvirtd_restart(): @@ -521,6 +521,11 @@ class VM(virt_vm.BaseVM): help = utils.system_output("%s --help" % virt_install_binary) + # Find all machine type. There isn't filtred any machine type even if + # domain doesn't support this machine type. Filtering could be added. + me = libvirt_xml.LibvirtXML().getroot().findall("./guest/arch/machine") + support_machine_type = map(lambda m: m.text, me) + # Start constructing the qemu command virt_install_cmd = "" # Set the X11 display parameter if requested @@ -542,7 +547,11 @@ class VM(virt_vm.BaseVM): machine_type = params.get("machine_type") if machine_type: - virt_install_cmd += add_machine_type(help, machine_type) + if machine_type in support_machine_type: + virt_install_cmd += add_machine_type(help, machine_type) + else: + raise error.TestNAError("Not supported machine type %s." % + (machine_type)) mem = params.get("mem") if mem: