diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-05-28 09:30:19 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-05-28 09:30:19 +0100 |
commit | 5cc436c1d2b3b0be3f42104582f53eec3969b43a (patch) | |
tree | 1e30ade146ee7287c486d1309b5d3d2c69a2d9b9 /tools/libxc/xc_netbsd.c | |
parent | 7f9a888af4b65cb8c22cea3c8295d30d0fedd623 (diff) | |
download | xen-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_netbsd.c')
-rw-r--r-- | tools/libxc/xc_netbsd.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/tools/libxc/xc_netbsd.c b/tools/libxc/xc_netbsd.c index 951926d5c4..b08268a4ce 100644 --- a/tools/libxc/xc_netbsd.c +++ b/tools/libxc/xc_netbsd.c @@ -15,7 +15,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("/kern/xen/privcmd", O_RDWR); @@ -51,19 +51,19 @@ 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_ANON | MAP_SHARED, -1, 0); if ( addr == MAP_FAILED ) { - perror("xc_map_foreign_batch: mmap failed"); + PERROR("xc_map_foreign_batch: mmap failed"); return NULL; } @@ -71,10 +71,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("xc_map_foreign_batch: ioctl failed"); + PERROR("xc_map_foreign_batch: ioctl failed"); (void)munmap(addr, num*PAGE_SIZE); errno = saved_errno; return NULL; @@ -83,7 +83,7 @@ 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) { @@ -92,7 +92,7 @@ void *xc_map_foreign_range(int xc_handle, uint32_t dom, void *addr; addr = mmap(NULL, size, prot, MAP_ANON | MAP_SHARED, -1, 0); if ( addr == MAP_FAILED ) { - perror("xc_map_foreign_range: mmap failed"); + PERROR("xc_map_foreign_range: mmap failed"); return NULL; } @@ -102,10 +102,10 @@ 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; - perror("xc_map_foreign_range: ioctl failed"); + PERROR("xc_map_foreign_range: ioctl failed"); (void)munmap(addr, size); errno = saved_errno; return NULL; @@ -113,7 +113,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) { @@ -134,7 +134,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; @@ -150,18 +150,18 @@ mmap_failed: } -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) { - int err = ioctl(xc_handle, cmd, data); + int err = ioctl(xch->fd, cmd, data); if (err == 0) return 0; else return -errno; } -int do_xen_hypercall(int xc_handle, privcmd_hypercall_t *hypercall) +int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall) { - int error = do_privcmd(xc_handle, + int error = do_privcmd(xch, IOCTL_PRIVCMD_HYPERCALL, (unsigned long)hypercall); if (error) @@ -254,7 +254,7 @@ 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) { if ( flush && (fsync(fd) < 0) ) @@ -264,13 +264,13 @@ void discard_file_cache(int fd, int flush) } 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; } |