mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
libxc: osdep: convert do_xen_hypercall()
do_privcmd() was only ever used by do_xen_hypercall() so remove it. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson.citrix.com>
This commit is contained in:
1 parent
02e4f47747
commit
2e04f9622f
6 files changed
+73
-66
No files matched your search
+10
-11
@@ -75,6 +75,12 @@ static int linux_privcmd_close(xc_interface *xch, xc_osdep_handle h)
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
static int linux_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, privcmd_hypercall_t *hypercall)
|
||||
{
|
||||
int fd = (int)h;
|
||||
return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
|
||||
}
|
||||
|
||||
static int xc_map_foreign_batch_single(xc_interface *xch, uint32_t dom,
|
||||
xen_pfn_t *mfn, unsigned long addr)
|
||||
{
|
||||
@@ -316,20 +322,13 @@ void *xc_map_foreign_ranges(xc_interface *xch, uint32_t dom, size_t size, int pr
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int do_privcmd(xc_interface *xch, int cmd, unsigned long data)
|
||||
{
|
||||
return ioctl(xch->fd, cmd, data);
|
||||
}
|
||||
|
||||
int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
|
||||
{
|
||||
return do_privcmd(xch, IOCTL_PRIVCMD_HYPERCALL,
|
||||
(unsigned long)hypercall);
|
||||
}
|
||||
|
||||
static struct xc_osdep_ops linux_privcmd_ops = {
|
||||
.open = &linux_privcmd_open,
|
||||
.close = &linux_privcmd_close,
|
||||
|
||||
.u.privcmd = {
|
||||
.hypercall = &linux_privcmd_hypercall,
|
||||
},
|
||||
};
|
||||
|
||||
#define DEVXEN "/dev/xen/"
|
||||
|
||||
+26
-22
@@ -71,6 +71,28 @@ void minios_interface_close_fd(int fd)
|
||||
files[fd].type = FTYPE_NONE;
|
||||
}
|
||||
|
||||
static int minios_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, privcmd_hypercall_t *hypercall)
|
||||
{
|
||||
multicall_entry_t call;
|
||||
int i, ret;
|
||||
|
||||
call.op = hypercall->op;
|
||||
for (i = 0; i < sizeof(hypercall->arg) / sizeof(*hypercall->arg); i++)
|
||||
call.args[i] = hypercall->arg[i];
|
||||
|
||||
ret = HYPERVISOR_multicall(&call, 1);
|
||||
|
||||
if (ret < 0) {
|
||||
errno = -ret;
|
||||
return -1;
|
||||
}
|
||||
if ((long) call.result < 0) {
|
||||
errno = - (long) call.result;
|
||||
return -1;
|
||||
}
|
||||
return call.result;
|
||||
}
|
||||
|
||||
void *xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot,
|
||||
const xen_pfn_t *arr, int *err, unsigned int num)
|
||||
{
|
||||
@@ -157,31 +179,13 @@ void *xc_map_foreign_ranges(xc_interface *xch, uint32_t dom,
|
||||
}
|
||||
|
||||
|
||||
int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
|
||||
{
|
||||
multicall_entry_t call;
|
||||
int i, ret;
|
||||
|
||||
call.op = hypercall->op;
|
||||
for (i = 0; i < sizeof(hypercall->arg) / sizeof(*hypercall->arg); i++)
|
||||
call.args[i] = hypercall->arg[i];
|
||||
|
||||
ret = HYPERVISOR_multicall(&call, 1);
|
||||
|
||||
if (ret < 0) {
|
||||
errno = -ret;
|
||||
return -1;
|
||||
}
|
||||
if ((long) call.result < 0) {
|
||||
errno = - (long) call.result;
|
||||
return -1;
|
||||
}
|
||||
return call.result;
|
||||
}
|
||||
|
||||
static struct xc_osdep_ops minios_privcmd_ops = {
|
||||
.open = &minios_privcmd_open,
|
||||
.close = &minios_privcmd_close,
|
||||
|
||||
.u.privcmd = {
|
||||
.hypercall = &minios_privcmd_hypercall,
|
||||
},
|
||||
};
|
||||
|
||||
static xc_osdep_handle minios_evtchn_open(xc_evtchn *xce)
|
||||
|
||||
+15
-21
@@ -68,6 +68,17 @@ static int netbsd_privcmd_close(xc_interface *xch, xc_osdep_handle h)
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
static int netbsd_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, privcmd_hypercall_t *hypercall)
|
||||
{
|
||||
int fd = (int)h;
|
||||
int error = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
|
||||
|
||||
if (error < 0)
|
||||
return -errno;
|
||||
else
|
||||
return hypercall->retval;
|
||||
}
|
||||
|
||||
void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
|
||||
xen_pfn_t *arr, int num)
|
||||
{
|
||||
@@ -161,30 +172,13 @@ mmap_failed:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static int do_privcmd(xc_interface *xch, unsigned int cmd, unsigned long data)
|
||||
{
|
||||
int err = ioctl(xch->fd, cmd, data);
|
||||
if (err == 0)
|
||||
return 0;
|
||||
else
|
||||
return -errno;
|
||||
}
|
||||
|
||||
int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
|
||||
{
|
||||
int error = do_privcmd(xch,
|
||||
IOCTL_PRIVCMD_HYPERCALL,
|
||||
(unsigned long)hypercall);
|
||||
if (error)
|
||||
return error;
|
||||
else
|
||||
return (hypercall->retval);
|
||||
}
|
||||
|
||||
static struct xc_osdep_ops netbsd_privcmd_ops = {
|
||||
.open = &netbsd_privcmd_open,
|
||||
.close = &netbsd_privcmd_close,
|
||||
|
||||
.u.privcmd = {
|
||||
.hypercall = &netbsd_privcmd_hypercall;
|
||||
},
|
||||
};
|
||||
|
||||
#define EVTCHN_DEV_NAME "/dev/xenevt"
|
||||
|
||||
@@ -139,6 +139,12 @@ int xc_interface_close(xc_interface *xch)
|
||||
return xc_interface_close_common(xch);
|
||||
}
|
||||
|
||||
|
||||
int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
|
||||
{
|
||||
return xch->ops->u.privcmd.hypercall(xch, xch->ops_handle, hypercall);
|
||||
}
|
||||
|
||||
xc_evtchn *xc_evtchn_open(xentoollog_logger *logger,
|
||||
unsigned open_flags)
|
||||
{
|
||||
|
||||
+10
-12
@@ -68,6 +68,12 @@ static int solaris_privcmd_close(xc_interface *xch, xc_osdep_handle h)
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
static int solaris_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, privcmd_hypercall_t *hypercall)
|
||||
{
|
||||
int fd = (int)h;
|
||||
return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
|
||||
}
|
||||
|
||||
void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
|
||||
xen_pfn_t *arr, int num)
|
||||
{
|
||||
@@ -156,21 +162,13 @@ mmap_failed:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int do_privcmd(xc_interface *xch, unsigned int cmd, unsigned long data)
|
||||
{
|
||||
return ioctl(xch->fd, cmd, data);
|
||||
}
|
||||
|
||||
int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
|
||||
{
|
||||
return do_privcmd(xch,
|
||||
IOCTL_PRIVCMD_HYPERCALL,
|
||||
(unsigned long)hypercall);
|
||||
}
|
||||
|
||||
static struct xc_osdep_ops solaris_privcmd_ops = {
|
||||
.open = &solaris_privcmd_open,
|
||||
.close = &solaris_privcmd_close,
|
||||
|
||||
.u.privcmd = {
|
||||
.hypercall = &solaris_privcmd_hypercall;
|
||||
},
|
||||
};
|
||||
|
||||
static xc_osdep_handle solaris_evtchn_open(xc_evtchn *xce)
|
||||
|
||||
@@ -59,6 +59,12 @@ struct xc_osdep_ops
|
||||
xc_osdep_handle (*open)(xc_interface *xch);
|
||||
|
||||
int (*close)(xc_interface *xch, xc_osdep_handle h);
|
||||
|
||||
union {
|
||||
struct {
|
||||
int (*hypercall)(xc_interface *xch, xc_osdep_handle h, privcmd_hypercall_t *hypercall);
|
||||
} privcmd;
|
||||
} u;
|
||||
};
|
||||
typedef struct xc_osdep_ops xc_osdep_ops;
|
||||
|
||||
|
||||