]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Add a new config option for all backend drivers. This has two benefits:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 10 Apr 2006 17:33:04 +0000 (18:33 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 10 Apr 2006 17:33:04 +0000 (18:33 +0100)
 1. All backend drivers can be disabled or modularised via
    one config option.
 2. Backend helper routines that are not specific to any particular driver
    can be disabled or modularised based on this config option. In
    particular this may allow backend drivers plus the service module
    to be upgraded separate from the kernel core as and when the backend
    interfaces change (and they will).

Signed-off-by: Keir Fraser <keir@xensource.com>
14 files changed:
buildconfigs/linux-defconfig_xen0_ia64
buildconfigs/linux-defconfig_xen0_x86_32
buildconfigs/linux-defconfig_xen0_x86_64
buildconfigs/linux-defconfig_xenU_ia64
buildconfigs/linux-defconfig_xenU_x86_32
buildconfigs/linux-defconfig_xenU_x86_64
buildconfigs/linux-defconfig_xen_ia64
buildconfigs/linux-defconfig_xen_x86_32
buildconfigs/linux-defconfig_xen_x86_64
linux-2.6-xen-sparse/arch/ia64/Kconfig
linux-2.6-xen-sparse/drivers/xen/Kconfig
linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c [new file with mode: 0644]
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c

index 2dbb12644ee53597927f256185e631960c19a032..b77e462d8d7db72043578e8f8c05bafe6f036e10 100644 (file)
@@ -95,6 +95,7 @@ CONFIG_ARCH_XEN=y
 CONFIG_XEN_PRIVILEGED_GUEST=y
 CONFIG_XEN_BLKDEV_GRANT=y
 CONFIG_XEN_BLKDEV_FRONTEND=y
+CONFIG_XEN_BACKEND=y
 CONFIG_XEN_BLKDEV_BACKEND=y
 CONFIG_XEN_SYSFS=y
 CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
index 89f700682f8a9c9467923c77f870c5e543c5bf75..4069eb41e335cb8398bec31e3c9ba3d77078296c 100644 (file)
@@ -1312,6 +1312,7 @@ CONFIG_NO_IDLE_HZ=y
 #
 CONFIG_XEN_PRIVILEGED_GUEST=y
 # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
+CONFIG_XEN_BACKEND=y
 CONFIG_XEN_PCIDEV_BACKEND=y
 # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
 CONFIG_XEN_PCIDEV_BACKEND_PASS=y
index 04e992076d725ca42600cb5b01c98f1f4409b7ba..72c2ffe2a1e6d38fbd7909fdaa3f80bde98d65b5 100644 (file)
@@ -1238,6 +1238,7 @@ CONFIG_NO_IDLE_HZ=y
 #
 CONFIG_XEN_PRIVILEGED_GUEST=y
 # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
+CONFIG_XEN_BACKEND=y
 CONFIG_XEN_PCIDEV_BACKEND=y
 # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
 CONFIG_XEN_PCIDEV_BACKEND_PASS=y
index da7a4e5b0cfa725492a11bfd4ec9ad781960c930..d1d330b8ef62d2e56b144ebb589f76992be83143 100644 (file)
@@ -92,6 +92,7 @@ CONFIG_ARCH_XEN=y
 CONFIG_XEN_PRIVILEGED_GUEST=y
 CONFIG_XEN_BLKDEV_GRANT=y
 CONFIG_XEN_BLKDEV_FRONTEND=y
+CONFIG_XEN_BACKEND=y
 CONFIG_XEN_BLKDEV_BACKEND=y
 CONFIG_XEN_SYSFS=y
 CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
index 077c626ca3ed8dd1b142447e3a676ddcfca45c67..6ba62af70ff3e5b0290793463f1315d91a76529c 100644 (file)
@@ -858,13 +858,9 @@ CONFIG_NO_IDLE_HZ=y
 #
 # CONFIG_XEN_PRIVILEGED_GUEST is not set
 CONFIG_XEN_UNPRIVILEGED_GUEST=y
-# CONFIG_XEN_PCIDEV_BACKEND is not set
-# CONFIG_XEN_BLKDEV_BACKEND is not set
-# CONFIG_XEN_NETDEV_BACKEND is not set
-# CONFIG_XEN_TPMDEV_BACKEND is not set
+# CONFIG_XEN_BACKEND is not set
 CONFIG_XEN_BLKDEV_FRONTEND=y
 CONFIG_XEN_NETDEV_FRONTEND=y
-# CONFIG_XEN_BLKDEV_TAP is not set
 # CONFIG_XEN_TPMDEV_FRONTEND is not set
 CONFIG_XEN_SCRUB_PAGES=y
 CONFIG_XEN_DISABLE_SERIAL=y
index 68893b915e8282e7897db06c936c714369657340..5b61581ddfb96425e7047077b54ea0a3dfa42e3f 100644 (file)
@@ -1135,13 +1135,9 @@ CONFIG_NO_IDLE_HZ=y
 #
 # CONFIG_XEN_PRIVILEGED_GUEST is not set
 CONFIG_XEN_UNPRIVILEGED_GUEST=y
-# CONFIG_XEN_PCIDEV_BACKEND is not set
-# CONFIG_XEN_BLKDEV_BACKEND is not set
-# CONFIG_XEN_NETDEV_BACKEND is not set
-# CONFIG_XEN_TPMDEV_BACKEND is not set
+# CONFIG_XEN_BACKEND is not set
 CONFIG_XEN_BLKDEV_FRONTEND=y
 CONFIG_XEN_NETDEV_FRONTEND=y
-# CONFIG_XEN_BLKDEV_TAP is not set
 # CONFIG_XEN_TPMDEV_FRONTEND is not set
 CONFIG_XEN_SCRUB_PAGES=y
 CONFIG_XEN_DISABLE_SERIAL=y
index 6592742e37b8e196aebe54d23d86c800e26f5788..3c3c6e520621fcda1b94db115e2d5af8b2a70eef 100644 (file)
@@ -95,6 +95,7 @@ CONFIG_ARCH_XEN=y
 CONFIG_XEN_PRIVILEGED_GUEST=y
 CONFIG_XEN_BLKDEV_GRANT=y
 CONFIG_XEN_BLKDEV_FRONTEND=y
+CONFIG_XEN_BACKEND=y
 CONFIG_XEN_BLKDEV_BACKEND=y
 CONFIG_XEN_SYSFS=y
 CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
index bce7cf92c23fc112f5fec5bebe65c9563a5f7341..4488963622db9152beb6493db16b0c7189766624 100644 (file)
@@ -2978,6 +2978,7 @@ CONFIG_NO_IDLE_HZ=y
 #
 CONFIG_XEN_PRIVILEGED_GUEST=y
 # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
+CONFIG_XEN_BACKEND=y
 CONFIG_XEN_PCIDEV_BACKEND=y
 # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
 CONFIG_XEN_PCIDEV_BACKEND_PASS=y
index 8e9738957017d5d1e2c39fb0df1ae37121f693c1..e41ea45b669de5dbfb984cb272a259f023833411 100644 (file)
@@ -2648,6 +2648,7 @@ CONFIG_NO_IDLE_HZ=y
 #
 CONFIG_XEN_PRIVILEGED_GUEST=y
 # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
+CONFIG_XEN_BACKEND=y
 CONFIG_XEN_PCIDEV_BACKEND=y
 # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
 CONFIG_XEN_PCIDEV_BACKEND_PASS=y
index db86da7611cc0f49a5e2987f19e351a7f00ed9b5..4f3c58cb71d5b0e4ad6008cdf3471a9c4924d9ba 100644 (file)
@@ -79,11 +79,16 @@ config XEN_BLKDEV_FRONTEND
        bool
        default y
 
-config XEN_BLKDEV_BACKEND
+config XEN_BACKEND
        depends on XEN
        bool
        default y
 
+config XEN_BLKDEV_BACKEND
+       depends on XEN && XEN_BACKEND
+       bool
+       default y
+
 config XEN_SYSFS
        bool "Export Xen attributes in sysfs"
        depends on XEN && SYSFS
index 6518ff821aaa1518c54e18fd2589f91736cc7d86..0595eb0028c3f8f51a4085cc28e0785685d19d4b 100644 (file)
@@ -28,9 +28,16 @@ config XEN_UNPRIVILEGED_GUEST
        bool
        default !XEN_PRIVILEGED_GUEST
 
+config XEN_BACKEND
+        tristate "Backend driver support"
+        default y
+        help
+          Support for backend device drivers that provide I/O services
+          to other virtual machines.
+
 config XEN_PCIDEV_BACKEND
        tristate "PCI device backend driver"
-       depends PCI
+       depends on PCI && XEN_BACKEND
        default XEN_PRIVILEGED_GUEST
        help
          The PCI device backend driver allows the kernel to export arbitrary
@@ -70,6 +77,7 @@ config XEN_PCIDEV_BE_DEBUG
 
 config XEN_BLKDEV_BACKEND
        tristate "Block-device backend driver"
+        depends on XEN_BACKEND
        default y
        help
          The block-device backend driver allows the kernel to export its
@@ -91,6 +99,7 @@ config XEN_BLKDEV_TAP_BE
 
 config XEN_NETDEV_BACKEND
        tristate "Network-device backend driver"
+        depends on XEN_BACKEND
        default y
        help
          The network-device backend driver allows the kernel to export its
@@ -120,6 +129,7 @@ config XEN_NETDEV_LOOPBACK
 
 config XEN_TPMDEV_BACKEND
        tristate "TPM-device backend driver"
+        depends on XEN_BACKEND
        default n
        help
          The TPM-device backend driver
@@ -155,6 +165,7 @@ config XEN_NETDEV_FRONTEND
 
 config XEN_BLKDEV_TAP
        tristate "Block device tap driver"
+        depends on XEN_BACKEND
        default n
        help
          This driver allows a VM to interact on block device channels
index 4ef620cd7cdbb3d68cf35c4cb7e6e198231a3443..899cc3133db1e6963d38651b42f2aa597f37fd4b 100644 (file)
@@ -1,4 +1,8 @@
 obj-y  += xenbus.o
+obj-$(CONFIG_XEN_BACKEND) += xenbus_be.o
+
+xenbus_be-objs =
+xenbus_be-objs += xenbus_backend_client.o
 
 xenbus-objs =
 xenbus-objs += xenbus_client.o
diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c
new file mode 100644 (file)
index 0000000..72327ec
--- /dev/null
@@ -0,0 +1,173 @@
+/******************************************************************************
+ * Backend-client-facing interface for the Xenbus driver.  In other words, the
+ * interface between the Xenbus and the device-specific code in the backend
+ * driver.
+ *
+ * Copyright (C) 2005-2006 XenSource Ltd
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <xen/gnttab.h>
+#include <xen/xenbus.h>
+#include <xen/driver_util.h>
+
+/* Based on Rusty Russell's skeleton driver's map_page */
+int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
+{
+       struct gnttab_map_grant_ref op = {
+               .flags = GNTMAP_host_map,
+               .ref   = gnt_ref,
+               .dom   = dev->otherend_id,
+       };
+       struct vm_struct *area;
+
+       *vaddr = NULL;
+
+       area = alloc_vm_area(PAGE_SIZE);
+       if (!area)
+               return -ENOMEM;
+
+       op.host_addr = (unsigned long)area->addr;
+
+       lock_vm_area(area);
+       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
+       unlock_vm_area(area);
+
+       if (op.status != GNTST_okay) {
+               free_vm_area(area);
+               xenbus_dev_fatal(dev, op.status,
+                                "mapping in shared page %d from domain %d",
+                                gnt_ref, dev->otherend_id);
+               return op.status;
+       }
+
+       /* Stuff the handle in an unused field */
+       area->phys_addr = (unsigned long)op.handle;
+
+       *vaddr = area->addr;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
+
+
+int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
+                  grant_handle_t *handle, void *vaddr)
+{
+       struct gnttab_map_grant_ref op = {
+               .host_addr = (unsigned long)vaddr,
+               .flags     = GNTMAP_host_map,
+               .ref       = gnt_ref,
+               .dom       = dev->otherend_id,
+       };
+
+       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
+
+       if (op.status != GNTST_okay) {
+               xenbus_dev_fatal(dev, op.status,
+                                "mapping in shared page %d from domain %d",
+                                gnt_ref, dev->otherend_id);
+       } else
+               *handle = op.handle;
+
+       return op.status;
+}
+EXPORT_SYMBOL_GPL(xenbus_map_ring);
+
+
+/* Based on Rusty Russell's skeleton driver's unmap_page */
+int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
+{
+       struct vm_struct *area;
+       struct gnttab_unmap_grant_ref op = {
+               .host_addr = (unsigned long)vaddr,
+       };
+
+       /* It'd be nice if linux/vmalloc.h provided a find_vm_area(void *addr)
+        * method so that we don't have to muck with vmalloc internals here.
+        * We could force the user to hang on to their struct vm_struct from
+        * xenbus_map_ring_valloc, but these 6 lines considerably simplify
+        * this API.
+        */
+       read_lock(&vmlist_lock);
+       for (area = vmlist; area != NULL; area = area->next) {
+               if (area->addr == vaddr)
+                       break;
+       }
+       read_unlock(&vmlist_lock);
+
+       if (!area) {
+               xenbus_dev_error(dev, -ENOENT,
+                                "can't find mapped virtual address %p", vaddr);
+               return GNTST_bad_virt_addr;
+       }
+
+       op.handle = (grant_handle_t)area->phys_addr;
+
+       lock_vm_area(area);
+       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
+       unlock_vm_area(area);
+
+       if (op.status == GNTST_okay)
+               free_vm_area(area);
+       else
+               xenbus_dev_error(dev, op.status,
+                                "unmapping page at handle %d error %d",
+                                (int16_t)area->phys_addr, op.status);
+
+       return op.status;
+}
+EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
+
+
+int xenbus_unmap_ring(struct xenbus_device *dev,
+                    grant_handle_t handle, void *vaddr)
+{
+       struct gnttab_unmap_grant_ref op = {
+               .host_addr = (unsigned long)vaddr,
+               .handle    = handle,
+       };
+
+       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
+
+       if (op.status != GNTST_okay)
+               xenbus_dev_error(dev, op.status,
+                                "unmapping page at handle %d error %d",
+                                handle, op.status);
+
+       return op.status;
+}
+EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
+
+
+/*
+ * Local variables:
+ *  c-file-style: "linux"
+ *  indent-tabs-mode: t
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ *  tab-width: 8
+ * End:
+ */
index 38ac7f2c49b8244c43a117371e83e4fd4552a661..d4059b18c2cfe3e9f4982e05ff5bad812f97df20 100644 (file)
@@ -261,134 +261,6 @@ int xenbus_free_evtchn(struct xenbus_device *dev, int port)
 }
 
 
