Module Name: src
Committed By: jmcneill
Date: Sat Jan 7 18:10:18 UTC 2012
Modified Files:
src/sys/arch/usermode/conf: GENERIC.common
src/sys/arch/usermode/dev: mainbus.c
src/sys/arch/usermode/usermode: machdep.c
Log Message:
support multiple disk images (pass multiple disk=<path> parameters on the
command-line). while changing command-line params, rename tap= option to
net=
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/usermode/conf/GENERIC.common
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/dev/mainbus.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/usermode/usermode/machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/usermode/conf/GENERIC.common
diff -u src/sys/arch/usermode/conf/GENERIC.common:1.11 src/sys/arch/usermode/conf/GENERIC.common:1.12
--- src/sys/arch/usermode/conf/GENERIC.common:1.11 Wed Jan 4 14:04:12 2012
+++ src/sys/arch/usermode/conf/GENERIC.common Sat Jan 7 18:10:18 2012
@@ -1,9 +1,9 @@
-# $NetBSD: GENERIC.common,v 1.11 2012/01/04 14:04:12 jmcneill Exp $
+# $NetBSD: GENERIC.common,v 1.12 2012/01/07 18:10:18 jmcneill Exp $
include "arch/usermode/conf/std.usermode"
options INCLUDE_CONFIG_FILE
-#ident "GENERIC-$Revision: 1.11 $"
+#ident "GENERIC-$Revision: 1.12 $"
maxusers 32
makeoptions DEBUG="-O1 -g3"
@@ -55,7 +55,7 @@ mainbus0 at root
cpu0 at mainbus?
clock0 at mainbus?
ttycons0 at mainbus?
-ld0 at mainbus?
+ld* at mainbus?
veth0 at mainbus?
vaudio0 at mainbus?
audio0 at vaudio0
Index: src/sys/arch/usermode/dev/mainbus.c
diff -u src/sys/arch/usermode/dev/mainbus.c:1.8 src/sys/arch/usermode/dev/mainbus.c:1.9
--- src/sys/arch/usermode/dev/mainbus.c:1.8 Thu Dec 29 21:22:49 2011
+++ src/sys/arch/usermode/dev/mainbus.c Sat Jan 7 18:10:18 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.c,v 1.8 2011/12/29 21:22:49 jmcneill Exp $ */
+/* $NetBSD: mainbus.c,v 1.9 2012/01/07 18:10:18 jmcneill Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.8 2011/12/29 21:22:49 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.9 2012/01/07 18:10:18 jmcneill Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -50,7 +50,8 @@ typedef struct mainbus_softc {
CFATTACH_DECL_NEW(mainbus, sizeof(mainbus_softc_t),
mainbus_match, mainbus_attach, NULL, NULL);
-extern char *usermode_root_image_path;
+extern char *usermode_disk_image_path[];
+extern int usermode_disk_image_path_count;
extern char *usermode_tap_device;
extern char *usermode_tap_eaddr;
extern char *usermode_audio_device;
@@ -68,6 +69,7 @@ mainbus_attach(device_t parent, device_t
{
mainbus_softc_t *sc = device_private(self);
struct thunkbus_attach_args taa;
+ int i;
aprint_naive("\n");
aprint_normal("\n");
@@ -104,9 +106,9 @@ mainbus_attach(device_t parent, device_t
config_found_ia(self, "thunkbus", &taa, mainbus_print);
}
- if (usermode_root_image_path) {
+ for (i = 0; i < usermode_disk_image_path_count; i++) {
taa.taa_type = THUNKBUS_TYPE_DISKIMAGE;
- taa.u.diskimage.path = usermode_root_image_path;
+ taa.u.diskimage.path = usermode_disk_image_path[i];
config_found_ia(self, "thunkbus", &taa, mainbus_print);
}
}
Index: src/sys/arch/usermode/usermode/machdep.c
diff -u src/sys/arch/usermode/usermode/machdep.c:1.49 src/sys/arch/usermode/usermode/machdep.c:1.50
--- src/sys/arch/usermode/usermode/machdep.c:1.49 Fri Jan 6 20:44:57 2012
+++ src/sys/arch/usermode/usermode/machdep.c Sat Jan 7 18:10:18 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.49 2012/01/06 20:44:57 reinoud Exp $ */
+/* $NetBSD: machdep.c,v 1.50 2012/01/07 18:10:18 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Reinoud Zandijk <[email protected]>
@@ -37,7 +37,7 @@
#include "opt_memsize.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.49 2012/01/06 20:44:57 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.50 2012/01/07 18:10:18 jmcneill Exp $");
#include <sys/types.h>
#include <sys/systm.h>
@@ -58,6 +58,10 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v
#include <machine/machdep.h>
#include <machine/thunk.h>
+#ifndef MAX_DISK_IMAGES
+#define MAX_DISK_IMAGES 4
+#endif
+
char machine[_SYS_NMLN] = "";
char machine_arch[_SYS_NMLN] = "";
char module_machine_usermode[_SYS_NMLN] = "";
@@ -65,7 +69,10 @@ char module_machine_usermode[_SYS_NMLN]
struct vm_map *phys_map = NULL;
static char **saved_argv;
-char *usermode_root_image_path = NULL;
+
+char *usermode_disk_image_path[MAX_DISK_IMAGES];
+int usermode_disk_image_path_count = 0;
+
static char usermode_tap_devicebuf[PATH_MAX] = "";
char *usermode_tap_device = NULL;
char *usermode_tap_eaddr = NULL;
@@ -82,16 +89,16 @@ static void
usage(const char *pn)
{
printf("usage: %s [-acdqsvxz]"
- " [tap=<dev>,<eaddr>]"
- " [audio=<dev>]"
- " [vnc=<width>x<height>,<port>]"
- " [<fsimg>]\n",
+ " [net=<tapdev>,<eaddr>]"
+ " [audio=<audiodev>]"
+ " [disk=<diskimg> ...]"
+ " [vnc=<width>x<height>,<port>]\n",
pn);
printf(" (ex. \"%s"
- " tap=tap0,00:00:be:ef:ca:fe"
+ " net=tap0,00:00:be:ef:ca:fe"
" audio=audio0"
- " vnc=640x480,5900"
- " root.fs\")\n", pn);
+ " disk=root.fs"
+ " vnc=640x480,5900\")\n", pn);
}
void
@@ -115,11 +122,11 @@ main(int argc, char *argv[])
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-') {
- if (strncmp(argv[i], "tap=", strlen("tap=")) == 0) {
- char *tap = argv[i] + strlen("tap=");
+ if (strncmp(argv[i], "net=", strlen("net=")) == 0) {
+ char *tap = argv[i] + strlen("net=");
char *mac = strchr(tap, ',');
if (mac == NULL) {
- printf("bad tap= format\n");
+ printf("bad net= format\n");
return;
}
*mac++ = '\0';
@@ -166,8 +173,22 @@ main(int argc, char *argv[])
usermode_vnc_width = strtoul(w, NULL, 10);
usermode_vnc_height = strtoul(h, NULL, 10);
usermode_vnc_port = strtoul(p, NULL, 10);
+ } else if (strncmp(argv[i], "disk=",
+ strlen("disk=")) == 0) {
+ if (usermode_disk_image_path_count ==
+ MAX_DISK_IMAGES) {
+ printf("too many disk images "
+ "(increase MAX_DISK_IMAGES)\n");
+ usage(argv[0]);
+ return;
+ }
+ usermode_disk_image_path[
+ usermode_disk_image_path_count++] =
+ argv[i] + strlen("disk=");
} else {
- usermode_root_image_path = argv[i];
+ printf("%s: unknown parameter\n", argv[i]);
+ usage(argv[0]);
+ return;
}
continue;
}