aboutsummaryrefslogtreecommitdiffstats
path: root/android/main.c
diff options
context:
space:
mode:
authorDries Harnie <botje.linux@gmail.com>2010-05-15 17:04:47 +0200
committerDries Harnie <botje.linux@gmail.com>2010-05-18 01:09:27 +0200
commit40beab42ecdc4e2a79714b54c401feb0fb33b6d0 (patch)
tree1dd2ee27674b364f130c54382d7a3cd154ecbc37 /android/main.c
parentd27aca1c8172462c6e834c3c42582106b36aa422 (diff)
downloadexternal_qemu-40beab42ecdc4e2a79714b54c401feb0fb33b6d0.zip
external_qemu-40beab42ecdc4e2a79714b54c401feb0fb33b6d0.tar.gz
external_qemu-40beab42ecdc4e2a79714b54c401feb0fb33b6d0.tar.bz2
Enable interconnection of emulators
This patch adds a -shared-net-id option to the emulator which joins the emulator in a shared network. If the option is given the emulator is started with an additional network interface bound to a multicast socket. This multicast socket emulates a network hub, interconnecting emulators. If the -shared-net-id option is not given, nothing changes. Change-Id: I0ea70a073cdbd34f804161300240fafca34080d0
Diffstat (limited to 'android/main.c')
-rw-r--r--android/main.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/android/main.c b/android/main.c
index 3aa89d0..bf3feec 100644
--- a/android/main.c
+++ b/android/main.c
@@ -1758,6 +1758,19 @@ int main(int argc, char **argv)
qemu_cpu_delay = (int) delay;
}
+ if (opts->shared_net_id) {
+ char* end;
+ long shared_net_id = strtol(opts->shared_net_id, &end, 0);
+ if (end == NULL || *end || shared_net_id < 1 || shared_net_id > 255) {
+ fprintf(stderr, "option -shared-net-id must be an integer between 1 and 255\n");
+ exit(1);
+ }
+ char ip[11];
+ snprintf(ip, 11, "10.1.2.%ld", shared_net_id);
+ boot_property_add("net.shared_net_ip",ip);
+ }
+
+
emulator_config_init();
init_skinned_ui(opts->skindir, opts->skin, opts);
@@ -2271,6 +2284,22 @@ int main(int argc, char **argv)
args[n++] = "unix";
#endif
+ /* Set up the interfaces for inter-emulator networking */
+ if (opts->shared_net_id) {
+ unsigned int shared_net_id = atoi(opts->shared_net_id);
+ char nic[37];
+ args[n++] = "-net";
+ snprintf(nic, 37, "nic,vlan=1,macaddr=52:54:00:12:34:%02x", shared_net_id);
+ args[n++] = strdup(nic);
+ args[n++] = "-net";
+ args[n++] = "socket,vlan=1,mcast=230.0.0.10:1234";
+
+ args[n++] = "-net";
+ args[n++] = "nic,vlan=0";
+ args[n++] = "-net";
+ args[n++] = "user,vlan=0";
+ }
+
while(argc-- > 0) {
args[n++] = *argv++;
}