aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_solaris.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-05-28 09:30:19 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-05-28 09:30:19 +0100
commit5cc436c1d2b3b0be3f42104582f53eec3969b43a (patch)
tree1e30ade146ee7287c486d1309b5d3d2c69a2d9b9 /tools/libxc/xc_solaris.c
parent7f9a888af4b65cb8c22cea3c8295d30d0fedd623 (diff)
downloadxen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.tar.gz
xen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.tar.bz2
xen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.zip
libxc: eliminate static variables, use xentoollog; API change
This patch eliminate the global variables in libxenctrl (used for logging and error reporting). Instead the information which was in the global variables is now in a new xc_interface* opaque structure, which xc_interface open returns instead of the raw file descriptor; furthermore, logging is done via xentoollog. There are three new parameters to xc_interface_open to control the logging, but existing callers can just pass "0" for all three to get the old behaviour. All libxc callers have been adjusted accordingly. Also update QEMU_TAG for corresponding qemu change. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxc/xc_solaris.c')
-rw-r--r--tools/libxc/xc_solaris.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/tools/libxc/xc_solaris.c b/tools/libxc/xc_solaris.c
index 99a51cae4b..b4830dec19 100644
--- a/tools/libxc/xc_solaris.c
+++ b/tools/libxc/xc_solaris.c
@@ -16,7 +16,7 @@
#include <unistd.h>
#include <fcntl.h>
-int xc_interface_open(void)
+int xc_interface_open_core(xc_interface *xch)
{
int flags, saved_errno;
int fd = open("/dev/xen/privcmd", O_RDWR);
@@ -52,17 +52,17 @@ int xc_interface_open(void)
return -1;
}
-int xc_interface_close(int xc_handle)
+int xc_interface_close(xc_interface *xch, int fd)
{
- return close(xc_handle);
+ return close(fd);
}
-void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
+void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
xen_pfn_t *arr, int num)
{
privcmd_mmapbatch_t ioctlx;
void *addr;
- addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0);
+ addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xch->fd, 0);
if ( addr == MAP_FAILED )
return NULL;
@@ -70,10 +70,10 @@ void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
ioctlx.dom=dom;
ioctlx.addr=(unsigned long)addr;
ioctlx.arr=arr;
- if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 )
+ if ( ioctl(xch->fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 )
{
int saved_errno = errno;
- perror("XXXXXXXX");
+ PERROR("XXXXXXXX");
(void)munmap(addr, num*PAGE_SIZE);
errno = saved_errno;
return NULL;
@@ -82,14 +82,14 @@ void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
}
-void *xc_map_foreign_range(int xc_handle, uint32_t dom,
+void *xc_map_foreign_range(xc_interface *xch, uint32_t dom,
int size, int prot,
unsigned long mfn)
{
privcmd_mmap_t ioctlx;
privcmd_mmap_entry_t entry;
void *addr;
- addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0);
+ addr = mmap(NULL, size, prot, MAP_SHARED, xch->fd, 0);
if ( addr == MAP_FAILED )
return NULL;
@@ -99,7 +99,7 @@ void *xc_map_foreign_range(int xc_handle, uint32_t dom,
entry.va=(unsigned long) addr;
entry.mfn=mfn;
entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT;
- if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 )
+ if ( ioctl(xch->fd, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 )
{
int saved_errno = errno;
(void)munmap(addr, size);
@@ -109,7 +109,7 @@ void *xc_map_foreign_range(int xc_handle, uint32_t dom,
return addr;
}
-void *xc_map_foreign_ranges(int xc_handle, uint32_t dom,
+void *xc_map_foreign_ranges(xc_interface *xch, uint32_t dom,
size_t size, int prot, size_t chunksize,
privcmd_mmap_entry_t entries[], int nentries)
{
@@ -117,7 +117,7 @@ void *xc_map_foreign_ranges(int xc_handle, uint32_t dom,
int i, rc;
void *addr;
- addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0);
+ addr = mmap(NULL, size, prot, MAP_SHARED, xch->fd, 0);
if (addr == MAP_FAILED)
goto mmap_failed;
@@ -130,7 +130,7 @@ void *xc_map_foreign_ranges(int xc_handle, uint32_t dom,
ioctlx.dom = dom;
ioctlx.entry = entries;
- rc = ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx);
+ rc = ioctl(xch->fd, IOCTL_PRIVCMD_MMAP, &ioctlx);
if (rc)
goto ioctl_failed;
@@ -139,21 +139,21 @@ void *xc_map_foreign_ranges(int xc_handle, uint32_t dom,
ioctl_failed:
rc = munmap(addr, size);
if (rc == -1)
- ERROR("%s: error in error path\n", __FUNCTION__);
+ PERROR("%s: error in error path\n", __FUNCTION__);
mmap_failed:
return NULL;
}
-static int do_privcmd(int xc_handle, unsigned int cmd, unsigned long data)
+static int do_privcmd(xc_interface *xch, unsigned int cmd, unsigned long data)
{
- return ioctl(xc_handle, cmd, data);
+ return ioctl(xch->fd, cmd, data);
}
-int do_xen_hypercall(int xc_handle, privcmd_hypercall_t *hypercall)
+int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
{
- return do_privcmd(xc_handle,
+ return do_privcmd(xch,
IOCTL_PRIVCMD_HYPERCALL,
(unsigned long)hypercall);
}
@@ -248,19 +248,19 @@ int xc_evtchn_unmask(int xce_handle, evtchn_port_t port)
}
/* Optionally flush file to disk and discard page cache */
-void discard_file_cache(int fd, int flush)
+void discard_file_cache(xc_interface *xch, int fd, int flush)
{
// TODO: Implement for Solaris!
}
grant_entry_v1_t *xc_gnttab_map_table_v1(
- int xc_handle, int domid, int *gnt_num)
+ xc_interface *xch, int domid, int *gnt_num)
{
return NULL;
}
grant_entry_v2_t *xc_gnttab_map_table_v2(
- int xc_handle, int domid, int *gnt_num)
+ xc_interface *xch, int domid, int *gnt_num)
{
return NULL;
}