[virt][PATCH 3/4] virt: Adds kvm,libvirt check of machine model

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jiří Župka <jzupka@xxxxxxxxxx>
---
 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:
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux