Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/xen Allow the block device driver to impersonate wd...



details:   https://anonhg.NetBSD.org/src/rev/d6509e88a8c6
branches:  trunk
changeset: 565973:d6509e88a8c6
user:      cl <cl%NetBSD.org@localhost>
date:      Sat Apr 24 20:05:49 2004 +0000

description:
Allow the block device driver to impersonate wd/sd/cd devices.  This allows
for most system seamless migration from a NetBSD/i386 setup to a NetBSD/xen
setup without changing /etc/fstab or creating additional device nodes.

diffstat:

 sys/arch/xen/conf/GENERIC     |    9 +-
 sys/arch/xen/conf/XEN         |    7 +-
 sys/arch/xen/conf/files.xen   |   16 +-
 sys/arch/xen/include/xbdvar.h |    3 +-
 sys/arch/xen/xen/xbd.c        |  321 +++++++++++++++++++++++++++++++++++++----
 5 files changed, 310 insertions(+), 46 deletions(-)

diffs (truncated from 612 to 300 lines):

diff -r 0c432de54a81 -r d6509e88a8c6 sys/arch/xen/conf/GENERIC
--- a/sys/arch/xen/conf/GENERIC Sat Apr 24 19:59:19 2004 +0000
+++ b/sys/arch/xen/conf/GENERIC Sat Apr 24 20:05:49 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.4 2004/04/24 18:24:14 cl Exp $
+# $NetBSD: GENERIC,v 1.5 2004/04/24 20:05:49 cl Exp $
 # NetBSD: GENERIC,v 1.596 2004/04/07 13:13:59 augustss Exp 
 #
 # GENERIC machine description file
@@ -23,7 +23,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.4 $"
+#ident                 "GENERIC-$Revision: 1.5 $"
 
 maxusers       32              # estimated number of users
 
@@ -187,7 +187,7 @@
 
 # Kernel root file system and dump configuration.
 config         netbsd  root on ? type ?
-#config                netbsd  root on xbd0a type ffs
+#config                netbsd  root on wd0a type ffs
 #config                netbsd  root on ? type nfs
 
 #
@@ -206,6 +206,9 @@
 xennet*        at hypervisor?          # Xen virtual network interface
 
 xbd*           at hypervisor?          # Xen virtual block device
+wd*            at hypervisor?          # Xen vbd (wd identity)
+sd*            at hypervisor?          # Xen vbd (sd identity)
+cd*            at hypervisor?          # Xen vbd (cd identity)
 
 
 # Pull in optional local configuration
diff -r 0c432de54a81 -r d6509e88a8c6 sys/arch/xen/conf/XEN
--- a/sys/arch/xen/conf/XEN     Sat Apr 24 19:59:19 2004 +0000
+++ b/sys/arch/xen/conf/XEN     Sat Apr 24 20:05:49 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: XEN,v 1.4 2004/04/24 18:24:14 cl Exp $
+# $NetBSD: XEN,v 1.5 2004/04/24 20:05:49 cl Exp $
 
 include        "arch/xen/conf/std.xen"
 
@@ -108,7 +108,7 @@
 #options       NFS_BOOTSTATIC_SERVER="\"server:/path/to/root\""
 
 config         netbsd  root on ? type ?
-#config                netbsd  root on xbd0a type ffs
+#config                netbsd  root on wd0a type ffs
 #config                netbsd  root on xennet0 type nfs
 
 mainbus0 at root
@@ -123,6 +123,9 @@
 xennet*        at hypervisor?          # Xen virtual network interface
 
 xbd*           at hypervisor?          # Xen virtual block device
+wd*            at hypervisor?          # Xen vbd (wd identity)
+sd*            at hypervisor?          # Xen vbd (sd identity)
+cd*            at hypervisor?          # Xen vbd (cd identity)
 
 
 include        "arch/xen/conf/GENERIC.local"
