make privcmd interface private to libxc
PATCH 1/1 make privcmd interface private to libxc
As discussed, this is the first part to cleaning up the explicit use of the kernel/dom0 interface that should be private to libxc. This only deals with privcmd stuff; later patches will add new interfaces for /dev/xen/evtchn, and the remaining bits of xenstore interfaces.
regards
john
# HG changeset patch
# User [email protected]
# Node ID 8e9e3a38536a6044eddeb4890347e73ded27edf2
# Parent 9df603eff58a6e5126b0eb82906b961a684575a7
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.
tools/Rules.mk +14 -6
@@ -23,15 +23,23 @@ %.o: %.cc $(CC) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< -.PHONY: mk-symlinks -mk-symlinks: LINUX_ROOT=$(XEN_ROOT)/linux-2.6-xen-sparse -mk-symlinks: +OS = $(shell uname -s) + +.PHONY: mk-symlinks mk-symlinks-xen mk-symlinks-$(OS) + +mk-symlinks-Linux: LINUX_ROOT=$(XEN_ROOT)/linux-2.6-xen-sparse +mk-symlinks-Linux: + mkdir -p xen/linux + ( cd xen/linux && \ + ln -sf ../../$(LINUX_ROOT)/include/xen/public/*.h . ) + ( cd xen && rm -f sys && ln -sf linux sys ) + +mk-symlinks-xen: mkdir -p xen ( cd xen && ln -sf ../$(XEN_ROOT)/xen/include/public/*.h . ) mkdir -p xen/hvm ( cd xen/hvm && ln -sf ../../$(XEN_ROOT)/xen/include/public/hvm/*.h . ) mkdir -p xen/io ( cd xen/io && ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . ) - mkdir -p xen/linux - ( cd xen/linux && \ - ln -sf ../../$(LINUX_ROOT)/include/xen/public/*.h . ) + +mk-symlinks: mk-symlinks-xen mk-symlinks-$(OS)
tools/debugger/pdb/pdb_caml_process.c +0 -1
@@ -18,7 +18,6 @@#include <xenctrl.h> #include <xen/xen.h> #include <xen/io/domain_controller.h> -#include <xen/linux/privcmd.h> #include "pdb_module.h" #include "pdb_caml_xen.h"
tools/debugger/pdb/pdb_caml_xcs.c +0 -1
@@ -21,7 +21,6 @@#include <xen/xen.h> #include <xen/io/domain_controller.h> -#include <xen/linux/privcmd.h> #include <arpa/inet.h> #include <xcs_proto.h>
tools/libxc/Makefile +5 -0
@@ -16,6 +16,7 @@ SRCS += xc_domain.c SRCS += xc_evtchn.c SRCS += xc_misc.c +SRCS += xc_acm.c SRCS += xc_physdev.c SRCS += xc_private.c SRCS += xc_sedf.c
@@ -26,6 +27,10 @@ SRCS += xc_ptrace_core.c SRCS += xc_pagetab.c endif + +SRCS_Linux += xc_linux.c + +SRCS += $(SRCS_$(shell uname -s)) BUILD_SRCS := BUILD_SRCS += xc_linux_build.c
tools/libxc/xc_linux_save.c +4 -7
@@ -12,6 +12,7 @@#include <unistd.h> #include <sys/time.h> +#include "xc_private.h" #include "xg_private.h" #include "xg_save_restore.h"
@@ -505,7 +506,6 @@ int prot) {struct xen_machphys_mfn_list xmml; -privcmd_mmap_t ioctlx;privcmd_mmap_entry_t *entries;unsigned long m2p_chunks, m2p_size;unsigned long *m2p;
@@ -537,18 +537,15 @@return NULL ; } - ioctlx.num = m2p_chunks; - ioctlx.dom =DOMID_XEN ; - ioctlx.entry = entries; -for (i=0 ; i < m2p_chunks; i++) { entries[i].va = (unsigned long )(((void *)m2p) + (i *M2P_CHUNK_SIZE )); entries[i].mfn = xmml.extent_start[i]; entries[i].npages =M2P_CHUNK_SIZE >>PAGE_SHIFT ; } -if ((rc =ioctl (xc_handle,IOCTL_PRIVCMD_MMAP , &ioctlx)) <0 ) { -ERR ("ioctl_mmap failed (rc = %d)" , rc); +if ((rc =xc_map_foreign_ranges (xc_handle,DOMID_XEN , + entries, m2p_chunks)) <0 ) { +ERR ("xc_mmap_foreign_ranges failed (rc = %d)" , rc);return NULL ; }
tools/libxc/xc_misc.c +0 -13
@@ -5,19 +5,6 @@*/ #include "xc_private.h" - -int xc_interface_open (void ) -{ -int fd =open ("/proc/xen/privcmd" ,O_RDWR ); -if ( fd ==-1 ) -PERROR ("Could not obtain handle on privileged command interface" ); -return fd; -} - -int xc_interface_close (int xc_handle) -{ -return close (xc_handle); -} int xc_readconsolering(int xc_handle, char **pbuffer,
tools/libxc/xc_private.c +0 -57
63 lines not on this page · raw message
tools/libxc/xc_private.h +4 -33
@@ -15,7 +15,7 @@#include "xenctrl.h" -#include <xen/linux/privcmd.h> +#include <xen/sys/privcmd.h> /* valgrind cannot see when a hypercall has filled in some values. For this reason, we must zero the privcmd_hypercall_t or dom0_op_t instance before a
@@ -56,20 +56,7 @@ errno = saved_errno; } -static inline int do_privcmd (int xc_handle, -unsigned int cmd, -unsigned long data) -{ -return ioctl (xc_handle, cmd, data); -} - -static inline int do_xen_hypercall (int xc_handle, -privcmd_hypercall_t *hypercall) -{ -return do_privcmd (xc_handle, -IOCTL_PRIVCMD_HYPERCALL , - (unsigned long )hypercall); -} +int do_xen_hypercall (int xc_handle,privcmd_hypercall_t *hypercall);static inline int do_xen_version (int xc_handle,int cmd,void *dest) {
@@ -111,23 +98,7 @@ return ret; } - -/* -* ioctl-based mfn mapping interface -*/ - -/* -typedef struct privcmd_mmap_entry { -unsigned long va; -unsigned long mfn; -unsigned long npages; -} privcmd_mmap_entry_t; - -typedef struct privcmd_mmap { -int num; -domid_t dom; -privcmd_mmap_entry_t *entry; -} privcmd_mmap_t; -*/ +int xc_map_foreign_ranges (int xc_handle,uint32_t dom, +privcmd_mmap_entry_t *entries,int nr);#endif /* __XC_PRIVATE_H__ */
tools/libxc/xc_tbuf.c +46 -0
55 lines not on this page · raw message
tools/libxc/xenctrl.h +15 -0
@@ -19,6 +19,7 @@#include <xen/sched_ctl.h> #include <xen/memory.h> #include <xen/acm.h> +#include <xen/acm_ops.h> #ifdef __ia64__#define XC_PAGE_SHIFT 14
@@ -560,6 +561,18 @@*/ int xc_tbuf_get_size (int xc_handle,uint32_t *size); +/** +* This function retrieves the machine frame of the trace buffer. + +* @parm xc_handle a handle to an open hypervisor interface +* @parm mfn will contain the machine frame of the buffer. +* @return 0 on success, -1 on failure. +*/ +int xc_tbuf_get_mfn (int xc_handle,unsigned long *mfn); + +int xc_tbuf_set_cpu_mask (int xc_handle,uint32_t mask); + +int xc_tbuf_set_evt_mask (int xc_handle,uint32_t mask);/* Execute a privileged dom0 operation. */ int xc_dom0_op (int xc_handle,dom0_op_t *op);
@@ -581,4 +594,6 @@ unsigned long long ptr, unsigned long long val);int xc_finish_mmu_updates (int xc_handle,xc_mmu_t *mmu); +int xc_acm_op (int xc_handle,struct acm_op *op); +#endif
tools/libxc/xg_private.h +1 -1
@@ -13,7 +13,7 @@#include "xenctrl.h" #include "xenguest.h" -#include <xen/linux/privcmd.h> +#include <xen/sys/privcmd.h> #include <xen/memory.h> /* valgrind cannot see when a hypercall has filled in some values. For this
tools/python/xen/lowlevel/acm/acm.c +16 -39
102 lines not on this page · raw message
tools/security/secpol_tool.c +18 -55
139 lines not on this page · raw message
tools/xenmon/xenbaked.c +1 -2
@@ -410,14 +410,13 @@struct t_buf *map_tbufs (unsigned long tbufs_mfn,unsigned int num,unsigned long size) { -int xc_handle;/* file descriptor for /proc/xen/privcmd */ +int xc_handle;struct t_buf *tbufs_mapped; xc_handle =xc_interface_open ();if ( xc_handle <0 ) { -PERROR ("Open /proc/xen/privcmd when mapping trace buffers\n" );exit (EXIT_FAILURE ); }
tools/xenstat/libxenstat/Makefile +6 -8
@@ -33,28 +33,26 @@ LIB=src/libxenstat.a SHLIB=src/libxenstat.so.$(MAJOR).$(MINOR) SHLIB_LINKS=src/libxenstat.so.$(MAJOR) src/libxenstat.so -OBJECTS=src/xenstat.o src/xen-interface.o +OBJECTS=src/xenstat.o SONAME_FLAGS=-Wl,-soname -Wl,libxenstat.so.$(MAJOR) WARN_FLAGS=-Wall -Werror CFLAGS+=-Isrc -I$(XEN_LIBXC) -I$(XEN_XENSTORE) -LDFLAGS+=-Lsrc +LDFLAGS+=-Lsrc -L$(XEN_XENSTORE)/ -L$(XEN_LIBXC)/ .PHONY: all all: $(LIB) $(LIB): $(OBJECTS) - $(AR) rc $@ $^ $(XEN_XENSTORE)/libxenstore.so + $(AR) rc $@ $^ $(XEN_XENSTORE)/libxenstore.so $(XEN_LIBXC)/libxenctrl.so $(RANLIB) $@ $(SHLIB): $(OBJECTS) - $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) -shared -o $@ $(OBJECTS) + $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) -shared -o $@ $(OBJECTS) \ + -lxenstore -lxenctrl -src/xenstat.o: src/xenstat.c src/xenstat.h src/xen-interface.h - $(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $< - -src/xen-interface.o: src/xen-interface.c src/xen-interface.h +src/xenstat.o: src/xenstat.c src/xenstat.h $(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $< src/libxenstat.so.$(MAJOR): $(LIB)
tools/xenstat/libxenstat/src/xenstat.c +21 -14
@@ -20,9 +20,10 @@#include <stdio.h> #include <string.h> #include <unistd.h> -#include <xen-interface.h> #include <xs.h> #include "xenstat.h" + +#include "xenctrl.h" /* * Types
@@ -31,7 +32,7 @@#define VERSION_SIZE (2 * SHORT_ASC_LEN + 1 + sizeof(xen_extraversion_t) + 1)struct xenstat_handle { -xi_handle *xihandle; +int xc_handle;struct xs_handle *xshandle;/* xenstore handle */ int page_size;FILE *procnetdev;
@@ -150,9 +151,9 @@ }#endif - handle->xihandle =xi_init (); -if (handle->xihandle ==NULL ) { -perror ("xi_init" ); + handle->xc_handle =xc_interface_open (); +if (handle->xc_handle ==-1 ) { +perror ("xc_interface_open" );free (handle);return NULL ; }
@@ -160,6 +161,7 @@ handle->xshandle =xs_daemon_open_readonly ();/* open handle to xenstore*/ if (handle->xshandle ==NULL ) {perror ("unable to open xenstore\n" ); +xc_interface_close (handle->xc_handle);free (handle);return NULL ; }
@@ -173,7 +175,7 @@if (handle) {for (i =0 ; i <NUM_COLLECTORS ; i++) collectors[i].uninit (handle); -xi_uninit (handle->xihandle); +xc_interface_close (handle->xc_handle);xs_daemon_close (handle->xshandle);free (handle); }
@@ -197,7 +199,7 @@ node->handle = handle;/* Get information about the physical system */ -if (xi_get_physinfo (handle->xihandle, &physinfo) <0 ) { +if (xc_physinfo (handle->xc_handle, &physinfo) <0 ) {free (node);return NULL ; }
@@ -223,9 +225,8 @@ do { xenstat_domain *domain; - new_domains = xi_get_domaininfolist(handle->xihandle, - domaininfo, num_domains, - DOMAIN_CHUNK_SIZE); + new_domains = xc_domain_getinfolist(handle->xc_handle, + num_domains, DOMAIN_CHUNK_SIZE, domaininfo); node->domains = realloc(node->domains, (num_domains + new_domains)
@@ -467,8 +468,8 @@/* FIXME: need to be using a more efficient mechanism*/ dom0_getvcpuinfo_t info; -if (xi_get_domain_vcpu_info (node->handle->xihandle, - node->domains[i].id, vcpu, &info) !=0 ) +if (xc_vcpu_getinfo (node->handle->xc_handle, + node->domains[i].id, vcpu, &info) !=0 )return 0 ; node->domains[i].vcpus[vcpu].online = info.online;
@@ -677,8 +678,14 @@/* Collect Xen version information if not already collected */ if (node->handle->xen_version[0 ] =='\0' ) {/* Get the Xen version number and extraversion string */ -if (xi_get_xen_version (node->handle->xihandle, - &vnum, &version) <0 ) + vnum =xc_version (node->handle->xc_handle, + XENVER_version,NULL ); + +if (vnum <0 ) +return 0 ; + +if (xc_version (node->handle->xc_handle, XENVER_extraversion, + &version) <0 )return 0 ;/* Format the version information as a string and store it */ snprintf(node->handle->xen_version, VERSION_SIZE, "%ld.%ld%s",
tools/xentrace/xentrace.c +38 -43
143 lines not on this page · raw message
tools/libxc/xc_acm.c new file +54 -0
54 lines not on this page · raw message
tools/libxc/xc_linux.c new file +114 -0
114 lines not on this page · raw message
tools/xenstat/libxenstat/src/xen-interface.c deleted +0 -201
201 lines not on this page · raw message
tools/xenstat/libxenstat/src/xen-interface.h deleted +0 -46
46 lines not on this page · raw message
PATCH RESEND 1/1 make privcmd interface private to libxc
Quoted 4 lines · John Levon
As discussed, this is the first part to cleaning up the explicit use of the kernel/dom0 interface that should be private to libxc. This only deals with privcmd stuff; later patches will add new interfaces for
/dev/xen/evtchn, and the remaining bits of xenstore interfaces.
Sent again. It seems the previous patch didn't actually apply (I thought I'd tested applying it to a clean tip, but apparently not).
regards
john
# HG changeset patch
# User [email protected]
# Node ID e276e89e24ae8744f9313869b45114e0effbfcb9
# Parent a95e677073c1fa420f10c572e0a2f6925e6853fa
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.
tools/Rules.mk +14 -6
@@ -23,15 +23,23 @@ CFLAGS += -D__XEN_TOOLS__ %.o: %.cc $(CC) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< -.PHONY: mk-symlinks -mk-symlinks: LINUX_ROOT=$(XEN_ROOT)/linux-2.6-xen-sparse -mk-symlinks: +OS = $(shell uname -s) + +.PHONY: mk-symlinks mk-symlinks-xen mk-symlinks-$(OS) + +mk-symlinks-Linux: LINUX_ROOT=$(XEN_ROOT)/linux-2.6-xen-sparse +mk-symlinks-Linux: + mkdir -p xen/linux + ( cd xen/linux && \ + ln -sf ../../$(LINUX_ROOT)/include/xen/public/*.h . ) + ( cd xen && rm -f sys && ln -sf linux sys ) + +mk-symlinks-xen: mkdir -p xen ( cd xen && ln -sf ../$(XEN_ROOT)/xen/include/public/*.h . ) mkdir -p xen/hvm ( cd xen/hvm && ln -sf ../../$(XEN_ROOT)/xen/include/public/hvm/*.h . ) mkdir -p xen/io ( cd xen/io && ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . ) - mkdir -p xen/linux - ( cd xen/linux && \ - ln -sf ../../$(LINUX_ROOT)/include/xen/public/*.h . ) + +mk-symlinks: mk-symlinks-xen mk-symlinks-$(OS)
tools/debugger/pdb/pdb_caml_process.c +0 -1
@@ -18,7 +18,6 @@#include <xenctrl.h> #include <xen/xen.h> #include <xen/io/domain_controller.h> -#include <xen/linux/privcmd.h> #include "pdb_module.h" #include "pdb_caml_xen.h"
tools/debugger/pdb/pdb_caml_xcs.c +0 -1
@@ -21,7 +21,6 @@#include <xen/xen.h> #include <xen/io/domain_controller.h> -#include <xen/linux/privcmd.h> #include <arpa/inet.h> #include <xcs_proto.h>
tools/libxc/Makefile +5 -0
@@ -16,6 +16,7 @@ SRCS += xc_domain.c SRCS += xc_domain.c SRCS += xc_evtchn.c SRCS += xc_misc.c +SRCS += xc_acm.c SRCS += xc_physdev.c SRCS += xc_private.c SRCS += xc_sedf.c
@@ -26,6 +27,10 @@ SRCS += xc_ptrace_core.c SRCS += xc_ptrace_core.c SRCS += xc_pagetab.c endif + +SRCS_Linux += xc_linux.c + +SRCS += $(SRCS_$(shell uname -s)) BUILD_SRCS := BUILD_SRCS += xc_linux_build.c
tools/libxc/xc_linux_save.c +4 -7
@@ -12,6 +12,7 @@#include <unistd.h> #include <sys/time.h> +#include "xc_private.h" #include "xg_private.h" #include "xg_save_restore.h"
@@ -505,7 +506,6 @@ static unsigned long *xc_map_m2p(int xc_ int prot) {struct xen_machphys_mfn_list xmml; -privcmd_mmap_t ioctlx;privcmd_mmap_entry_t *entries;unsigned long m2p_chunks, m2p_size;unsigned long *m2p;
@@ -539,18 +539,15 @@ static unsigned long *xc_map_m2p(int xc_return NULL ; } - ioctlx.num = m2p_chunks; - ioctlx.dom =DOMID_XEN ; - ioctlx.entry = entries; -for (i=0 ; i < m2p_chunks; i++) { entries[i].va = (unsigned long )(((void *)m2p) + (i *M2P_CHUNK_SIZE )); entries[i].mfn = extent_start[i]; entries[i].npages =M2P_CHUNK_SIZE >>PAGE_SHIFT ; } -if ((rc =ioctl (xc_handle,IOCTL_PRIVCMD_MMAP , &ioctlx)) <0 ) { -ERR ("ioctl_mmap failed (rc = %d)" , rc); +if ((rc =xc_map_foreign_ranges (xc_handle,DOMID_XEN , + entries, m2p_chunks)) <0 ) { +ERR ("xc_mmap_foreign_ranges failed (rc = %d)" , rc);return NULL ; }
tools/libxc/xc_misc.c +0 -13
@@ -5,19 +5,6 @@*/ #include "xc_private.h" - -int xc_interface_open (void ) -{ -int fd =open ("/proc/xen/privcmd" ,O_RDWR ); -if ( fd ==-1 ) -PERROR ("Could not obtain handle on privileged command interface" ); -return fd; -} - -int xc_interface_close (int xc_handle) -{ -return close (xc_handle); -} int xc_readconsolering(int xc_handle, char **pbuffer,
tools/libxc/xc_private.c +0 -57
63 lines not on this page · raw message
tools/libxc/xc_private.h +4 -33
@@ -15,7 +15,7 @@#include "xenctrl.h" -#include <xen/linux/privcmd.h> +#include <xen/sys/privcmd.h> /* valgrind cannot see when a hypercall has filled in some values. For this reason, we must zero the privcmd_hypercall_t or dom0_op_t instance before a
@@ -56,20 +56,7 @@ static inline void safe_munlock(const vo errno = saved_errno; } -static inline int do_privcmd (int xc_handle, -unsigned int cmd, -unsigned long data) -{ -return ioctl (xc_handle, cmd, data); -} - -static inline int do_xen_hypercall (int xc_handle, -privcmd_hypercall_t *hypercall) -{ -return do_privcmd (xc_handle, -IOCTL_PRIVCMD_HYPERCALL , - (unsigned long )hypercall); -} +int do_xen_hypercall (int xc_handle,privcmd_hypercall_t *hypercall);static inline int do_xen_version (int xc_handle,int cmd,void *dest) {
@@ -111,23 +98,7 @@ static inline int do_dom0_op(int xc_hand return ret; } - -/* -* ioctl-based mfn mapping interface -*/ - -/* -typedef struct privcmd_mmap_entry { -unsigned long va; -unsigned long mfn; -unsigned long npages; -} privcmd_mmap_entry_t; - -typedef struct privcmd_mmap { -int num; -domid_t dom; -privcmd_mmap_entry_t *entry; -} privcmd_mmap_t; -*/ +int xc_map_foreign_ranges (int xc_handle,uint32_t dom, +privcmd_mmap_entry_t *entries,int nr);#endif /* __XC_PRIVATE_H__ */
tools/libxc/xc_tbuf.c +46 -0
55 lines not on this page · raw message
tools/libxc/xenctrl.h +15 -0
@@ -19,6 +19,7 @@#include <xen/sched_ctl.h> #include <xen/memory.h> #include <xen/acm.h> +#include <xen/acm_ops.h> #ifdef __ia64__#define XC_PAGE_SHIFT 14
@@ -560,6 +561,18 @@ int xc_tbuf_set_size(int xc_handle, uint*/ int xc_tbuf_get_size (int xc_handle,uint32_t *size); +/** +* This function retrieves the machine frame of the trace buffer. + +* @parm xc_handle a handle to an open hypervisor interface +* @parm mfn will contain the machine frame of the buffer. +* @return 0 on success, -1 on failure. +*/ +int xc_tbuf_get_mfn (int xc_handle,unsigned long *mfn); + +int xc_tbuf_set_cpu_mask (int xc_handle,uint32_t mask); + +int xc_tbuf_set_evt_mask (int xc_handle,uint32_t mask);/* Execute a privileged dom0 operation. */ int xc_dom0_op (int xc_handle,dom0_op_t *op);
@@ -581,4 +594,6 @@ int xc_add_mmu_update(int xc_handle, xc_ unsigned long long ptr, unsigned long long val);int xc_finish_mmu_updates (int xc_handle,xc_mmu_t *mmu); +int xc_acm_op (int xc_handle,struct acm_op *op); +#endif
tools/libxc/xg_private.h +1 -1
@@ -13,7 +13,7 @@#include "xenctrl.h" #include "xenguest.h" -#include <xen/linux/privcmd.h> +#include <xen/sys/privcmd.h> #include <xen/memory.h> /* valgrind cannot see when a hypercall has filled in some values. For this
tools/python/xen/lowlevel/acm/acm.c +16 -39
102 lines not on this page · raw message
tools/security/secpol_tool.c +18 -55
139 lines not on this page · raw message
tools/xenmon/xenbaked.c +1 -2
@@ -410,14 +410,13 @@ struct t_buf *map_tbufs(unsigned long tbstruct t_buf *map_tbufs (unsigned long tbufs_mfn,unsigned int num,unsigned long size) { -int xc_handle;/* file descriptor for /proc/xen/privcmd */ +int xc_handle;struct t_buf *tbufs_mapped; xc_handle =xc_interface_open ();if ( xc_handle <0 ) { -PERROR ("Open /proc/xen/privcmd when mapping trace buffers\n" );exit (EXIT_FAILURE ); }
tools/xenstat/libxenstat/Makefile +6 -8
@@ -33,28 +33,26 @@ LIB=src/libxenstat.a LIB=src/libxenstat.a SHLIB=src/libxenstat.so.$(MAJOR).$(MINOR) SHLIB_LINKS=src/libxenstat.so.$(MAJOR) src/libxenstat.so -OBJECTS=src/xenstat.o src/xen-interface.o +OBJECTS=src/xenstat.o SONAME_FLAGS=-Wl,-soname -Wl,libxenstat.so.$(MAJOR) WARN_FLAGS=-Wall -Werror CFLAGS+=-Isrc -I$(XEN_LIBXC) -I$(XEN_XENSTORE) -LDFLAGS+=-Lsrc +LDFLAGS+=-Lsrc -L$(XEN_XENSTORE)/ -L$(XEN_LIBXC)/ .PHONY: all all: $(LIB) $(LIB): $(OBJECTS) - $(AR) rc $@ $^ $(XEN_XENSTORE)/libxenstore.so + $(AR) rc $@ $^ $(XEN_XENSTORE)/libxenstore.so $(XEN_LIBXC)/libxenctrl.so $(RANLIB) $@ $(SHLIB): $(OBJECTS) - $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) -shared -o $@ $(OBJECTS) + $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) -shared -o $@ $(OBJECTS) \ + -lxenstore -lxenctrl -src/xenstat.o: src/xenstat.c src/xenstat.h src/xen-interface.h - $(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $< - -src/xen-interface.o: src/xen-interface.c src/xen-interface.h +src/xenstat.o: src/xenstat.c src/xenstat.h $(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $< src/libxenstat.so.$(MAJOR): $(LIB)
tools/xenstat/libxenstat/src/xenstat.c +21 -14
@@ -20,9 +20,10 @@#include <stdio.h> #include <string.h> #include <unistd.h> -#include <xen-interface.h> #include <xs.h> #include "xenstat.h" + +#include "xenctrl.h" /* * Types
@@ -31,7 +32,7 @@#define VERSION_SIZE (2 * SHORT_ASC_LEN + 1 + sizeof(xen_extraversion_t) + 1)struct xenstat_handle { -xi_handle *xihandle; +int xc_handle;struct xs_handle *xshandle;/* xenstore handle */ int page_size;FILE *procnetdev;
@@ -150,9 +151,9 @@ xenstat_handle *xenstat_init(void) }#endif - handle->xihandle =xi_init (); -if (handle->xihandle ==NULL ) { -perror ("xi_init" ); + handle->xc_handle =xc_interface_open (); +if (handle->xc_handle ==-1 ) { +perror ("xc_interface_open" );free (handle);return NULL ; }
@@ -160,6 +161,7 @@ xenstat_handle *xenstat_init(void) handle->xshandle =xs_daemon_open_readonly ();/* open handle to xenstore*/ if (handle->xshandle ==NULL ) {perror ("unable to open xenstore\n" ); +xc_interface_close (handle->xc_handle);free (handle);return NULL ; }
@@ -173,7 +175,7 @@ void xenstat_uninit(xenstat_handle * hanif (handle) {for (i =0 ; i <NUM_COLLECTORS ; i++) collectors[i].uninit (handle); -xi_uninit (handle->xihandle); +xc_interface_close (handle->xc_handle);xs_daemon_close (handle->xshandle);free (handle); }
@@ -197,7 +199,7 @@ xenstat_node *xenstat_get_node(xenstat_h node->handle = handle;/* Get information about the physical system */ -if (xi_get_physinfo (handle->xihandle, &physinfo) <0 ) { +if (xc_physinfo (handle->xc_handle, &physinfo) <0 ) {free (node);return NULL ; }
@@ -223,9 +225,8 @@ xenstat_node *xenstat_get_node(xenstat_h do { xenstat_domain *domain; - new_domains = xi_get_domaininfolist(handle->xihandle, - domaininfo, num_domains, - DOMAIN_CHUNK_SIZE); + new_domains = xc_domain_getinfolist(handle->xc_handle, + num_domains, DOMAIN_CHUNK_SIZE, domaininfo); node->domains = realloc(node->domains, (num_domains + new_domains)
@@ -467,8 +468,8 @@ static int xenstat_collect_vcpus(xenstat/* FIXME: need to be using a more efficient mechanism*/ dom0_getvcpuinfo_t info; -if (xi_get_domain_vcpu_info (node->handle->xihandle, - node->domains[i].id, vcpu, &info) !=0 ) +if (xc_vcpu_getinfo (node->handle->xc_handle, + node->domains[i].id, vcpu, &info) !=0 )return 0 ; node->domains[i].vcpus[vcpu].online = info.online;
@@ -677,8 +678,14 @@ static int xenstat_collect_xen_version(x/* Collect Xen version information if not already collected */ if (node->handle->xen_version[0 ] =='\0' ) {/* Get the Xen version number and extraversion string */ -if (xi_get_xen_version (node->handle->xihandle, - &vnum, &version) <0 ) + vnum =xc_version (node->handle->xc_handle, + XENVER_version,NULL ); + +if (vnum <0 ) +return 0 ; + +if (xc_version (node->handle->xc_handle, XENVER_extraversion, + &version) <0 )return 0 ;/* Format the version information as a string and store it */ snprintf(node->handle->xen_version, VERSION_SIZE, "%ld.%ld%s",
tools/xentrace/xentrace.c +38 -43
143 lines not on this page · raw message
tools/libxc/xc_acm.c new file +54 -0
54 lines not on this page · raw message
tools/libxc/xc_linux.c new file +114 -0
114 lines not on this page · raw message
tools/xenstat/libxenstat/src/xen-interface.c deleted +0 -201
201 lines not on this page · raw message
tools/xenstat/libxenstat/src/xen-interface.h deleted +0 -46
46 lines not on this page · raw message