Blob Blame History Raw
diff -rup virtinst-0.500.2/virtinst/CapabilitiesParser.py foo/virtinst/CapabilitiesParser.py
--- virtinst-0.500.2/virtinst/CapabilitiesParser.py	2010-02-08 23:07:04.000000000 -0500
+++ foo/virtinst/CapabilitiesParser.py	2010-03-22 15:05:19.530904000 -0400
@@ -90,6 +90,7 @@ class Host(object):
     def __init__(self, node = None):
         # e.g. "i686" or "x86_64"
         self.arch = None
+        self.model = None
 
         self.features = CapabilityFeatures()
         self.topology = None
@@ -115,6 +116,8 @@ class Host(object):
             while n:
                 if n.name == "arch":
                     self.arch = n.content
+                elif n.name == "model":
+                    self.model = n.content
                 elif n.name == "features":
                     self.features = CapabilityFeatures(n)
                 n = n.next
diff -rup virtinst-0.500.2/virtinst/Guest.py foo/virtinst/Guest.py
--- virtinst-0.500.2/virtinst/Guest.py	2010-03-22 15:03:37.220776000 -0400
+++ foo/virtinst/Guest.py	2010-03-22 15:07:16.032765000 -0400
@@ -695,6 +695,22 @@ class Guest(object):
         """
         return self.clock.get_xml_config()
 
+    def _get_cpu_xml(self):
+        """
+        Return <cpu> XML
+        """
+        xml = ""
+        is_kvm = self.type == "kvm"
+        model = self._caps.host.model
+
+        if is_kvm and model:
+            xml += "  <cpu match='exact'>\n"
+            xml += "    <model>%s</model>\n" % model
+            xml += "    <feature policy='force' name='x2apic'/>\n"
+            xml += "  </cpu>"
+
+        return xml
+
     def _get_seclabel_xml(self):
         """
         Return <seclabel> XML
@@ -718,6 +734,7 @@ class Guest(object):
         xml = _util.xml_append(xml,
                                self.installer.get_install_xml(self, install))
         xml = _util.xml_append(xml, self._get_features_xml())
+        xml = _util.xml_append(xml, self._get_cpu_xml())
         xml = _util.xml_append(xml, self._get_clock_xml())
         return xml