Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode support multiple disk images (pass multipl...



details:   https://anonhg.NetBSD.org/src/rev/4766e02237e0
branches:  trunk
changeset: 772535:4766e02237e0
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Jan 07 18:10:18 2012 +0000

description:
support multiple disk images (pass multiple disk=<path> parameters on the
command-line). while changing command-line params, rename tap= option to
net=

diffstat:

 sys/arch/usermode/conf/GENERIC.common |   6 ++--
 sys/arch/usermode/dev/mainbus.c       |  12 +++++---
 sys/arch/usermode/usermode/machdep.c  |  49 +++++++++++++++++++++++++----------
 3 files changed, 45 insertions(+), 22 deletions(-)

diffs (176 lines):

diff -r ef8bda6402be -r 4766e02237e0 sys/arch/usermode/conf/GENERIC.common
--- a/sys/arch/usermode/conf/GENERIC.common     Sat Jan 07 18:08:35 2012 +0000
+++ b/sys/arch/usermode/conf/GENERIC.common     Sat Jan 07 18:10:18 2012 +0000
@@ -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 @@
 cpu0           at mainbus?
 clock0         at mainbus?
 ttycons0       at mainbus?
-ld0            at mainbus?
+ld*            at mainbus?
 veth0          at mainbus?
 vaudio0                at mainbus?
 audio0         at vaudio0
diff -r ef8bda6402be -r 4766e02237e0 sys/arch/usermode/dev/mainbus.c
--- a/sys/arch/usermode/dev/mainbus.c   Sat Jan 07 18:08:35 2012 +0000
+++ b/sys/arch/usermode/dev/mainbus.c   Sat Jan 07 18:10:18 2012 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
 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_softc_t *sc = device_private(self);
        struct thunkbus_attach_args taa;
+       int i;
 
        aprint_naive("\n");
        aprint_normal("\n");
@@ -104,9 +106,9 @@
                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);
        }
 }
diff -r ef8bda6402be -r 4766e02237e0 sys/arch/usermode/usermode/machdep.c
--- a/sys/arch/usermode/usermode/machdep.c      Sat Jan 07 18:08:35 2012 +0000
+++ b/sys/arch/usermode/usermode/machdep.c      Sat Jan 07 18:10:18 2012 +0000
@@ -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 <reinoud%netbsd.org@localhost>
@@ -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 @@
 #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 @@
 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 @@
 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 @@
 
        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 @@
                                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;
                }



Home | Main Index | Thread Index | Old Index