1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
$NetBSD: patch-ac,v 1.3 2005/07/13 01:28:37 grant Exp $
--- python/xen/lowlevel/xu/xu.c.orig 2005-05-22 20:56:26.000000000 +1000
+++ python/xen/lowlevel/xu/xu.c
@@ -15,7 +15,9 @@
#include <sys/socket.h>
#include <sys/mman.h>
#include <sys/poll.h>
+#ifndef __NetBSD__
#include <sys/sysmacros.h>
+#endif
#include <netinet/in.h>
#include <fcntl.h>
#include <unistd.h>
@@ -25,7 +27,11 @@
#include <xen/xen.h>
#include <xen/io/domain_controller.h>
+#ifdef __NetBSD__
+#include <xen/NetBSD/xenio.h>
+#else
#include <xen/linux/privcmd.h>
+#endif
#define XENPKG "xen.lowlevel.xu"
@@ -35,6 +41,9 @@
#endif
/* NB. The following should be kept in sync with the kernel's evtchn driver. */
+#ifdef __NetBSD__
+#define EVTCHN_DEV_NAME "/dev/xenevt"
+#else
#define EVTCHN_DEV_NAME "/dev/xen/evtchn"
#define EVTCHN_DEV_MAJOR 10
#define EVTCHN_DEV_MINOR 201
@@ -45,6 +54,7 @@
#define EVTCHN_BIND _IO('E', 2)
/* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
#define EVTCHN_UNBIND _IO('E', 3)
+#endif
/* Size of a machine page frame. */
#define PAGE_SIZE 4096
@@ -130,7 +140,11 @@ static PyObject *xu_notifier_bind(PyObje
if ( !PyArg_ParseTuple(args, "i", &idx) )
return NULL;
+#ifdef __NetBSD__
+ if ( ioctl(xun->evtchn_fd, EVTCHN_BIND, &idx) != 0 )
+#else
if ( ioctl(xun->evtchn_fd, EVTCHN_BIND, idx) != 0 )
+#endif
return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None);
@@ -145,7 +159,11 @@ static PyObject *xu_notifier_unbind(PyOb
if ( !PyArg_ParseTuple(args, "i", &idx) )
return NULL;
+#ifdef __NetBSD__
+ if ( ioctl(xun->evtchn_fd, EVTCHN_UNBIND, &idx) != 0 )
+#else
if ( ioctl(xun->evtchn_fd, EVTCHN_UNBIND, idx) != 0 )
+#endif
return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None);
@@ -192,13 +210,16 @@ staticforward PyTypeObject xu_notifier_t
static PyObject *xu_notifier_new(PyObject *self, PyObject *args)
{
xu_notifier_object *xun;
+#ifndef __NetBSD__
struct stat st;
+#endif
if ( !PyArg_ParseTuple(args, "") )
return NULL;
xun = PyObject_New(xu_notifier_object, &xu_notifier_type);
+#ifndef __NetBSD__
/* Make sure any existing device file links to correct device. */
if ( (lstat(EVTCHN_DEV_NAME, &st) != 0) ||
!S_ISCHR(st.st_mode) ||
@@ -206,14 +227,17 @@ static PyObject *xu_notifier_new(PyObjec
(void)unlink(EVTCHN_DEV_NAME);
reopen:
+#endif
xun->evtchn_fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR);
if ( xun->evtchn_fd == -1 )
{
+#ifndef __NetBSD__
if ( (errno == ENOENT) &&
((mkdir("/dev/xen", 0755) == 0) || (errno == EEXIST)) &&
(mknod(EVTCHN_DEV_NAME, S_IFCHR|0600,
makedev(EVTCHN_DEV_MAJOR,EVTCHN_DEV_MINOR)) == 0) )
goto reopen;
+#endif
PyObject_Del((PyObject *)xun);
return PyErr_SetFromErrno(PyExc_IOError);
}
@@ -1110,7 +1134,8 @@ static PyObject *xu_port_new(PyObject *s
* The control-interface event channel for DOM0 is already set up.
* We use an ioctl to discover the port at our end of the channel.
*/
- port1 = ioctl(xup->xc_handle, IOCTL_PRIVCMD_INITDOMAIN_EVTCHN, NULL);
+ if (ioctl(xup->xc_handle, IOCTL_PRIVCMD_INITDOMAIN_EVTCHN, &port1))
+ port1 = -1;
port2 = -1; /* We don't need the remote end of the DOM0 link. */
if ( port1 < 0 )
{
|