Support kernels with version >= 3.10
Newer Android Linux kernels modify the way certain devices are
named, i.e.:
/dev/qemu_pipe is renamed as /dev/goldfish_pipe.
/dev/ttyS<num> is renamed as /dev/ttyGF<num>
This patch adds support code to the emulator to deal with this
as transparently as possible:
1) Add a new hardware property 'kernel.newDeviceNaming', a string
which can only take the values 'autodetect', 'no', and 'yes'.
2) Support code to probe the type of a kernel image.
IMPORTANT: The kernel implementation depends on the host
/usr/bin/file to properly recognize kernel files and extract
their version number. This really only works on Linux and
OS X, and only for x86 and x86_64 kernel images.
A future patch will implement more robust detection by
essentially doing its own probing through libmagic or equivalent.
Note that there doesn't seem to be any existing libmagic rules
to recognize ARM and MIPS kernel images at the moment :-(
See android/kernel/kernel_utils*
3) Modify the emulator startup code to perform auto-detection
when possible (broken on Windows, and non Intel archs, see
comment above).
4) Modify the kernel command line generation to handle the new
TTY device naming
5) Modify the Goldfish pipe virtual device implementation
(since the device name presented to the kernel also changed).
This should be enough to auto-detect Linux 3.10+ x86_64 kernel
images on Linux.
Change-Id: Ied517f8a1fdeb18d84fa9a12ebcdc3daa1f41d9a
diff --git a/android/main.c b/android/main.c
index 0662bfe..c557d95 100644
--- a/android/main.c
+++ b/android/main.c
@@ -37,6 +37,7 @@
#include "android/config-file.h"
#include "android/config/config.h"
+#include "android/kernel/kernel_utils.h"
#include "android/user-config.h"
#include "android/utils/bufprint.h"
#include "android/utils/filelock.h"
@@ -452,6 +453,24 @@
}
}
+ // Auto-detect kernel device naming scheme if needed.
+ if (androidHwConfig_getKernelDeviceNaming(hw) < 0) {
+ KernelType kernelType;
+ const char* newDeviceNaming = "no";
+ if (!android_pathProbeKernelType(hw->kernel_path, &kernelType)) {
+ D("WARNING: Could not determine kernel device naming scheme. Assuming legacy\n"
+ "If this AVD doesn't boot, and uses a recent kernel (3.10 or above) try setting\n"
+ "'kernel.newDeviceNaming' to 'yes' in its configuration.\n");
+ } else if (kernelType == KERNEL_TYPE_3_10_OR_ABOVE) {
+ D("Auto-detect: Kernel image requires new device naming scheme.");
+ newDeviceNaming = "yes";
+ } else {
+ D("Auto-detect: Kernel image requires legacy device naming scheme.");
+ }
+ AFREE(hw->kernel_newDeviceNaming);
+ hw->kernel_newDeviceNaming = ASTRDUP(newDeviceNaming);
+ }
+
if (boot_prop_ip[0]) {
args[n++] = "-boot-property";
args[n++] = boot_prop_ip;
@@ -1027,7 +1046,9 @@
#endif
if (opts->shell || opts->logcat) {
- p = bufprint(p, end, " androidboot.console=ttyS%d", shell_serial );
+ p = bufprint(p, end, " androidboot.console=%s%d",
+ androidHwConfig_getKernelSerialPrefix(android_hw),
+ shell_serial );
}
if (opts->trace) {