Fix x86 un-accelerated emulation.

Emulating an x86 system image was broken since the commit that
added support for 64-bit Intel CPUs, because the default CPU model
changed from 'qemu32' to 'qemu64'. Unfortunately, this prevents
existing x86 SDK system images from booting properly when using
un-accelerated emulation (i.e. without KVM or HAXM).

This patch fixes the issue by auto-configuring the CPU model
to "qemu32" if the target architecture is "x86". Note that "qemu64" will
still be used if the target architecture is "x86_64", so this should
not affect Intel 64-bit emulation.

Change-Id: Ib1fde3d7daa447b85f5b63393d6899b904948927
diff --git a/android/main.c b/android/main.c
index c557d95..62331c5 100644
--- a/android/main.c
+++ b/android/main.c
@@ -1263,6 +1263,22 @@
         D("Auto-config: -qemu -cpu %s", hw->hw_cpu_model);
     }
 
+    /* If the target architecture is 'x86', ensure that the 'qemu32'
+     * CPU model is used. Otherwise, the default (which is now 'qemu64')
+     * will result in a failure to boot with some kernels under
+     * un-accelerated emulation.
+     */
+    if (hw->hw_cpu_model[0] == '\0') {
+        char* arch = avdInfo_getTargetCpuArch(avd);
+        D("Target arch = '%s'", arch ? arch : "NULL");
+        if (arch != NULL && !strcmp(arch, "x86")) {
+            AFREE(hw->hw_cpu_model);
+            hw->hw_cpu_model = ASTRDUP("qemu32");
+            D("Auto-config: -qemu -cpu %s", hw->hw_cpu_model);
+        }
+        AFREE(arch);
+    }
+
     /* Generate a hardware-qemu.ini for this AVD. The real hardware
      * configuration is ususally stored in several files, e.g. the AVD's
      * config.ini plus the skin-specific hardware.ini.