ia64/xen-unstable
changeset 9914:24dbb153ab39
Move Linux-specific privcmd code into private libxc implementations.
Make header path for kernel's privcmd/evtchn headers generic.
Remove pointless xi_*() interface that was using private libxc
interfaces.
Signed-off-by: John Levon <john.levon@sun.com>
Make header path for kernel's privcmd/evtchn headers generic.
Remove pointless xi_*() interface that was using private libxc
interfaces.
Signed-off-by: John Levon <john.levon@sun.com>
line diff
1.1 --- a/tools/Rules.mk Tue May 02 09:18:55 2006 +0100 1.2 +++ b/tools/Rules.mk Tue May 02 15:12:06 2006 +0100 1.3 @@ -23,15 +23,23 @@ CFLAGS += -D__XEN_TOOLS__ 1.4 %.o: %.cc 1.5 $(CC) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< 1.6 1.7 -.PHONY: mk-symlinks 1.8 -mk-symlinks: LINUX_ROOT=$(XEN_ROOT)/linux-2.6-xen-sparse 1.9 -mk-symlinks: 1.10 +OS = $(shell uname -s) 1.11 + 1.12 +.PHONY: mk-symlinks mk-symlinks-xen mk-symlinks-$(OS) 1.13 + 1.14 +mk-symlinks-Linux: LINUX_ROOT=$(XEN_ROOT)/linux-2.6-xen-sparse 1.15 +mk-symlinks-Linux: 1.16 + mkdir -p xen/linux 1.17 + ( cd xen/linux && \ 1.18 + ln -sf ../../$(LINUX_ROOT)/include/xen/public/*.h . ) 1.19 + ( cd xen && rm -f sys && ln -sf linux sys ) 1.20 + 1.21 +mk-symlinks-xen: 1.22 mkdir -p xen 1.23 ( cd xen && ln -sf ../$(XEN_ROOT)/xen/include/public/*.h . ) 1.24 mkdir -p xen/hvm 1.25 ( cd xen/hvm && ln -sf ../../$(XEN_ROOT)/xen/include/public/hvm/*.h . ) 1.26 mkdir -p xen/io 1.27 ( cd xen/io && ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . ) 1.28 - mkdir -p xen/linux 1.29 - ( cd xen/linux && \ 1.30 - ln -sf ../../$(LINUX_ROOT)/include/xen/public/*.h . ) 1.31 + 1.32 +mk-symlinks: mk-symlinks-xen mk-symlinks-$(OS)
2.1 --- a/tools/debugger/pdb/pdb_caml_process.c Tue May 02 09:18:55 2006 +0100 2.2 +++ b/tools/debugger/pdb/pdb_caml_process.c Tue May 02 15:12:06 2006 +0100 2.3 @@ -18,7 +18,6 @@ 2.4 #include <xenctrl.h> 2.5 #include <xen/xen.h> 2.6 #include <xen/io/domain_controller.h> 2.7 -#include <xen/linux/privcmd.h> 2.8 #include "pdb_module.h" 2.9 #include "pdb_caml_xen.h" 2.10
3.1 --- a/tools/debugger/pdb/pdb_caml_xcs.c Tue May 02 09:18:55 2006 +0100 3.2 +++ b/tools/debugger/pdb/pdb_caml_xcs.c Tue May 02 15:12:06 2006 +0100 3.3 @@ -21,7 +21,6 @@ 3.4 3.5 #include <xen/xen.h> 3.6 #include <xen/io/domain_controller.h> 3.7 -#include <xen/linux/privcmd.h> 3.8 3.9 #include <arpa/inet.h> 3.10 #include <xcs_proto.h>
4.1 --- a/tools/libxc/Makefile Tue May 02 09:18:55 2006 +0100 4.2 +++ b/tools/libxc/Makefile Tue May 02 15:12:06 2006 +0100 4.3 @@ -16,6 +16,7 @@ SRCS += xc_core.c 4.4 SRCS += xc_domain.c 4.5 SRCS += xc_evtchn.c 4.6 SRCS += xc_misc.c 4.7 +SRCS += xc_acm.c 4.8 SRCS += xc_physdev.c 4.9 SRCS += xc_private.c 4.10 SRCS += xc_sedf.c 4.11 @@ -27,6 +28,10 @@ SRCS += xc_ptrace_core.c 4.12 SRCS += xc_pagetab.c 4.13 endif 4.14 4.15 +SRCS_Linux += xc_linux.c 4.16 + 4.17 +SRCS += $(SRCS_Linux) 4.18 + 4.19 BUILD_SRCS := 4.20 BUILD_SRCS += xc_linux_build.c 4.21 BUILD_SRCS += xc_load_bin.c
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/tools/libxc/xc_acm.c Tue May 02 15:12:06 2006 +0100 5.3 @@ -0,0 +1,54 @@ 5.4 +/****************************************************************************** 5.5 + * 5.6 + * Copyright (C) 2005 IBM Corporation 5.7 + * 5.8 + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 5.9 + * Use is subject to license terms. 5.10 + * 5.11 + * Authors: 5.12 + * Reiner Sailer <sailer@watson.ibm.com> 5.13 + * Stefan Berger <stefanb@watson.ibm.com> 5.14 + * 5.15 + * This program is free software; you can redistribute it and/or 5.16 + * modify it under the terms of the GNU General Public License as 5.17 + * published by the Free Software Foundation, version 2 of the 5.18 + * License. 5.19 + */ 5.20 + 5.21 +#include "xc_private.h" 5.22 + 5.23 +int xc_acm_op(int xc_handle, struct acm_op *op) 5.24 +{ 5.25 + int ret = -1; 5.26 + DECLARE_HYPERCALL; 5.27 + 5.28 + op->interface_version = ACM_INTERFACE_VERSION; 5.29 + 5.30 + hypercall.op = __HYPERVISOR_acm_op; 5.31 + hypercall.arg[0] = (unsigned long) op; 5.32 + 5.33 + if (mlock(op, sizeof(*op)) != 0) { 5.34 + PERROR("Could not lock memory for Xen policy hypercall"); 5.35 + goto out1; 5.36 + } 5.37 + 5.38 + ret = do_xen_hypercall(xc_handle, &hypercall); 5.39 + ret = ioctl(xc_handle, IOCTL_PRIVCMD_HYPERCALL, &hypercall); 5.40 + if (ret < 0) { 5.41 + goto out2; 5.42 + } 5.43 + out2: 5.44 + safe_munlock(op, sizeof(*op)); 5.45 + out1: 5.46 + return ret; 5.47 +} 5.48 + 5.49 +/* 5.50 + * Local variables: 5.51 + * mode: C 5.52 + * c-set-style: "BSD" 5.53 + * c-basic-offset: 4 5.54 + * tab-width: 4 5.55 + * indent-tabs-mode: nil 5.56 + * End: 5.57 + */
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/tools/libxc/xc_linux.c Tue May 02 15:12:06 2006 +0100 6.3 @@ -0,0 +1,114 @@ 6.4 +/****************************************************************************** 6.5 + * 6.6 + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 6.7 + * Use is subject to license terms. 6.8 + * 6.9 + * This program is free software; you can redistribute it and/or 6.10 + * modify it under the terms of the GNU General Public License as 6.11 + * published by the Free Software Foundation, version 2 of the 6.12 + * License. 6.13 + */ 6.14 + 6.15 +#include "xc_private.h" 6.16 + 6.17 +#include <xen/memory.h> 6.18 +#include <xen/sys/evtchn.h> 6.19 + 6.20 +int xc_interface_open(void) 6.21 +{ 6.22 + int fd = open("/proc/xen/privcmd", O_RDWR); 6.23 + if ( fd == -1 ) 6.24 + PERROR("Could not obtain handle on privileged command interface"); 6.25 + return fd; 6.26 +} 6.27 + 6.28 +int xc_interface_close(int xc_handle) 6.29 +{ 6.30 + return close(xc_handle); 6.31 +} 6.32 + 6.33 +void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot, 6.34 + unsigned long *arr, int num) 6.35 +{ 6.36 + privcmd_mmapbatch_t ioctlx; 6.37 + void *addr; 6.38 + addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0); 6.39 + if ( addr == MAP_FAILED ) 6.40 + return NULL; 6.41 + 6.42 + ioctlx.num=num; 6.43 + ioctlx.dom=dom; 6.44 + ioctlx.addr=(unsigned long)addr; 6.45 + ioctlx.arr=arr; 6.46 + if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 ) 6.47 + { 6.48 + int saved_errno = errno; 6.49 + perror("XXXXXXXX"); 6.50 + (void)munmap(addr, num*PAGE_SIZE); 6.51 + errno = saved_errno; 6.52 + return NULL; 6.53 + } 6.54 + return addr; 6.55 + 6.56 +} 6.57 + 6.58 +void *xc_map_foreign_range(int xc_handle, uint32_t dom, 6.59 + int size, int prot, 6.60 + unsigned long mfn) 6.61 +{ 6.62 + privcmd_mmap_t ioctlx; 6.63 + privcmd_mmap_entry_t entry; 6.64 + void *addr; 6.65 + addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0); 6.66 + if ( addr == MAP_FAILED ) 6.67 + return NULL; 6.68 + 6.69 + ioctlx.num=1; 6.70 + ioctlx.dom=dom; 6.71 + ioctlx.entry=&entry; 6.72 + entry.va=(unsigned long) addr; 6.73 + entry.mfn=mfn; 6.74 + entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT; 6.75 + if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 ) 6.76 + { 6.77 + int saved_errno = errno; 6.78 + (void)munmap(addr, size); 6.79 + errno = saved_errno; 6.80 + return NULL; 6.81 + } 6.82 + return addr; 6.83 +} 6.84 + 6.85 +int xc_map_foreign_ranges(int xc_handle, uint32_t dom, 6.86 + privcmd_mmap_entry_t *entries, int nr) 6.87 +{ 6.88 + privcmd_mmap_t ioctlx; 6.89 + 6.90 + ioctlx.num = nr; 6.91 + ioctlx.dom = dom; 6.92 + ioctlx.entry = entries; 6.93 + 6.94 + return ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx); 6.95 +} 6.96 + 6.97 +static int do_privcmd(int xc_handle, unsigned int cmd, unsigned long data) 6.98 +{ 6.99 + return ioctl(xc_handle, cmd, data); 6.100 +} 6.101 + 6.102 +int do_xen_hypercall(int xc_handle, privcmd_hypercall_t *hypercall) 6.103 +{ 6.104 + return do_privcmd(xc_handle, 6.105 + IOCTL_PRIVCMD_HYPERCALL, 6.106 + (unsigned long)hypercall); 6.107 +} 6.108 + 6.109 +/* 6.110 + * Local variables: 6.111 + * mode: C 6.112 + * c-set-style: "BSD" 6.113 + * c-basic-offset: 4 6.114 + * tab-width: 4 6.115 + * indent-tabs-mode: nil 6.116 + * End: 6.117 + */
7.1 --- a/tools/libxc/xc_linux_save.c Tue May 02 09:18:55 2006 +0100 7.2 +++ b/tools/libxc/xc_linux_save.c Tue May 02 15:12:06 2006 +0100 7.3 @@ -12,6 +12,7 @@ 7.4 #include <unistd.h> 7.5 #include <sys/time.h> 7.6 7.7 +#include "xc_private.h" 7.8 #include "xg_private.h" 7.9 #include "xg_save_restore.h" 7.10 7.11 @@ -505,7 +506,6 @@ static unsigned long *xc_map_m2p(int xc_ 7.12 int prot) 7.13 { 7.14 struct xen_machphys_mfn_list xmml; 7.15 - privcmd_mmap_t ioctlx; 7.16 privcmd_mmap_entry_t *entries; 7.17 unsigned long m2p_chunks, m2p_size; 7.18 unsigned long *m2p; 7.19 @@ -539,18 +539,15 @@ static unsigned long *xc_map_m2p(int xc_ 7.20 return NULL; 7.21 } 7.22 7.23 - ioctlx.num = m2p_chunks; 7.24 - ioctlx.dom = DOMID_XEN; 7.25 - ioctlx.entry = entries; 7.26 - 7.27 for (i=0; i < m2p_chunks; i++) { 7.28 entries[i].va = (unsigned long)(((void *)m2p) + (i * M2P_CHUNK_SIZE)); 7.29 entries[i].mfn = extent_start[i]; 7.30 entries[i].npages = M2P_CHUNK_SIZE >> PAGE_SHIFT; 7.31 } 7.32 7.33 - if ((rc = ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx)) < 0) { 7.34 - ERR("ioctl_mmap failed (rc = %d)", rc); 7.35 + if ((rc = xc_map_foreign_ranges(xc_handle, DOMID_XEN, 7.36 + entries, m2p_chunks)) < 0) { 7.37 + ERR("xc_mmap_foreign_ranges failed (rc = %d)", rc); 7.38 return NULL; 7.39 } 7.40
8.1 --- a/tools/libxc/xc_misc.c Tue May 02 09:18:55 2006 +0100 8.2 +++ b/tools/libxc/xc_misc.c Tue May 02 15:12:06 2006 +0100 8.3 @@ -6,19 +6,6 @@ 8.4 8.5 #include "xc_private.h" 8.6 8.7 -int xc_interface_open(void) 8.8 -{ 8.9 - int fd = open("/proc/xen/privcmd", O_RDWR); 8.10 - if ( fd == -1 ) 8.11 - PERROR("Could not obtain handle on privileged command interface"); 8.12 - return fd; 8.13 -} 8.14 - 8.15 -int xc_interface_close(int xc_handle) 8.16 -{ 8.17 - return close(xc_handle); 8.18 -} 8.19 - 8.20 int xc_readconsolering(int xc_handle, 8.21 char **pbuffer, 8.22 unsigned int *pnr_chars,
9.1 --- a/tools/libxc/xc_private.c Tue May 02 09:18:55 2006 +0100 9.2 +++ b/tools/libxc/xc_private.c Tue May 02 15:12:06 2006 +0100 9.3 @@ -5,63 +5,6 @@ 9.4 */ 9.5 9.6 #include "xc_private.h" 9.7 -#include <xen/memory.h> 9.8 - 9.9 -void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot, 9.10 - unsigned long *arr, int num ) 9.11 -{ 9.12 - privcmd_mmapbatch_t ioctlx; 9.13 - void *addr; 9.14 - addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0); 9.15 - if ( addr == MAP_FAILED ) 9.16 - return NULL; 9.17 - 9.18 - ioctlx.num=num; 9.19 - ioctlx.dom=dom; 9.20 - ioctlx.addr=(unsigned long)addr; 9.21 - ioctlx.arr=arr; 9.22 - if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx ) < 0 ) 9.23 - { 9.24 - int saved_errno = errno; 9.25 - perror("XXXXXXXX"); 9.26 - (void)munmap(addr, num*PAGE_SIZE); 9.27 - errno = saved_errno; 9.28 - return NULL; 9.29 - } 9.30 - return addr; 9.31 - 9.32 -} 9.33 - 9.34 -/*******************/ 9.35 - 9.36 -void *xc_map_foreign_range(int xc_handle, uint32_t dom, 9.37 - int size, int prot, 9.38 - unsigned long mfn ) 9.39 -{ 9.40 - privcmd_mmap_t ioctlx; 9.41 - privcmd_mmap_entry_t entry; 9.42 - void *addr; 9.43 - addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0); 9.44 - if ( addr == MAP_FAILED ) 9.45 - return NULL; 9.46 - 9.47 - ioctlx.num=1; 9.48 - ioctlx.dom=dom; 9.49 - ioctlx.entry=&entry; 9.50 - entry.va=(unsigned long) addr; 9.51 - entry.mfn=mfn; 9.52 - entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT; 9.53 - if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx ) < 0 ) 9.54 - { 9.55 - int saved_errno = errno; 9.56 - (void)munmap(addr, size); 9.57 - errno = saved_errno; 9.58 - return NULL; 9.59 - } 9.60 - return addr; 9.61 -} 9.62 - 9.63 -/*******************/ 9.64 9.65 /* NB: arr must be mlock'ed */ 9.66 int xc_get_pfn_type_batch(int xc_handle,
10.1 --- a/tools/libxc/xc_private.h Tue May 02 09:18:55 2006 +0100 10.2 +++ b/tools/libxc/xc_private.h Tue May 02 15:12:06 2006 +0100 10.3 @@ -15,7 +15,7 @@ 10.4 10.5 #include "xenctrl.h" 10.6 10.7 -#include <xen/linux/privcmd.h> 10.8 +#include <xen/sys/privcmd.h> 10.9 10.10 /* valgrind cannot see when a hypercall has filled in some values. For this 10.11 reason, we must zero the privcmd_hypercall_t or dom0_op_t instance before a 10.12 @@ -56,20 +56,7 @@ static inline void safe_munlock(const vo 10.13 errno = saved_errno; 10.14 } 10.15 10.16 -static inline int do_privcmd(int xc_handle, 10.17 - unsigned int cmd, 10.18 - unsigned long data) 10.19 -{ 10.20 - return ioctl(xc_handle, cmd, data); 10.21 -} 10.22 - 10.23 -static inline int do_xen_hypercall(int xc_handle, 10.24 - privcmd_hypercall_t *hypercall) 10.25 -{ 10.26 - return do_privcmd(xc_handle, 10.27 - IOCTL_PRIVCMD_HYPERCALL, 10.28 - (unsigned long)hypercall); 10.29 -} 10.30 +int do_xen_hypercall(int xc_handle, privcmd_hypercall_t *hypercall); 10.31 10.32 static inline int do_xen_version(int xc_handle, int cmd, void *dest) 10.33 { 10.34 @@ -111,23 +98,7 @@ static inline int do_dom0_op(int xc_hand 10.35 return ret; 10.36 } 10.37 10.38 - 10.39 -/* 10.40 - * ioctl-based mfn mapping interface 10.41 - */ 10.42 - 10.43 -/* 10.44 -typedef struct privcmd_mmap_entry { 10.45 - unsigned long va; 10.46 - unsigned long mfn; 10.47 - unsigned long npages; 10.48 -} privcmd_mmap_entry_t; 10.49 - 10.50 -typedef struct privcmd_mmap { 10.51 - int num; 10.52 - domid_t dom; 10.53 - privcmd_mmap_entry_t *entry; 10.54 -} privcmd_mmap_t; 10.55 -*/ 10.56 +int xc_map_foreign_ranges(int xc_handle, uint32_t dom, 10.57 + privcmd_mmap_entry_t *entries, int nr); 10.58 10.59 #endif /* __XC_PRIVATE_H__ */
11.1 --- a/tools/libxc/xc_tbuf.c Tue May 02 09:18:55 2006 +0100 11.2 +++ b/tools/libxc/xc_tbuf.c Tue May 02 15:12:06 2006 +0100 11.3 @@ -4,6 +4,14 @@ 11.4 * API for manipulating and accessing trace buffer parameters 11.5 * 11.6 * Copyright (c) 2005, Rob Gardner 11.7 + * 11.8 + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 11.9 + * Use is subject to license terms. 11.10 + * 11.11 + * This program is free software; you can redistribute it and/or 11.12 + * modify it under the terms of the GNU General Public License as 11.13 + * published by the Free Software Foundation, version 2 of the 11.14 + * License. 11.15 */ 11.16 11.17 #include "xc_private.h" 11.18 @@ -49,3 +57,41 @@ int xc_tbuf_get_size(int xc_handle, uint 11.19 return rc; 11.20 } 11.21 11.22 +int xc_tbuf_get_mfn(int xc_handle, unsigned long *mfn) 11.23 +{ 11.24 + int rc; 11.25 + DECLARE_DOM0_OP; 11.26 + 11.27 + op.cmd = DOM0_TBUFCONTROL; 11.28 + op.interface_version = DOM0_INTERFACE_VERSION; 11.29 + op.u.tbufcontrol.op = DOM0_TBUF_GET_INFO; 11.30 + 11.31 + rc = xc_dom0_op(xc_handle, &op); 11.32 + if ( rc == 0 ) 11.33 + *mfn = op.u.tbufcontrol.buffer_mfn; 11.34 + return rc; 11.35 +} 11.36 + 11.37 +int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask) 11.38 +{ 11.39 + DECLARE_DOM0_OP; 11.40 + 11.41 + op.cmd = DOM0_TBUFCONTROL; 11.42 + op.interface_version = DOM0_INTERFACE_VERSION; 11.43 + op.u.tbufcontrol.op = DOM0_TBUF_SET_CPU_MASK; 11.44 + op.u.tbufcontrol.cpu_mask = mask; 11.45 + 11.46 + return do_dom0_op(xc_handle, &op); 11.47 +} 11.48 + 11.49 +int xc_tbuf_set_evt_mask(int xc_handle, uint32_t mask) 11.50 +{ 11.51 + DECLARE_DOM0_OP; 11.52 + 11.53 + op.cmd = DOM0_TBUFCONTROL; 11.54 + op.interface_version = DOM0_INTERFACE_VERSION; 11.55 + op.u.tbufcontrol.op = DOM0_TBUF_SET_EVT_MASK; 11.56 + op.u.tbufcontrol.evt_mask = mask; 11.57 + 11.58 + return do_dom0_op(xc_handle, &op); 11.59 +}
12.1 --- a/tools/libxc/xenctrl.h Tue May 02 09:18:55 2006 +0100 12.2 +++ b/tools/libxc/xenctrl.h Tue May 02 15:12:06 2006 +0100 12.3 @@ -19,6 +19,7 @@ 12.4 #include <xen/sched_ctl.h> 12.5 #include <xen/memory.h> 12.6 #include <xen/acm.h> 12.7 +#include <xen/acm_ops.h> 12.8 12.9 #ifdef __ia64__ 12.10 #define XC_PAGE_SHIFT 14 12.11 @@ -560,6 +561,18 @@ int xc_tbuf_set_size(int xc_handle, uint 12.12 */ 12.13 int xc_tbuf_get_size(int xc_handle, uint32_t *size); 12.14 12.15 +/** 12.16 + * This function retrieves the machine frame of the trace buffer. 12.17 + 12.18 + * @parm xc_handle a handle to an open hypervisor interface 12.19 + * @parm mfn will contain the machine frame of the buffer. 12.20 + * @return 0 on success, -1 on failure. 12.21 + */ 12.22 +int xc_tbuf_get_mfn(int xc_handle, unsigned long *mfn); 12.23 + 12.24 +int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask); 12.25 + 12.26 +int xc_tbuf_set_evt_mask(int xc_handle, uint32_t mask); 12.27 12.28 /* Execute a privileged dom0 operation. */ 12.29 int xc_dom0_op(int xc_handle, dom0_op_t *op); 12.30 @@ -581,4 +594,6 @@ int xc_add_mmu_update(int xc_handle, xc_ 12.31 unsigned long long ptr, unsigned long long val); 12.32 int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu); 12.33 12.34 +int xc_acm_op(int xc_handle, struct acm_op *op); 12.35 + 12.36 #endif
13.1 --- a/tools/libxc/xg_private.h Tue May 02 09:18:55 2006 +0100 13.2 +++ b/tools/libxc/xg_private.h Tue May 02 15:12:06 2006 +0100 13.3 @@ -13,7 +13,7 @@ 13.4 #include "xenctrl.h" 13.5 #include "xenguest.h" 13.6 13.7 -#include <xen/linux/privcmd.h> 13.8 +#include <xen/sys/privcmd.h> 13.9 #include <xen/memory.h> 13.10 13.11 /* valgrind cannot see when a hypercall has filled in some values. For this
14.1 --- a/tools/python/xen/lowlevel/acm/acm.c Tue May 02 09:18:55 2006 +0100 14.2 +++ b/tools/python/xen/lowlevel/acm/acm.c Tue May 02 15:12:06 2006 +0100 14.3 @@ -28,51 +28,22 @@ 14.4 #include <netinet/in.h> 14.5 #include <xen/acm.h> 14.6 #include <xen/acm_ops.h> 14.7 -#include <xen/linux/privcmd.h> 14.8 + 14.9 +#include <xenctrl.h> 14.10 14.11 #define PERROR(_m, _a...) \ 14.12 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \ 14.13 errno, strerror(errno)) 14.14 14.15 - 14.16 - 14.17 -static inline int do_acm_op(int xc_handle, struct acm_op *op) 14.18 -{ 14.19 - int ret = -1; 14.20 - privcmd_hypercall_t hypercall; 14.21 - 14.22 - op->interface_version = ACM_INTERFACE_VERSION; 14.23 - 14.24 - hypercall.op = __HYPERVISOR_acm_op; 14.25 - hypercall.arg[0] = (unsigned long) op; 14.26 - 14.27 - if (mlock(op, sizeof(*op)) != 0) { 14.28 - PERROR("Could not lock memory for Xen policy hypercall"); 14.29 - goto out1; 14.30 - } 14.31 - ret = ioctl(xc_handle, IOCTL_PRIVCMD_HYPERCALL, &hypercall); 14.32 - if (ret < 0) { 14.33 - if (errno == EACCES) 14.34 - PERROR("ACM operation failed."); 14.35 - goto out2; 14.36 - } 14.37 - out2: 14.38 - munlock(op, sizeof(*op)); 14.39 - out1: 14.40 - return ret; 14.41 -} 14.42 - 14.43 - 14.44 - 14.45 /* generic shared function */ 14.46 void * __getssid(int domid, uint32_t *buflen) 14.47 { 14.48 struct acm_op op; 14.49 - int acm_cmd_fd; 14.50 + int xc_handle; 14.51 #define SSID_BUFFER_SIZE 4096 14.52 void *buf = NULL; 14.53 14.54 - if ((acm_cmd_fd = open("/proc/xen/privcmd", O_RDONLY)) < 0) { 14.55 + if ((xc_handle = xc_interface_open()) < 0) { 14.56 goto out1; 14.57 } 14.58 if ((buf = malloc(SSID_BUFFER_SIZE)) == NULL) { 14.59 @@ -87,7 +58,9 @@ void * __getssid(int domid, uint32_t *bu 14.60 op.u.getssid.get_ssid_by = DOMAINID; 14.61 op.u.getssid.id.domainid = domid; 14.62 14.63 - if (do_acm_op(acm_cmd_fd, &op) < 0) { 14.64 + if (xc_acm_op(xc_handle, &op) < 0) { 14.65 + if (errno == EACCES) 14.66 + PERROR("ACM operation failed."); 14.67 free(buf); 14.68 buf = NULL; 14.69 goto out2; 14.70 @@ -96,7 +69,7 @@ void * __getssid(int domid, uint32_t *bu 14.71 goto out2; 14.72 } 14.73 out2: 14.74 - close(acm_cmd_fd); 14.75 + xc_interface_close(xc_handle); 14.76 out1: 14.77 return buf; 14.78 } 14.79 @@ -175,13 +148,13 @@ static PyObject *getdecision(PyObject * 14.80 { 14.81 char *arg1_name, *arg1, *arg2_name, *arg2, *decision = NULL; 14.82 struct acm_op op; 14.83 - int acm_cmd_fd, ret; 14.84 + int xc_handle; 14.85 14.86 if (!PyArg_ParseTuple(args, "ssss", &arg1_name, &arg1, &arg2_name, &arg2)) { 14.87 return NULL; 14.88 } 14.89 14.90 - if ((acm_cmd_fd = open("/proc/xen/privcmd", O_RDONLY)) <= 0) { 14.91 + if ((xc_handle = xc_interface_open()) <= 0) { 14.92 PERROR("Could not open xen privcmd device!\n"); 14.93 return NULL; 14.94 } 14.95 @@ -208,8 +181,12 @@ static PyObject *getdecision(PyObject * 14.96 op.u.getdecision.id2.ssidref = atol(arg2); 14.97 } 14.98 14.99 - ret = do_acm_op(acm_cmd_fd, &op); 14.100 - close(acm_cmd_fd); 14.101 + if (xc_acm_op(xc_handle, &op) < 0) { 14.102 + if (errno == EACCES) 14.103 + PERROR("ACM operation failed."); 14.104 + } 14.105 + 14.106 + xc_interface_close(xc_handle); 14.107 14.108 if (op.u.getdecision.acm_decision == ACM_ACCESS_PERMITTED) 14.109 decision = "PERMITTED";
15.1 --- a/tools/security/secpol_tool.c Tue May 02 09:18:55 2006 +0100 15.2 +++ b/tools/security/secpol_tool.c Tue May 02 15:12:06 2006 +0100 15.3 @@ -14,7 +14,7 @@ 15.4 * 15.5 * sHype policy management tool. This code runs in a domain and 15.6 * manages the Xen security policy by interacting with the 15.7 - * Xen access control module via a /proc/xen/privcmd proc-ioctl, 15.8 + * Xen access control module via the privcmd device, 15.9 * which is translated into a acm_op hypercall into Xen. 15.10 * 15.11 * indent -i4 -kr -nut 15.12 @@ -36,7 +36,8 @@ 15.13 #include <stdint.h> 15.14 #include <xen/acm.h> 15.15 #include <xen/acm_ops.h> 15.16 -#include <xen/linux/privcmd.h> 15.17 + 15.18 +#include <xenctrl.h> 15.19 15.20 #define PERROR(_m, _a...) \ 15.21 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \ 15.22 @@ -52,47 +53,6 @@ void usage(char *progname) 15.23 exit(-1); 15.24 } 15.25 15.26 -static inline int do_policycmd(int xc_handle, unsigned int cmd, 15.27 - unsigned long data) 15.28 -{ 15.29 - return ioctl(xc_handle, cmd, data); 15.30 -} 15.31 - 15.32 -static inline int do_xen_hypercall(int xc_handle, 15.33 - privcmd_hypercall_t * hypercall) 15.34 -{ 15.35 - return do_policycmd(xc_handle, 15.36 - IOCTL_PRIVCMD_HYPERCALL, 15.37 - (unsigned long) hypercall); 15.38 -} 15.39 - 15.40 -static inline int do_acm_op(int xc_handle, struct acm_op *op) 15.41 -{ 15.42 - int ret = -1; 15.43 - privcmd_hypercall_t hypercall; 15.44 - 15.45 - op->interface_version = ACM_INTERFACE_VERSION; 15.46 - 15.47 - hypercall.op = __HYPERVISOR_acm_op; 15.48 - hypercall.arg[0] = (unsigned long) op; 15.49 - 15.50 - if (mlock(op, sizeof(*op)) != 0) { 15.51 - PERROR("Could not lock memory for Xen policy hypercall"); 15.52 - goto out1; 15.53 - } 15.54 - 15.55 - if ((ret = do_xen_hypercall(xc_handle, &hypercall)) < 0) { 15.56 - printf("ACM operation failed: errno=%d\n", errno); 15.57 - if (errno == EACCES) 15.58 - fprintf(stderr, "ACM operation failed -- need to" 15.59 - " rebuild the user-space tool set?\n"); 15.60 - goto out2; 15.61 - } 15.62 - 15.63 - out2:(void) munlock(op, sizeof(*op)); 15.64 - out1:return ret; 15.65 -} 15.66 - 15.67 /*************************** DUMPS *******************************/ 15.68 15.69 void acm_dump_chinesewall_buffer(void *buf, int buflen) 15.70 @@ -276,10 +236,15 @@ int acm_domain_getpolicy(int xc_handle) 15.71 15.72 memset(pull_buffer, 0x00, sizeof(pull_buffer)); 15.73 op.cmd = ACM_GETPOLICY; 15.74 - op.interface_version = ACM_INTERFACE_VERSION; 15.75 op.u.getpolicy.pullcache = (void *) pull_buffer; 15.76 op.u.getpolicy.pullcache_size = sizeof(pull_buffer); 15.77 - ret = do_acm_op(xc_handle, &op); 15.78 + if ((ret = xc_acm_op(xc_handle, &op)) < 0) { 15.79 + printf("ACM operation failed: errno=%d\n", errno); 15.80 + if (errno == EACCES) 15.81 + fprintf(stderr, "ACM operation failed -- need to" 15.82 + " rebuild the user-space tool set?\n"); 15.83 + } 15.84 + 15.85 /* dump policy */ 15.86 acm_dump_policy_buffer(pull_buffer, sizeof(pull_buffer)); 15.87 return ret; 15.88 @@ -314,10 +279,9 @@ int acm_domain_loadpolicy(int xc_handle, 15.89 /* dump it and then push it down into xen/acm */ 15.90 acm_dump_policy_buffer(buffer, len); 15.91 op.cmd = ACM_SETPOLICY; 15.92 - op.interface_version = ACM_INTERFACE_VERSION; 15.93 op.u.setpolicy.pushcache = (void *) buffer; 15.94 op.u.setpolicy.pushcache_size = len; 15.95 - ret = do_acm_op(xc_handle, &op); 15.96 + ret = xc_acm_op(xc_handle, &op); 15.97 15.98 if (ret) 15.99 printf 15.100 @@ -364,10 +328,9 @@ int acm_domain_dumpstats(int xc_handle) 15.101 15.102 memset(stats_buffer, 0x00, sizeof(stats_buffer)); 15.103 op.cmd = ACM_DUMPSTATS; 15.104 - op.interface_version = ACM_INTERFACE_VERSION; 15.105 op.u.dumpstats.pullcache = (void *) stats_buffer; 15.106 op.u.dumpstats.pullcache_size = sizeof(stats_buffer); 15.107 - ret = do_acm_op(xc_handle, &op); 15.108 + ret = xc_acm_op(xc_handle, &op); 15.109 15.110 if (ret < 0) { 15.111 printf 15.112 @@ -426,12 +389,12 @@ int acm_domain_dumpstats(int xc_handle) 15.113 int main(int argc, char **argv) 15.114 { 15.115 15.116 - int acm_cmd_fd, ret = 0; 15.117 + int xc_handle, ret = 0; 15.118 15.119 if (argc < 2) 15.120 usage(argv[0]); 15.121 15.122 - if ((acm_cmd_fd = open("/proc/xen/privcmd", O_RDONLY)) <= 0) { 15.123 + if ((xc_handle = xc_interface_open()) <= 0) { 15.124 printf("ERROR: Could not open xen privcmd device!\n"); 15.125 exit(-1); 15.126 } 15.127 @@ -439,18 +402,18 @@ int main(int argc, char **argv) 15.128 if (!strcmp(argv[1], "getpolicy")) { 15.129 if (argc != 2) 15.130 usage(argv[0]); 15.131 - ret = acm_domain_getpolicy(acm_cmd_fd); 15.132 + ret = acm_domain_getpolicy(xc_handle); 15.133 } else if (!strcmp(argv[1], "loadpolicy")) { 15.134 if (argc != 3) 15.135 usage(argv[0]); 15.136 - ret = acm_domain_loadpolicy(acm_cmd_fd, argv[2]); 15.137 + ret = acm_domain_loadpolicy(xc_handle, argv[2]); 15.138 } else if (!strcmp(argv[1], "dumpstats")) { 15.139 if (argc != 2) 15.140 usage(argv[0]); 15.141 - ret = acm_domain_dumpstats(acm_cmd_fd); 15.142 + ret = acm_domain_dumpstats(xc_handle); 15.143 } else 15.144 usage(argv[0]); 15.145 15.146 - close(acm_cmd_fd); 15.147 + xc_interface_close(xc_handle); 15.148 return ret; 15.149 }
16.1 --- a/tools/xenmon/xenbaked.c Tue May 02 09:18:55 2006 +0100 16.2 +++ b/tools/xenmon/xenbaked.c Tue May 02 15:12:06 2006 +0100 16.3 @@ -410,14 +410,13 @@ void get_tbufs(unsigned long *mfn, unsig 16.4 struct t_buf *map_tbufs(unsigned long tbufs_mfn, unsigned int num, 16.5 unsigned long size) 16.6 { 16.7 - int xc_handle; /* file descriptor for /proc/xen/privcmd */ 16.8 + int xc_handle; 16.9 struct t_buf *tbufs_mapped; 16.10 16.11 xc_handle = xc_interface_open(); 16.12 16.13 if ( xc_handle < 0 ) 16.14 { 16.15 - PERROR("Open /proc/xen/privcmd when mapping trace buffers\n"); 16.16 exit(EXIT_FAILURE); 16.17 } 16.18
17.1 --- a/tools/xenstat/libxenstat/Makefile Tue May 02 09:18:55 2006 +0100 17.2 +++ b/tools/xenstat/libxenstat/Makefile Tue May 02 15:12:06 2006 +0100 17.3 @@ -33,28 +33,26 @@ MINOR=0 17.4 LIB=src/libxenstat.a 17.5 SHLIB=src/libxenstat.so.$(MAJOR).$(MINOR) 17.6 SHLIB_LINKS=src/libxenstat.so.$(MAJOR) src/libxenstat.so 17.7 -OBJECTS=src/xenstat.o src/xen-interface.o 17.8 +OBJECTS=src/xenstat.o 17.9 SONAME_FLAGS=-Wl,-soname -Wl,libxenstat.so.$(MAJOR) 17.10 17.11 WARN_FLAGS=-Wall -Werror 17.12 17.13 CFLAGS+=-Isrc -I$(XEN_LIBXC) -I$(XEN_XENSTORE) 17.14 -LDFLAGS+=-Lsrc 17.15 +LDFLAGS+=-Lsrc -L$(XEN_XENSTORE)/ -L$(XEN_LIBXC)/ 17.16 17.17 .PHONY: all 17.18 all: $(LIB) 17.19 17.20 $(LIB): $(OBJECTS) 17.21 - $(AR) rc $@ $^ $(XEN_XENSTORE)/libxenstore.so 17.22 + $(AR) rc $@ $^ $(XEN_XENSTORE)/libxenstore.so $(XEN_LIBXC)/libxenctrl.so 17.23 $(RANLIB) $@ 17.24 17.25 $(SHLIB): $(OBJECTS) 17.26 - $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) -shared -o $@ $(OBJECTS) 17.27 + $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) -shared -o $@ $(OBJECTS) \ 17.28 + -lxenstore -lxenctrl 17.29 17.30 -src/xenstat.o: src/xenstat.c src/xenstat.h src/xen-interface.h 17.31 - $(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $< 17.32 - 17.33 -src/xen-interface.o: src/xen-interface.c src/xen-interface.h 17.34 +src/xenstat.o: src/xenstat.c src/xenstat.h 17.35 $(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $< 17.36 17.37 src/libxenstat.so.$(MAJOR): $(LIB)
18.1 --- a/tools/xenstat/libxenstat/src/xenstat.c Tue May 02 09:18:55 2006 +0100 18.2 +++ b/tools/xenstat/libxenstat/src/xenstat.c Tue May 02 15:12:06 2006 +0100 18.3 @@ -20,10 +20,11 @@ 18.4 #include <stdio.h> 18.5 #include <string.h> 18.6 #include <unistd.h> 18.7 -#include <xen-interface.h> 18.8 #include <xs.h> 18.9 #include "xenstat.h" 18.10 18.11 +#include "xenctrl.h" 18.12 + 18.13 /* 18.14 * Types 18.15 */ 18.16 @@ -31,7 +32,7 @@ 18.17 #define VERSION_SIZE (2 * SHORT_ASC_LEN + 1 + sizeof(xen_extraversion_t) + 1) 18.18 18.19 struct xenstat_handle { 18.20 - xi_handle *xihandle; 18.21 + int xc_handle; 18.22 struct xs_handle *xshandle; /* xenstore handle */ 18.23 int page_size; 18.24 FILE *procnetdev; 18.25 @@ -150,9 +151,9 @@ xenstat_handle *xenstat_init(void) 18.26 } 18.27 #endif 18.28 18.29 - handle->xihandle = xi_init(); 18.30 - if (handle->xihandle == NULL) { 18.31 - perror("xi_init"); 18.32 + handle->xc_handle = xc_interface_open(); 18.33 + if (handle->xc_handle == -1) { 18.34 + perror("xc_interface_open"); 18.35 free(handle); 18.36 return NULL; 18.37 } 18.38 @@ -160,6 +161,7 @@ xenstat_handle *xenstat_init(void) 18.39 handle->xshandle = xs_daemon_open_readonly(); /* open handle to xenstore*/ 18.40 if (handle->xshandle == NULL) { 18.41 perror("unable to open xenstore\n"); 18.42 + xc_interface_close(handle->xc_handle); 18.43 free(handle); 18.44 return NULL; 18.45 } 18.46 @@ -173,7 +175,7 @@ void xenstat_uninit(xenstat_handle * han 18.47 if (handle) { 18.48 for (i = 0; i < NUM_COLLECTORS; i++) 18.49 collectors[i].uninit(handle); 18.50 - xi_uninit(handle->xihandle); 18.51 + xc_interface_close(handle->xc_handle); 18.52 xs_daemon_close(handle->xshandle); 18.53 free(handle); 18.54 } 18.55 @@ -197,7 +199,7 @@ xenstat_node *xenstat_get_node(xenstat_h 18.56 node->handle = handle; 18.57 18.58 /* Get information about the physical system */ 18.59 - if (xi_get_physinfo(handle->xihandle, &physinfo) < 0) { 18.60 + if (xc_physinfo(handle->xc_handle, &physinfo) < 0) { 18.61 free(node); 18.62 return NULL; 18.63 } 18.64 @@ -223,9 +225,8 @@ xenstat_node *xenstat_get_node(xenstat_h 18.65 do { 18.66 xenstat_domain *domain; 18.67 18.68 - new_domains = xi_get_domaininfolist(handle->xihandle, 18.69 - domaininfo, num_domains, 18.70 - DOMAIN_CHUNK_SIZE); 18.71 + new_domains = xc_domain_getinfolist(handle->xc_handle, 18.72 + num_domains, DOMAIN_CHUNK_SIZE, domaininfo); 18.73 18.74 node->domains = realloc(node->domains, 18.75 (num_domains + new_domains) 18.76 @@ -467,8 +468,8 @@ static int xenstat_collect_vcpus(xenstat 18.77 /* FIXME: need to be using a more efficient mechanism*/ 18.78 dom0_getvcpuinfo_t info; 18.79 18.80 - if (xi_get_domain_vcpu_info(node->handle->xihandle, 18.81 - node->domains[i].id, vcpu, &info) != 0) 18.82 + if (xc_vcpu_getinfo(node->handle->xc_handle, 18.83 + node->domains[i].id, vcpu, &info) != 0) 18.84 return 0; 18.85 18.86 node->domains[i].vcpus[vcpu].online = info.online; 18.87 @@ -677,8 +678,14 @@ static int xenstat_collect_xen_version(x 18.88 /* Collect Xen version information if not already collected */ 18.89 if (node->handle->xen_version[0] == '\0') { 18.90 /* Get the Xen version number and extraversion string */ 18.91 - if (xi_get_xen_version(node->handle->xihandle, 18.92 - &vnum, &version) < 0) 18.93 + vnum = xc_version(node->handle->xc_handle, 18.94 + XENVER_version, NULL); 18.95 + 18.96 + if (vnum < 0) 18.97 + return 0; 18.98 + 18.99 + if (xc_version(node->handle->xc_handle, XENVER_extraversion, 18.100 + &version) < 0) 18.101 return 0; 18.102 /* Format the version information as a string and store it */ 18.103 snprintf(node->handle->xen_version, VERSION_SIZE, "%ld.%ld%s",
19.1 --- a/tools/xentrace/xentrace.c Tue May 02 09:18:55 2006 +0100 19.2 +++ b/tools/xentrace/xentrace.c Tue May 02 15:12:06 2006 +0100 19.3 @@ -20,10 +20,21 @@ 19.4 #include <errno.h> 19.5 #include <argp.h> 19.6 #include <signal.h> 19.7 +#include <inttypes.h> 19.8 +#include <string.h> 19.9 19.10 -#include "xc_private.h" 19.11 +#include <xen/xen.h> 19.12 +#include <xen/trace.h> 19.13 + 19.14 +#include <xenctrl.h> 19.15 19.16 -#include <xen/trace.h> 19.17 +#define PERROR(_m, _a...) \ 19.18 +do { \ 19.19 + int __saved_errno = errno; \ 19.20 + fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \ 19.21 + __saved_errno, strerror(__saved_errno)); \ 19.22 + errno = __saved_errno; \ 19.23 +} while (0) 19.24 19.25 extern FILE *stderr; 19.26 19.27 @@ -100,26 +111,22 @@ void write_rec(unsigned int cpu, struct 19.28 */ 19.29 void get_tbufs(unsigned long *mfn, unsigned long *size) 19.30 { 19.31 - int ret; 19.32 - dom0_op_t op; /* dom0 op we'll build */ 19.33 + uint32_t size32; 19.34 int xc_handle = xc_interface_open(); /* for accessing control interface */ 19.35 19.36 - op.cmd = DOM0_TBUFCONTROL; 19.37 - op.interface_version = DOM0_INTERFACE_VERSION; 19.38 - op.u.tbufcontrol.op = DOM0_TBUF_GET_INFO; 19.39 + if (xc_tbuf_get_size(xc_handle, &size32) != 0) 19.40 + goto fail; 19.41 + *size = size32; 19.42 19.43 - ret = do_dom0_op(xc_handle, &op); 19.44 + if (xc_tbuf_get_mfn(xc_handle, mfn) != 0) 19.45 + goto fail; 19.46 19.47 xc_interface_close(xc_handle); 19.48 + return; 19.49 19.50 - if ( ret != 0 ) 19.51 - { 19.52 - PERROR("Failure to get trace buffer pointer from Xen"); 19.53 - exit(EXIT_FAILURE); 19.54 - } 19.55 - 19.56 - *mfn = op.u.tbufcontrol.buffer_mfn; 19.57 - *size = op.u.tbufcontrol.size; 19.58 +fail: 19.59 + PERROR("Failure to get trace buffer pointer from Xen"); 19.60 + exit(EXIT_FAILURE); 19.61 } 19.62 19.63 /** 19.64 @@ -133,14 +140,13 @@ void get_tbufs(unsigned long *mfn, unsig 19.65 struct t_buf *map_tbufs(unsigned long tbufs_mfn, unsigned int num, 19.66 unsigned long size) 19.67 { 19.68 - int xc_handle; /* file descriptor for /proc/xen/privcmd */ 19.69 + int xc_handle; 19.70 struct t_buf *tbufs_mapped; 19.71 19.72 xc_handle = xc_interface_open(); 19.73 19.74 if ( xc_handle < 0 ) 19.75 { 19.76 - PERROR("Open /proc/xen/privcmd when mapping trace buffers\n"); 19.77 exit(EXIT_FAILURE); 19.78 } 19.79 19.80 @@ -167,24 +173,17 @@ struct t_buf *map_tbufs(unsigned long tb 19.81 */ 19.82 void set_mask(uint32_t mask, int type) 19.83 { 19.84 - int ret; 19.85 - dom0_op_t op; /* dom0 op we'll build */ 19.86 + int ret = 0; 19.87 int xc_handle = xc_interface_open(); /* for accessing control interface */ 19.88 19.89 - op.cmd = DOM0_TBUFCONTROL; 19.90 - op.interface_version = DOM0_INTERFACE_VERSION; 19.91 - if (type == 1) { /* cpu mask */ 19.92 - op.u.tbufcontrol.op = DOM0_TBUF_SET_CPU_MASK; 19.93 - op.u.tbufcontrol.cpu_mask = mask; 19.94 + if (type == 1) { 19.95 + ret = xc_tbuf_set_cpu_mask(xc_handle, mask); 19.96 fprintf(stderr, "change cpumask to 0x%x\n", mask); 19.97 - }else if (type == 0) { /* event mask */ 19.98 - op.u.tbufcontrol.op = DOM0_TBUF_SET_EVT_MASK; 19.99 - op.u.tbufcontrol.evt_mask = mask; 19.100 + } else if (type == 0) { 19.101 + ret = xc_tbuf_set_evt_mask(xc_handle, mask); 19.102 fprintf(stderr, "change evtmask to 0x%x\n", mask); 19.103 } 19.104 19.105 - ret = do_dom0_op(xc_handle, &op); 19.106 - 19.107 xc_interface_close(xc_handle); 19.108 19.109 if ( ret != 0 ) 19.110 @@ -192,7 +191,6 @@ void set_mask(uint32_t mask, int type) 19.111 PERROR("Failure to get trace buffer pointer from Xen and set the new mask"); 19.112 exit(EXIT_FAILURE); 19.113 } 19.114 - 19.115 } 19.116 19.117 /** 19.118 @@ -260,14 +258,11 @@ struct t_rec **init_rec_ptrs(struct t_bu 19.119 */ 19.120 unsigned int get_num_cpus(void) 19.121 { 19.122 - dom0_op_t op; 19.123 + xc_physinfo_t physinfo; 19.124 int xc_handle = xc_interface_open(); 19.125 int ret; 19.126 19.127 - op.cmd = DOM0_PHYSINFO; 19.128 - op.interface_version = DOM0_INTERFACE_VERSION; 19.129 - 19.130 - ret = do_dom0_op(xc_handle, &op); 19.131 + ret = xc_physinfo(xc_handle, &physinfo); 19.132 19.133 if ( ret != 0 ) 19.134 { 19.135 @@ -277,10 +272,10 @@ unsigned int get_num_cpus(void) 19.136 19.137 xc_interface_close(xc_handle); 19.138 19.139 - return (op.u.physinfo.threads_per_core * 19.140 - op.u.physinfo.cores_per_socket * 19.141 - op.u.physinfo.sockets_per_node * 19.142 - op.u.physinfo.nr_nodes); 19.143 + return (physinfo.threads_per_core * 19.144 + physinfo.cores_per_socket * 19.145 + physinfo.sockets_per_node * 19.146 + physinfo.nr_nodes); 19.147 } 19.148 19.149