|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/2] xenstored: Use xenbus_backend device on Linux
xenstored: Use xenbus_backend device on Linux
This patch is done on top of 4.1 for now. The kernel part is already
merged.
diff -r 1c89f7d29fbb tools/include/xen-sys/Linux/xenbus_dev.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/include/xen-sys/Linux/xenbus_dev.h Sat Dec 10 19:38:54 2011 +0100
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * evtchn.h
+ *
+ * Interface to /dev/xen/xenbus_backend.
+ *
+ * Copyright (c) 2011 Bastian Blank <waldi@xxxxxxxxxx>
+ *
+ * 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.
+ */
+
+#ifndef __LINUX_XEN_XENBUS_DEV_H__
+#define __LINUX_XEN_XENBUS_DEV_H__
+
+#include <linux/ioctl.h>
+
+#define IOCTL_XENBUS_BACKEND_EVTCHN \
+ _IOC(_IOC_NONE, 'B', 0, 0)
+
+#endif /* __LINUX_XEN_XENBUS_DEV_H__ */
diff -r 1c89f7d29fbb tools/xenstore/xenstored_linux.c
--- a/tools/xenstore/xenstored_linux.c Thu Dec 08 16:50:28 2011 +0000
+++ b/tools/xenstore/xenstored_linux.c Sat Dec 10 19:38:54 2011 +0100
@@ -11,17 +11,22 @@
* License.
*/
+#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
+#include <sys/ioctl.h>
#include <sys/mman.h>
+#include <xen/sys/xenbus_dev.h>
+
#include "xenstored_core.h"
+#define XENSTORED_DEV "/dev/xen/xenbus_backend"
#define XENSTORED_PROC_KVA "/proc/xen/xsd_kva"
#define XENSTORED_PROC_PORT "/proc/xen/xsd_port"
-evtchn_port_t xenbus_evtchn(void)
+static evtchn_port_t xenbus_proc_evtchn(void)
{
int fd;
int rc;
@@ -48,12 +53,35 @@
return port;
}
+evtchn_port_t xenbus_evtchn(void)
+{
+ int fd;
+ long ret;
+
+ fd = open(XENSTORED_DEV, O_RDONLY);
+ if (fd == -1)
+ {
+ if (errno == ENOENT)
+ return xenbus_proc_evtchn();
+ return -1;
+ }
+
+ ret = ioctl(fd, IOCTL_XENBUS_BACKEND_EVTCHN);
+ if (ret == -1)
+ return -1;
+
+ close(fd);
+ return ret;
+}
+
void *xenbus_map(void)
{
int fd;
void *addr;
- fd = open(XENSTORED_PROC_KVA, O_RDWR);
+ fd = open(XENSTORED_DEV, O_RDWR);
+ if (fd == -1 && errno == ENOENT)
+ fd = open(XENSTORED_PROC_KVA, O_RDWR);
if (fd == -1)
return NULL;
--
Killing is wrong.
-- Losira, "That Which Survives", stardate unknown
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |