commit c4162f6708764a3e458baeea16ce7026ed8b0b2c
Author: Cole Robinson <crobinso@redhat.com>
Date:   Tue Sep 23 16:05:48 2014 -0400

    Use -M virt as default machine for arm/aarch64
    
    Centralize the default machine logic in caps and use it consistently

Index: virt-manager-1.0.1/tests/cli-test-xml/compare/virt-install-ppc64-machdefault-f20.xml
===================================================================
--- /dev/null
+++ virt-manager-1.0.1/tests/cli-test-xml/compare/virt-install-ppc64-machdefault-f20.xml
@@ -0,0 +1,42 @@
+<domain type="qemu">
+  <name>foobar</name>
+  <uuid>00000000-1111-2222-3333-444444444444</uuid>
+  <memory>65536</memory>
+  <currentMemory>65536</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch="ppc64" machine="pseries">hvm</type>
+    <boot dev="network"/>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset="utc"/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <disk type="file" device="disk">
+      <driver name="qemu" type="qcow2"/>
+      <source file="/dev/default-pool/testvol1.img"/>
+      <target dev="sda" bus="scsi"/>
+    </disk>
+    <graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
+    <console type="pty"/>
+    <channel type="unix">
+      <source mode="bind"/>
+      <target type="virtio" name="org.qemu.guest_agent.0"/>
+    </channel>
+    <channel type="spicevmc">
+      <target type="virtio" name="com.redhat.spice.0"/>
+    </channel>
+    <video>
+      <model type="vga"/>
+    </video>
+    <redirdev bus="usb" type="spicevmc"/>
+    <redirdev bus="usb" type="spicevmc"/>
+  </devices>
+</domain>
Index: virt-manager-1.0.1/virt-install
===================================================================
--- virt-manager-1.0.1.orig/virt-install
+++ virt-manager-1.0.1/virt-install
@@ -204,7 +204,6 @@ def get_guest(conn, options):
                         typ=req_hv_type,
                         machine=options.machine)
         guest = conn.caps.build_virtinst_guest(conn, capsguest, capsdomain)
-        guest.os.machine = options.machine
     except Exception, e:
         fail(e)
 
Index: virt-manager-1.0.1/virtManager/create.py
===================================================================
--- virt-manager-1.0.1.orig/virtManager/create.py
+++ virt-manager-1.0.1/virtManager/create.py
@@ -705,12 +705,11 @@ class vmmCreate(vmmGObjectUI):
 
         defmachine = None
         prios = []
-        if self.capsguest.arch == "armv7l":
-            defmachine = "vexpress-a9"
-            prios = ["vexpress-a9", "vexpress-a15", "highbank", "midway"]
-        elif self.capsguest.arch == "ppc64":
-            defmachine = "pseries"
-            prios = ["pseries"]
+        recommended_machine = self.capsdomain.get_recommended_machine(
+            self.conn.get_backend(), self.capsguest)
+        if recommended_machine:
+            defmachine = recommended_machine
+            prios = [defmachine]
 
         for p in prios[:]:
             if p not in machines:
Index: virt-manager-1.0.1/virtinst/capabilities.py
===================================================================
--- virt-manager-1.0.1.orig/virtinst/capabilities.py
+++ virt-manager-1.0.1/virtinst/capabilities.py
@@ -355,10 +355,15 @@ class Guest(object):
     def bestDomainType(self, dtype=None, machine=None):
         domains = []
         for d in self.domains:
+            d.set_recommended_machine(None)
+
             if dtype and d.hypervisor_type != dtype.lower():
                 continue
             if machine and machine not in d.machines:
                 continue
+
+            if machine:
+                d.set_recommended_machine(machine)
             domains.append(d)
 
         return self._favoredDomain(domains)
@@ -373,9 +378,30 @@ class Domain(object):
         self.loader = loader
         self.machines = machines
 
+        self._recommended_machine = None
+
         if node is not None:
             self.parseXML(node)
 
+    def get_recommended_machine(self, conn, capsguest):
+        if self._recommended_machine:
+            return self._recommended_machine
+
+        if not conn.is_test() and not conn.is_qemu():
+            return None
+
+        if capsguest.arch == "ppc64" and "pseries" in self.machines:
+            return "pseries"
+        if capsguest.arch in ["armv7l", "aarch64"]:
+            if "virt" in self.machines:
+                return "virt"
+            if "vexpress-a15" in self.machines:
+                return "vexpress-a15"
+
+        return None
+
+    def set_recommended_machine(self, machine):
+        self._recommended_machine = machine
 
     def parseXML(self, node):
         child = node.children
@@ -690,5 +716,6 @@ class Capabilities(object):
         gobj.os.arch = guest.arch
         gobj.os.loader = domain.loader
         gobj.emulator = domain.emulator
+        gobj.os.machine = domain.get_recommended_machine(conn, guest)
 
         return gobj
Index: virt-manager-1.0.1/virtinst/guest.py
===================================================================
--- virt-manager-1.0.1.orig/virtinst/guest.py
+++ virt-manager-1.0.1/virtinst/guest.py
@@ -670,9 +670,6 @@ class Guest(XMLBuilder):
         if self.os.kernel or self.os.init:
             self.os.bootorder = []
 
-        if (self.os.machine is None and self.os.is_ppc64()):
-            self.os.machine = "pseries"
-
     def _set_clock_defaults(self):
         if not self.os.is_hvm():
             return
