aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Chtchetkine <vchtchetkine@google.com>2010-08-11 15:30:32 -0700
committerVladimir Chtchetkine <vchtchetkine@google.com>2010-08-24 07:29:49 -0700
commit7fbf49776a98847a5f95325646f7eb5ff787423f (patch)
tree6bbdef92b669532c74800927632c932491f684c1
parentb5365f32d7b1dcc6c3e9be7584ce8d4f68b3e7e1 (diff)
downloadexternal_qemu-7fbf49776a98847a5f95325646f7eb5ff787423f.zip
external_qemu-7fbf49776a98847a5f95325646f7eb5ff787423f.tar.gz
external_qemu-7fbf49776a98847a5f95325646f7eb5ff787423f.tar.bz2
Cleanup stuff for the UI build
1. Move DNS server registration entirely to the core. 2. Move -memcheck option initialization entirely to the core. 3. Move qemu_help routine (used by both, Core and UI) to common qemu-help.c file. Change-Id: I5e47e94bdc375f0e037ccc6bd88daeb5fa06d1cf
-rw-r--r--android/main.c91
-rw-r--r--qemu-options.hx3
-rw-r--r--vl-android.c120
3 files changed, 127 insertions, 87 deletions
diff --git a/android/main.c b/android/main.c
index 2eba00f..25710bb 100644
--- a/android/main.c
+++ b/android/main.c
@@ -17,7 +17,7 @@
#ifdef _WIN32
#include <process.h>
#endif
-#include "libslirp.h"
+
#include "sockets.h"
#include "android/android.h"
@@ -69,9 +69,6 @@
#include "android/qemulator.h"
#include "android/display.h"
-/* in vl.c */
-extern void qemu_help(int code);
-
#include "framebuffer.h"
AndroidRotation android_framebuffer_rotation;
@@ -702,29 +699,6 @@ void emulator_help( void )
exit(1);
}
-static int
-add_dns_server( const char* server_name )
-{
- SockAddress addr;
-
- if (sock_address_init_resolve( &addr, server_name, 55, 0 ) < 0) {
- fprintf(stderr,
- "### WARNING: can't resolve DNS server name '%s'\n",
- server_name );
- return -1;
- }
-
- D( "DNS server name '%s' resolved to %s", server_name, sock_address_to_string(&addr) );
-
- if ( slirp_add_dns_server( &addr ) < 0 ) {
- fprintf(stderr,
- "### WARNING: could not add DNS server '%s' to the network stack\n", server_name);
- return -1;
- }
- return 0;
-}
-
-
/* this function is used to perform auto-detection of the
* system directory in the case of a SDK installation.
*
@@ -892,7 +866,6 @@ int main(int argc, char **argv)
int radio_serial = 0;
int qemud_serial = 0;
int shell_serial = 0;
- int dns_count = 0;
unsigned cachePartitionSize = 0;
unsigned systemPartitionSize = 0;
unsigned dataPartitionSize = 0;
@@ -961,16 +934,6 @@ int main(int argc, char **argv)
exit(1);
}
- /* special case, if -qemu -h is used, directly invoke the QEMU-specific help */
- if (argc > 0) {
- int nn;
- for (nn = 0; nn < argc; nn++)
- if (!strcmp(argv[nn], "-h")) {
- qemu_help(0);
- break;
- }
- }
-
if (android_charmap_setup(opts->charmap)) {
exit(1);
}
@@ -1401,41 +1364,6 @@ int main(int argc, char **argv)
if (opts->no_cache)
opts->cache = 0;
- if (opts->dns_server) {
- char* x = strchr(opts->dns_server, ',');
- dns_count = 0;
- if (x == NULL)
- {
- if ( add_dns_server( opts->dns_server ) == 0 )
- dns_count = 1;
- }
- else
- {
- x = strdup(opts->dns_server);
- while (*x) {
- char* y = strchr(x, ',');
-
- if (y != NULL)
- *y = 0;
-
- if (y == NULL || y > x) {
- if ( add_dns_server( x ) == 0 )
- dns_count += 1;
- }
-
- if (y == NULL)
- break;
-
- x = y+1;
- }
- }
- if (dns_count == 0)
- fprintf( stderr, "### WARNING: will use system default DNS server\n" );
- }
-
- if (dns_count == 0)
- dns_count = slirp_get_system_dns_servers();
-
n = 1;
/* generate arguments for the underlying qemu main() */
{
@@ -1464,6 +1392,11 @@ int main(int argc, char **argv)
}
}
+ if (opts->dns_server) {
+ args[n++] = "-dns-server";
+ args[n++] = opts->dns_server;
+ }
+
args[n++] = "-initrd";
args[n++] = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_RAMDISK);
@@ -1778,14 +1711,6 @@ int main(int argc, char **argv)
p = bufprint(p, end, " android.tracing=1");
}
-#ifdef CONFIG_MEMCHECK
- if (opts->memcheck) {
- /* This will set ro.kernel.memcheck system property
- * to memcheck's tracing flags. */
- p = bufprint(p, end, " memcheck=%s", opts->memcheck);
- }
-#endif // CONFIG_MEMCHECK
-
if (!opts->no_jni) {
p = bufprint(p, end, " android.checkjni=1");
}
@@ -1823,10 +1748,6 @@ int main(int argc, char **argv)
p = bufprint(p, end, " android.qemud=ttyS%d", qemud_serial);
}
- if (dns_count > 0) {
- p = bufprint(p, end, " android.ndns=%d", dns_count);
- }
-
if (opts->bootchart) {
p = bufprint(p, end, " androidboot.bootchart=%s", opts->bootchart);
}
diff --git a/qemu-options.hx b/qemu-options.hx
index 1883b08..927daaf 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1633,4 +1633,7 @@ DEF("android-hw", HAS_ARG, QEMU_OPTION_android_hw, \
DEF("android-memcheck", HAS_ARG, QEMU_OPTION_android_memcheck, \
"-android-memcheck <options> enable memory access checking on the emulated system\n")
+DEF("dns-server", HAS_ARG, QEMU_OPTION_dns_server, \
+ "-dns-server <servers> use this DNS server(s) in the emulated system\n")
+
#endif
diff --git a/vl-android.c b/vl-android.c
index 12627fd..8e38b7f 100644
--- a/vl-android.c
+++ b/vl-android.c
@@ -351,6 +351,9 @@ char* android_op_hwini = NULL;
/* Memory checker options. */
char* android_op_memcheck = NULL;
+/* -dns-server option value. */
+char* android_op_dns_server = NULL;
+
extern int android_display_width;
extern int android_display_height;
extern int android_display_bpp;
@@ -4546,7 +4549,7 @@ static void main_loop(void)
pause_all_vcpus();
}
-static void version(void)
+void version(void)
{
printf("QEMU PC emulator version " QEMU_VERSION QEMU_PKGVERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n");
}
@@ -4975,6 +4978,47 @@ char *qemu_find_file(int type, const char *name)
return buf;
}
+static int
+add_dns_server( const char* server_name )
+{
+ SockAddress addr;
+
+ if (sock_address_init_resolve( &addr, server_name, 55, 0 ) < 0) {
+ fprintf(stdout,
+ "### WARNING: can't resolve DNS server name '%s'\n",
+ server_name );
+ return -1;
+ }
+
+ fprintf(stderr,
+ "DNS server name '%s' resolved to %s\n", server_name, sock_address_to_string(&addr) );
+
+ if ( slirp_add_dns_server( &addr ) < 0 ) {
+ fprintf(stderr,
+ "### WARNING: could not add DNS server '%s' to the network stack\n", server_name);
+ return -1;
+ }
+ return 0;
+}
+
+/* Appends a parameter to a string of parameters separated with space.
+ * Pararm:
+ * param_str String containing parameters separated with space.
+ * param Parameter to append to the string.
+ * size - Size (in characters) of the buffer addressed by param_str.
+ */
+static void
+append_param(char* param_str, const char* arg, int size)
+{
+ if (*param_str) {
+ strncat(param_str, " ", size);
+ strncat(param_str, arg, size);
+ } else {
+ strncpy(param_str, arg, size);
+ param_str[size - 1] = '\0';
+ }
+}
+
int main(int argc, char **argv, char **envp)
{
const char *gdbstub_dev = NULL;
@@ -5024,6 +5068,14 @@ int main(int argc, char **argv, char **envp)
#ifdef CONFIG_STANDALONE_CORE
IniFile* hw_ini = NULL;
#endif // CONFIG_STANDALONE_CORE
+ /* Container for the kernel initialization parameters collected in this
+ * routine. */
+ char kernel_cmdline_append[1024];
+ /* Combines kernel initialization parameters passed from the UI with
+ * the parameters collected in this routine. */
+ char kernel_cmdline_full[1024];
+ char tmp_str[1024];
+ int dns_count = 0;
init_clocks();
@@ -5068,6 +5120,8 @@ int main(int argc, char **argv, char **envp)
snapshot = 0;
kernel_filename = NULL;
kernel_cmdline = "";
+ kernel_cmdline_append[0] = '\0';
+ kernel_cmdline_full[0] = '\0';
cyls = heads = secs = 0;
translation = BIOS_ATA_TRANSLATION_AUTO;
monitor_device = "vc:80Cx24C";
@@ -5820,9 +5874,19 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_android_hw:
android_op_hwini = (char*)optarg;
break;
+ case QEMU_OPTION_dns_server:
+ android_op_dns_server = (char*)optarg;
+ break;
+
#ifdef CONFIG_MEMCHECK
case QEMU_OPTION_android_memcheck:
android_op_memcheck = (char*)optarg;
+ snprintf(tmp_str, sizeof(tmp_str), "memcheck=%s",
+ android_op_memcheck);
+ tmp_str[sizeof(tmp_str) - 1] = '\0';
+ /* This will set ro.kernel.memcheck system property
+ * to memcheck's tracing flags. */
+ append_param(kernel_cmdline_append, tmp_str, sizeof(kernel_cmdline_append));
break;
#endif // CONFIG_MEMCHECK
}
@@ -5868,6 +5932,44 @@ int main(int argc, char **argv, char **envp)
iniFile_free(hw_ini);
#endif // CONFIG_STANDALONE_CORE
+ if (android_op_dns_server) {
+ char* x = strchr(android_op_dns_server, ',');
+ dns_count = 0;
+ if (x == NULL)
+ {
+ if ( add_dns_server( android_op_dns_server ) == 0 )
+ dns_count = 1;
+ }
+ else
+ {
+ x = android_op_dns_server;
+ while (*x) {
+ char* y = strchr(x, ',');
+
+ if (y != NULL) {
+ *y = 0;
+ y++;
+ } else {
+ y = x + strlen(x);
+ }
+
+ if (y > x && add_dns_server( x ) == 0) {
+ dns_count += 1;
+ }
+ x = y;
+ }
+ }
+ if (dns_count == 0)
+ fprintf( stdout, "### WARNING: will use system default DNS server\n" );
+ }
+
+ if (dns_count == 0)
+ dns_count = slirp_get_system_dns_servers();
+ if (dns_count) {
+ snprintf(tmp_str, sizeof(tmp_str), "android.ndns=%d", dns_count);
+ append_param(kernel_cmdline_append, tmp_str, sizeof(kernel_cmdline_append));
+ }
+
#ifdef CONFIG_MEMCHECK
if (android_op_memcheck) {
memcheck_init(android_op_memcheck);
@@ -6235,8 +6337,22 @@ int main(int argc, char **argv, char **envp)
}
#endif
+ /* Combine kernel command line passed from the UI with parameters
+ * collected during initialization. */
+ if (*kernel_cmdline) {
+ if (kernel_cmdline_append[0]) {
+ snprintf(kernel_cmdline_full, sizeof(kernel_cmdline_full), "%s %s",
+ kernel_cmdline, kernel_cmdline_append);
+ } else {
+ strncpy(kernel_cmdline_full, kernel_cmdline, sizeof(kernel_cmdline_full));
+ kernel_cmdline_full[sizeof(kernel_cmdline_full) - 1] = '\0';
+ }
+ } else if (kernel_cmdline_append[0]) {
+ strncpy(kernel_cmdline_full, kernel_cmdline_append, sizeof(kernel_cmdline_full));
+ }
+
machine->init(ram_size, boot_devices,
- kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
+ kernel_filename, kernel_cmdline_full, initrd_filename, cpu_model);
for (env = first_cpu; env != NULL; env = env->next_cpu) {