diff -r 0c432de54a81 -r d6509e88a8c6 sys/arch/xen/conf/files.xen
--- a/sys/arch/xen/conf/files.xen       Sat Apr 24 19:59:19 2004 +0000
+++ b/sys/arch/xen/conf/files.xen       Sat Apr 24 20:05:49 2004 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.xen,v 1.7 2004/04/24 19:18:01 cl Exp $
+#      $NetBSD: files.xen,v 1.8 2004/04/24 20:05:49 cl Exp $
 #      NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp 
 #      NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp 
 
@@ -192,12 +192,24 @@
 
 # Xen devices
 
+# Network driver
 device xennet: arp, ether, ifnet
 attach xennet at hypervisor
 file   arch/xen/xen/if_xennet.c        xennet needs-flag
 
+# Block device driver and wd/sd/cd identities
 device xbd: disk
 attach xbd at hypervisor
-file   arch/xen/xen/xbd.c              xbd needs-flag
+file   arch/xen/xen/xbd.c              xbd | wd | sd | cd needs-flag
+
+device wd: disk
+attach wd at hypervisor
+
+device sd: disk
+attach sd at hypervisor
+
+device cd: disk
+attach cd at hypervisor
+
 
 include "arch/xen/conf/majors.i386"
diff -r 0c432de54a81 -r d6509e88a8c6 sys/arch/xen/include/xbdvar.h
--- a/sys/arch/xen/include/xbdvar.h     Sat Apr 24 19:59:19 2004 +0000
+++ b/sys/arch/xen/include/xbdvar.h     Sat Apr 24 20:05:49 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xbdvar.h,v 1.2 2004/04/24 17:35:27 cl Exp $ */
+/* $NetBSD: xbdvar.h,v 1.3 2004/04/24 20:05:49 cl Exp $ */
 
 /*
  *
@@ -46,6 +46,7 @@
 struct xbd_attach_args {
        const char              *xa_device;
        int                     xa_disk;
+       struct dk_intf          *xa_dkintf;
 };
 
 int xbd_scan(struct device *, struct xbd_attach_args *, cfprint_t);
diff -r 0c432de54a81 -r d6509e88a8c6 sys/arch/xen/xen/xbd.c
--- a/sys/arch/xen/xen/xbd.c    Sat Apr 24 19:59:19 2004 +0000
+++ b/sys/arch/xen/xen/xbd.c    Sat Apr 24 20:05:49 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xbd.c,v 1.4 2004/04/24 19:32:37 cl Exp $ */
+/* $NetBSD: xbd.c,v 1.5 2004/04/24 20:05:49 cl Exp $ */
 
 /*
  *
@@ -33,7 +33,9 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.4 2004/04/24 19:32:37 cl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.5 2004/04/24 20:05:49 cl Exp $");
+
+#include "xbd.h"
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -52,6 +54,7 @@
 #include <sys/lock.h>
 #include <sys/conf.h>
 #include <sys/queue.h>
+#include <sys/stat.h>
 
 #include <uvm/uvm.h>
 
@@ -64,38 +67,115 @@
 #include <machine/events.h>
 
 
-int xbd_match(struct device *, struct cfdata *, void *);
 void xbd_attach(struct device *, struct device *, void *);
 
+#if NXBD > 0
+int xbd_match(struct device *, struct cfdata *, void *);
 CFATTACH_DECL(xbd, sizeof(struct xbd_softc),
     xbd_match, xbd_attach, NULL, NULL);
 
 extern struct cfdriver xbd_cd;
+#endif
+
+#if NWD > 0
+int xbd_wd_match(struct device *, struct cfdata *, void *);
+CFATTACH_DECL(wd, sizeof(struct xbd_softc),
+    xbd_wd_match, xbd_attach, NULL, NULL);
+
+extern struct cfdriver wd_cd;
+#endif
+
+#if NSD > 0
+int xbd_sd_match(struct device *, struct cfdata *, void *);
+CFATTACH_DECL(sd, sizeof(struct xbd_softc),
+    xbd_sd_match, xbd_attach, NULL, NULL);
+
+extern struct cfdriver sd_cd;
+#endif
+
+#if NCD > 0
+int xbd_cd_match(struct device *, struct cfdata *, void *);
+CFATTACH_DECL(cd, sizeof(struct xbd_softc),
+    xbd_cd_match, xbd_attach, NULL, NULL);
+
+extern struct cfdriver cd_cd;
+#endif
+
 
 dev_type_open(xbdopen);
 dev_type_close(xbdclose);
 dev_type_read(xbdread);
 dev_type_write(xbdwrite);
 dev_type_ioctl(xbdioctl);
+dev_type_ioctl(xbdioctl_cdev);
 dev_type_strategy(xbdstrategy);
 dev_type_dump(xbddump);
 dev_type_size(xbdsize);
 
+#if NXBD > 0
 const struct bdevsw xbd_bdevsw = {
        xbdopen, xbdclose, xbdstrategy, xbdioctl,
        xbddump, xbdsize, D_DISK
 };
 
 const struct cdevsw xbd_cdevsw = {
-       xbdopen, xbdclose, xbdread, xbdwrite, xbdioctl,
+       xbdopen, xbdclose, xbdread, xbdwrite, xbdioctl_cdev,
+       nostop, notty, nopoll, nommap, nokqfilter, D_DISK
+};
+
+static dev_t xbd_major;
+#endif
+
+#if NWD > 0
+const struct bdevsw wd_bdevsw = {
+       xbdopen, xbdclose, xbdstrategy, xbdioctl,
+       xbddump, xbdsize, D_DISK
+};
+
+const struct cdevsw wd_cdevsw = {
+       xbdopen, xbdclose, xbdread, xbdwrite, xbdioctl_cdev,
        nostop, notty, nopoll, nommap, nokqfilter, D_DISK
 };
 
+static dev_t xbd_wd_major;
+static dev_t xbd_wd_cdev_major;
+#endif
+
+#if NSD > 0
+const struct bdevsw sd_bdevsw = {
+       xbdopen, xbdclose, xbdstrategy, xbdioctl,
+       xbddump, xbdsize, D_DISK
+};
+
+const struct cdevsw sd_cdevsw = {
+       xbdopen, xbdclose, xbdread, xbdwrite, xbdioctl_cdev,
+       nostop, notty, nopoll, nommap, nokqfilter, D_DISK
+};
+
+static dev_t xbd_sd_major;
+static dev_t xbd_sd_cdev_major;
+#endif
+
+#if NCD > 0
+const struct bdevsw cd_bdevsw = {
+       xbdopen, xbdclose, xbdstrategy, xbdioctl,
+       xbddump, xbdsize, D_DISK
+};
+
+const struct cdevsw cd_cdevsw = {
+       xbdopen, xbdclose, xbdread, xbdwrite, xbdioctl_cdev,
+       nostop, notty, nopoll, nommap, nokqfilter, D_DISK
+};
+
+static dev_t xbd_cd_major;
+static dev_t xbd_cd_cdev_major;
+#endif
+
 
 static int     xbdstart(struct dk_softc *, struct buf *);
 static int     xbd_response_handler(void *);
 
-static int     xbdinit(struct xbd_softc *, xen_disk_t *);
+static int     xbdinit(struct xbd_softc *, xen_disk_t *, struct dk_intf *);
 
 /* Pseudo-disk Interface */
 static struct dk_intf dkintf_esdi = {
@@ -106,6 +186,7 @@
        xbdstrategy,
        xbdstart,
 };
+#if NSD > 0
 static struct dk_intf dkintf_scsi = {
        DTYPE_SCSI,
        "Xen Virtual SCSI",
@@ -114,6 +195,35 @@
        xbdstrategy,
        xbdstart,
 };
+#endif
+
+#if NXBD > 0
+static struct xbd_attach_args xbd_ata = {
+       .xa_device = "xbd",
+       .xa_dkintf = &dkintf_esdi,
+};
+#endif
+
+#if NWD > 0
+static struct xbd_attach_args wd_ata = {
+       .xa_device = "wd",
+       .xa_dkintf = &dkintf_esdi,
+};
+#endif
+
+#if NSD > 0
+static struct xbd_attach_args sd_ata = {
+       .xa_device = "sd",
+       .xa_dkintf = &dkintf_scsi,
+};
+#endif
+
+#if NCD > 0



Home | Main Index | Thread Index | Old Index