-/* Based on Rusty Russell's skeleton driver's map_page */
-int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
-{
-       struct gnttab_map_grant_ref op = {
-               .flags = GNTMAP_host_map,
-               .ref   = gnt_ref,
-               .dom   = dev->otherend_id,
-       };
-       struct vm_struct *area;
-
-       *vaddr = NULL;
-
-       area = alloc_vm_area(PAGE_SIZE);
-       if (!area)
-               return -ENOMEM;
-
-       op.host_addr = (unsigned long)area->addr;
-
-       lock_vm_area(area);
-       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
-       unlock_vm_area(area);
-
-       if (op.status != GNTST_okay) {
-               free_vm_area(area);
-               xenbus_dev_fatal(dev, op.status,
-                                "mapping in shared page %d from domain %d",
-                                gnt_ref, dev->otherend_id);
-               return op.status;
-       }
-
-       /* Stuff the handle in an unused field */
-       area->phys_addr = (unsigned long)op.handle;
-
-       *vaddr = area->addr;
-       return 0;
-}
-EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
-
-
-int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
-                  grant_handle_t *handle, void *vaddr)
-{
-       struct gnttab_map_grant_ref op = {
-               .host_addr = (unsigned long)vaddr,
-               .flags     = GNTMAP_host_map,
-               .ref       = gnt_ref,
-               .dom       = dev->otherend_id,
-       };
-
-       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
-
-       if (op.status != GNTST_okay) {
-               xenbus_dev_fatal(dev, op.status,
-                                "mapping in shared page %d from domain %d",
-                                gnt_ref, dev->otherend_id);
-       } else
-               *handle = op.handle;
-
-       return op.status;
-}
-EXPORT_SYMBOL_GPL(xenbus_map_ring);
-
-
-/* Based on Rusty Russell's skeleton driver's unmap_page */
-int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
-{
-       struct vm_struct *area;
-       struct gnttab_unmap_grant_ref op = {
-               .host_addr = (unsigned long)vaddr,
-       };
-
-       /* It'd be nice if linux/vmalloc.h provided a find_vm_area(void *addr)
-        * method so that we don't have to muck with vmalloc internals here.
-        * We could force the user to hang on to their struct vm_struct from
-        * xenbus_map_ring_valloc, but these 6 lines considerably simplify
-        * this API.
-        */
-       read_lock(&vmlist_lock);
-       for (area = vmlist; area != NULL; area = area->next) {
-               if (area->addr == vaddr)
-                       break;
-       }
-       read_unlock(&vmlist_lock);
-
-       if (!area) {
-               xenbus_dev_error(dev, -ENOENT,
-                                "can't find mapped virtual address %p", vaddr);
-               return GNTST_bad_virt_addr;
-       }
-
-       op.handle = (grant_handle_t)area->phys_addr;
-
-       lock_vm_area(area);
-       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
-       unlock_vm_area(area);
-
-       if (op.status == GNTST_okay)
-               free_vm_area(area);
-       else
-               xenbus_dev_error(dev, op.status,
-                                "unmapping page at handle %d error %d",
-                                (int16_t)area->phys_addr, op.status);
-
-       return op.status;
-}
-EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
-
-
-int xenbus_unmap_ring(struct xenbus_device *dev,
-                    grant_handle_t handle, void *vaddr)
-{
-       struct gnttab_unmap_grant_ref op = {
-               .host_addr = (unsigned long)vaddr,
-               .handle    = handle,
-       };
-
-       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
-
-       if (op.status != GNTST_okay)
-               xenbus_dev_error(dev, op.status,
-                                "unmapping page at handle %d error %d",
-                                handle, op.status);
-
-       return op.status;
-}
-EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
-
-
 XenbusState xenbus_read_driver_state(const char *path)
 {
        XenbusState result;