Skip to content

Commit

Permalink
xen: Add xenbus device driver
Browse files Browse the repository at this point in the history
Access to xenbus is currently handled via xenfs. This adds a device
driver for xenbus and makes xenfs use this code.

Signed-off-by: Bastian Blank <waldi@debian.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Bastian Blank authored and Konrad Rzeszutek Wilk committed Dec 16, 2011
1 parent d8414d3 commit 2fb3683
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
1 change: 1 addition & 0 deletions drivers/xen/xenbus/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
obj-y += xenbus.o
obj-y += xenbus_dev_frontend.o

xenbus-objs =
xenbus-objs += xenbus_client.o
Expand Down
4 changes: 4 additions & 0 deletions drivers/xen/xenbus/xenbus_comms.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#ifndef _XENBUS_COMMS_H
#define _XENBUS_COMMS_H

#include <linux/fs.h>

int xs_init(void);
int xb_init_comms(void);

Expand All @@ -43,4 +45,6 @@ int xs_input_avail(void);
extern struct xenstore_domain_interface *xen_store_interface;
extern int xen_store_evtchn;

extern const struct file_operations xen_xenbus_fops;

#endif /* _XENBUS_COMMS_H */
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@
#include <linux/namei.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/miscdevice.h>
#include <linux/module.h>

#include "xenfs.h"
#include "../xenbus/xenbus_comms.h"
#include "xenbus_comms.h"

#include <xen/xenbus.h>
#include <asm/xen/hypervisor.h>

MODULE_LICENSE("GPL");

/*
* An element of a list of outstanding transactions, for which we're
* still waiting a reply.
Expand Down Expand Up @@ -583,11 +586,39 @@ static unsigned int xenbus_file_poll(struct file *file, poll_table *wait)
return 0;
}

const struct file_operations xenbus_file_ops = {
const struct file_operations xen_xenbus_fops = {
.read = xenbus_file_read,
.write = xenbus_file_write,
.open = xenbus_file_open,
.release = xenbus_file_release,
.poll = xenbus_file_poll,
.llseek = no_llseek,
};
EXPORT_SYMBOL_GPL(xen_xenbus_fops);

static struct miscdevice xenbus_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "xen/xenbus",
.fops = &xen_xenbus_fops,
};

static int __init xenbus_init(void)
{
int err;

if (!xen_domain())
return -ENODEV;

err = misc_register(&xenbus_dev);
if (err)
printk(KERN_ERR "Could not register xenbus device\n");
return err;
}

static void __exit xenbus_exit(void)
{
misc_deregister(&xenbus_dev);
}

module_init(xenbus_init);
module_exit(xenbus_exit);
2 changes: 1 addition & 1 deletion drivers/xen/xenfs/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
obj-$(CONFIG_XENFS) += xenfs.o

xenfs-y = super.o xenbus.o
xenfs-y = super.o
xenfs-$(CONFIG_XEN_DOM0) += xenstored.o
3 changes: 2 additions & 1 deletion drivers/xen/xenfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "xenfs.h"
#include "../privcmd.h"
#include "../xenbus/xenbus_comms.h"

#include <asm/xen/hypervisor.h>

Expand Down Expand Up @@ -83,7 +84,7 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
{
static struct tree_descr xenfs_files[] = {
[1] = {},
{ "xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR },
{ "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
{ "capabilities", &capabilities_file_ops, S_IRUGO },
{ "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
{""},
Expand Down
1 change: 0 additions & 1 deletion drivers/xen/xenfs/xenfs.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef _XENFS_XENBUS_H
#define _XENFS_XENBUS_H

extern const struct file_operations xenbus_file_ops;
extern const struct file_operations xsd_kva_file_ops;
extern const struct file_operations xsd_port_file_ops;

Expand Down

0 comments on commit 2fb3683

Please sign in to comment.