Begin to disentangle libxenctrl and provide some stable libraries
Subsystems (2)
Re: [Qemu-devel] [PATCH QEMU-XEN v6 5/8] xen: Switch uses of xc_map_foreign_{pages, bulk} to use libxenforeignmemory API.
In reply to Ian CampbellQuoted 51 lines · Ian Campbell
include/hw/xen/xen_common.h +22
-0@@ -41,6 +41,7 @@ static inline void *xc_map_foreign_bulk(int xc_handle, uint32_t dom, int prot,typedef int XenXC ;typedef int xenevtchn_handle ;typedef int xengnttab_handle ; +typedef int xenforeignmemory_handle ;# define XC_INTERFACE_FMT "%i"# define XC_HANDLER_INITIAL_VALUE -1@@ -104,6 +105,19 @@ static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger,return xc_interface_open (); } +#define xenforeignmemory_open (l, f) &xen_xc +static inline void *xenforeignmemory_map (XenXC *h,uint32_t dom, +int prot,size_t pages, +const xen_pfn_t arr[/*pages*/ ], +int err[/*pages*/ ]) +{ +if (err) +return xc_map_foreign_bulk (*h, dom, prot, arr, err, pages); +else +return xc_map_foreign_pages (*h, dom, prot, arr, pages); +} +#define xenforeignmemory_unmap (h, p, s) munmap(p, s * XC_PAGE_SIZE) +static inline int xc_fd (int xen_xc) {return xen_xc;@@ -149,6 +163,7 @@ static inline void xs_close(struct xs_handle *xsh)#else typedef xc_interface *XenXC ; +typedef xc_interface *xenforeignmemory_handle ;typedef xc_evtchn xenevtchn_handle ;typedef xc_gnttab xengnttab_handle ;@@ -178,6 +193,20 @@ static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger,return xc_interface_open (logger, dombuild_logger, open_flags); } +#define xenforeignmemory_open (l, f) &xen_xc +static inline void *xenforeignmemory_map (XenXC *h,uint32_t dom, +int prot,size_t pages, +const xen_pfn_t arr[/*pages*/ ], +int err[/*pages*/ ]) +{ +if (err)
include/hw/xen/xen_common.h static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger, · line 212
Quoted 10 lines
include/hw/xen/xen_common.h +7
-0+return xc_map_foreign_bulk (*h, dom, prot, arr, err, pages); + else + return xc_map_foreign_pages(*h, dom, prot, arr, pages); +} + +#define xenforeignmemory_unmap (h, p, s) munmap(p, s * XC_PAGE_SIZE) +/* FIXME There is now way to have the xen fd */ static inline int xc_fd (xc_interface *xen_xc) {
The two definitions are the same. Please introduce just one, at the bottom under the ifdef CONFIG_XEN_CTRL_INTERFACE_VERSION < 470 case.
PATCH v6 6/8 xen: Use stable library interfaces when they are available.
In reply to Ian CampbellIn Xen 4.7 we are refactoring parts libxenctrl into a number of separate libraries which will provide backward and forward API and ABI compatiblity.
Specifically libxenevtchn, libxengnttab and libxenforeignmemory.
Previous patches have already laid the groundwork for using these by switching the existing compatibility shims to reflect the intefaces to these libraries.
So all which remains is to update configure to detect the libraries and enable their use. Although they are notionally independent we take an all or nothing approach to the three libraries since they were added at the same time.
The only non-obvious bit is that we now open a proper xenforeignmemory handle for xen_fmem instead of reusing the xen_xc handle.
Build tested with 4.0 .. 4.6 (inclusive) and the patches targetting 4.7 which adds these libraries.
---
v6: Two minor formatting things.
Rebase onto "xen: fix usage of xc_domain_create in domain builder", required adjusting the configure script changes.
The rebase wasn't entirely trivial (semantically), so dropped Stefano's reviwed by.
v5: Remove ifdef check when undeffing the compat stuff.
s/now way/no way/
v4: xenforeignmemory_open is now a compat wrapper, so no ifdef.
Simplify configury by asserting that interface version 470 will always have the libraries (lack of them makes it 460).
Ran checkpatch and fixed everything except:
ERROR: need consistent spacing around '*' (ctx:WxV) +typedef xc_interface *XenXC;
Which I think is a false +ve.
Simpler configure stuff
--- configure | 42 +++++++++++++++++++++++++++++++++++++++++- include/hw/xen/xen_common.h | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 3 deletions(-)
configure +41 -1
@@ -1923,6 +1923,7 @@ fi if test "$xen" != "no" ; then xen_libs="-lxenstore -lxenctrl -lxenguest" + xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" # First we test whether Xen headers and libraries are available. # If no, we are done and there is no Xen support.
@@ -1945,16 +1946,52 @@ EOF # Xen unstable elif cat > $TMPC <<EOF && +/* + * If we have stable libs the we don't want the libxc compat + * layers, regardless of what CFLAGS we may have been given. + */ +#undef XC_WANT_COMPAT_EVTCHN_API +#undef XC_WANT_COMPAT_GNTTAB_API +#undef XC_WANT_COMPAT_MAP_FOREIGN_API #include <xenctrl.h> +#include <xenstore.h> +#include <xenevtchn.h> +#include <xengnttab.h> +#include <xenforeignmemory.h> #include <stdint.h> +#include <xen/hvm/hvm_info_table.h> +#if !defined(HVM_MAX_VCPUS) +# error HVM_MAX_VCPUS not defined +#endif int main(void) { xc_interface *xc = NULL; + xenforeignmemory_handle *xfmem; + xenevtchn_handle *xe; + xengnttab_handle *xg; xen_domain_handle_t handle; + + xs_daemon_open(); + + xc = xc_interface_open(0, 0, 0); + xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); + xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); + xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); + xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); xc_domain_create(xc, 0, handle, 0, NULL, NULL); + + xfmem = xenforeignmemory_open(0, 0); + xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); + + xe = xenevtchn_open(0, 0); + xenevtchn_fd(xe); + + xg = xengnttab_open(0, 0); + xengnttab_map_grant_ref(xg, 0, 0, 0); + return 0; } EOF - compile_prog "" "$xen_libs" + compile_prog "" "$xen_libs $xen_stable_libs" then xen_ctrl_version=470 xen=yes
@@ -2138,6 +2175,9 @@ EOF fi if test "$xen" = yes; then + if test $xen_ctrl_version -ge 470 ; then + libs_softmmu="$xen_stable_libs $libs_softmmu" + fi libs_softmmu="$xen_libs $libs_softmmu" fi fi
include/hw/xen/xen_common.h +33 -2
@@ -6,6 +6,15 @@#include <stddef.h> #include <inttypes.h> +/* +* If we have new enough libxenctrl then we do not want/need these compat +* interfaces, despite what the user supplied cflags might say. They +* must be undefined before including xenctrl.h +*/ +#undef XC_WANT_COMPAT_EVTCHN_API +#undef XC_WANT_COMPAT_GNTTAB_API +#undef XC_WANT_COMPAT_MAP_FOREIGN_API +#include <xenctrl.h> #if CONFIG_XEN_CTRL_INTERFACE_VERSION <420 # include <xs.h>
@@ -159,8 +168,8 @@ static inline void xs_close(struct xs_handle *xsh) } -/* Xen 4.1 */ -#else +/* Xen 4.1 thru 4.6 */ +#elif CONFIG_XEN_CTRL_INTERFACE_VERSION < 470typedef xc_interface *XenXC ;typedef xc_interface *xenforeignmemory_handle ;
@@ -207,6 +216,28 @@ static inline void *xenforeignmemory_map(XenXC *h, uint32_t dom,#define xenforeignmemory_unmap (h, p, s) munmap(p, s * XC_PAGE_SIZE) +/* FIXME There is no way to have the xen fd */ +static inline int xc_fd (xc_interface *xen_xc) +{ +return -1 ; +} +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 470 */ + +typedef xc_interface *XenXC ; + +# define XC_INTERFACE_FMT "%p" +# define XC_HANDLER_INITIAL_VALUE NULL + +#include <xenevtchn.h> +#include <xengnttab.h> +#include <xenforeignmemory.h> + +static inline XenXC xen_xc_interface_open (void *logger,void *dombuild_logger, +unsigned int open_flags) +{ +return xc_interface_open (logger, dombuild_logger, open_flags); +} +/* FIXME There is now way to have the xen fd */ static inline int xc_fd (xc_interface *xen_xc) {
Signature · 1 line
2.1.4
PATCH v6 6/8 xen: Use stable library interfaces when they are available.
In reply to Ian CampbellIn Xen 4.7 we are refactoring parts libxenctrl into a number of separate libraries which will provide backward and forward API and ABI compatiblity.
Specifically libxenevtchn, libxengnttab and libxenforeignmemory.
Previous patches have already laid the groundwork for using these by switching the existing compatibility shims to reflect the intefaces to these libraries.
So all which remains is to update configure to detect the libraries and enable their use. Although they are notionally independent we take an all or nothing approach to the three libraries since they were added at the same time.
The only non-obvious bit is that we now open a proper xenforeignmemory handle for xen_fmem instead of reusing the xen_xc handle.
Build tested with 4.0 .. 4.6 (inclusive) and the patches targetting 4.7 which adds these libraries.
---
v6: Two minor formatting things.
Rebase onto "xen: fix usage of xc_domain_create in domain builder", required adjusting the configure script changes.
The rebase wasn't entirely trivial (semantically), so dropped Stefano's reviwed by.
v5: Remove ifdef check when undeffing the compat stuff.
s/now way/no way/
v4: xenforeignmemory_open is now a compat wrapper, so no ifdef.
Simplify configury by asserting that interface version 470 will always have the libraries (lack of them makes it 460).
Ran checkpatch and fixed everything except:
ERROR: need consistent spacing around '*' (ctx:WxV) +typedef xc_interface *XenXC;
Which I think is a false +ve.
Simpler configure stuff
--- configure | 42 +++++++++++++++++++++++++++++++++++++++++- include/hw/xen/xen_common.h | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 3 deletions(-)
configure +41 -1
@@ -1923,6 +1923,7 @@ fi if test "$xen" != "no" ; then xen_libs="-lxenstore -lxenctrl -lxenguest" + xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" # First we test whether Xen headers and libraries are available. # If no, we are done and there is no Xen support.
@@ -1945,16 +1946,52 @@ EOF # Xen unstable elif cat > $TMPC <<EOF && +/* + * If we have stable libs the we don't want the libxc compat + * layers, regardless of what CFLAGS we may have been given. + */ +#undef XC_WANT_COMPAT_EVTCHN_API +#undef XC_WANT_COMPAT_GNTTAB_API +#undef XC_WANT_COMPAT_MAP_FOREIGN_API #include <xenctrl.h> +#include <xenstore.h> +#include <xenevtchn.h> +#include <xengnttab.h> +#include <xenforeignmemory.h> #include <stdint.h> +#include <xen/hvm/hvm_info_table.h> +#if !defined(HVM_MAX_VCPUS) +# error HVM_MAX_VCPUS not defined +#endif int main(void) { xc_interface *xc = NULL; + xenforeignmemory_handle *xfmem; + xenevtchn_handle *xe; + xengnttab_handle *xg; xen_domain_handle_t handle; + + xs_daemon_open(); + + xc = xc_interface_open(0, 0, 0); + xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); + xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); + xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); + xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); xc_domain_create(xc, 0, handle, 0, NULL, NULL); + + xfmem = xenforeignmemory_open(0, 0); + xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); + + xe = xenevtchn_open(0, 0); + xenevtchn_fd(xe); + + xg = xengnttab_open(0, 0); + xengnttab_map_grant_ref(xg, 0, 0, 0); + return 0; } EOF - compile_prog "" "$xen_libs" + compile_prog "" "$xen_libs $xen_stable_libs" then xen_ctrl_version=470 xen=yes
@@ -2138,6 +2175,9 @@ EOF fi if test "$xen" = yes; then + if test $xen_ctrl_version -ge 470 ; then + libs_softmmu="$xen_stable_libs $libs_softmmu" + fi libs_softmmu="$xen_libs $libs_softmmu" fi fi
include/hw/xen/xen_common.h +33 -2
@@ -6,6 +6,15 @@#include <stddef.h> #include <inttypes.h> +/* +* If we have new enough libxenctrl then we do not want/need these compat +* interfaces, despite what the user supplied cflags might say. They +* must be undefined before including xenctrl.h +*/ +#undef XC_WANT_COMPAT_EVTCHN_API +#undef XC_WANT_COMPAT_GNTTAB_API +#undef XC_WANT_COMPAT_MAP_FOREIGN_API +#include <xenctrl.h> #if CONFIG_XEN_CTRL_INTERFACE_VERSION <420 # include <xs.h>
@@ -159,8 +168,8 @@ static inline void xs_close(struct xs_handle *xsh) } -/* Xen 4.1 */ -#else +/* Xen 4.1 thru 4.6 */ +#elif CONFIG_XEN_CTRL_INTERFACE_VERSION < 470typedef xc_interface *XenXC ;typedef xc_interface *xenforeignmemory_handle ;
@@ -207,6 +216,28 @@ static inline void *xenforeignmemory_map(XenXC *h, uint32_t dom,#define xenforeignmemory_unmap (h, p, s) munmap(p, s * XC_PAGE_SIZE) +/* FIXME There is no way to have the xen fd */ +static inline int xc_fd (xc_interface *xen_xc) +{ +return -1 ; +} +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 470 */ + +typedef xc_interface *XenXC ; + +# define XC_INTERFACE_FMT "%p" +# define XC_HANDLER_INITIAL_VALUE NULL + +#include <xenevtchn.h> +#include <xengnttab.h> +#include <xenforeignmemory.h> + +static inline XenXC xen_xc_interface_open (void *logger,void *dombuild_logger, +unsigned int open_flags) +{ +return xc_interface_open (logger, dombuild_logger, open_flags); +} +/* FIXME There is now way to have the xen fd */ static inline int xc_fd (xc_interface *xen_xc) {
Signature · 1 line
2.1.4
Re: [PATCH QEMU-XEN v6 6/8] xen: Use stable library interfaces when they are available.
Quoted 15 lines · Ian Campbell
In Xen 4.7 we are refactoring parts libxenctrl into a number of separate libraries which will provide backward and forward API and ABI compatiblity.
Specifically libxenevtchn, libxengnttab and libxenforeignmemory.
Previous patches have already laid the groundwork for using these by switching the existing compatibility shims to reflect the intefaces to these libraries.
So all which remains is to update configure to detect the libraries and enable their use. Although they are notionally independent we take an all or nothing approach to the three libraries since they were added at the same time.
Quoted 7 lines
The only non-obvious bit is that we now open a proper xenforeignmemory handle for
xen_fmeminstead of reusing thexen_xchandle.Build tested with 4.0 .. 4.6 (inclusive) and the patches targetting 4.7 which adds these libraries.
Signed-off-by Ian Campbell <[email protected]>
Quoted 167 lines
v6: Two minor formatting things.
Rebase onto "xen: fix usage ofxc_domain_createin domain builder", required adjusting the configure script changes.The rebase wasn't entirely trivial (semantically), so dropped Stefano's reviwed by.
v5: Remove ifdef check when undeffing the compat stuff.
s/now way/no way/v4:
xenforeignmemory_openis now a compat wrapper, so no ifdef.Simplify configury by asserting that interface version 470 will always have the libraries (lack of them makes it 460).
Ran checkpatch and fixed everything except:
ERROR: need consistent spacing around '*' (ctx:WxV) +typedef
xc_interface*XenXC;Which I think is a false +ve.
Simpler configure stuff
--- configure | 42 +++++++++++++++++++++++++++++++++++++++++- include/hw/xen/xen_common.h | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 3 deletions(-)configure +41
-1@@ -1923,6 +1923,7 @@ fi if test "$xen" != "no" ; then xen_libs="-lxenstore -lxenctrl -lxenguest" + xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" # First we test whether Xen headers and libraries are available. # If no, we are done and there is no Xen support.@@ -1945,16 +1946,52 @@ EOF # Xen unstable elif cat > $TMPC <<EOF && +/* + * If we have stable libs the we don't want the libxc compat + * layers, regardless of what CFLAGS we may have been given. + */ +#undef XC_WANT_COMPAT_EVTCHN_API +#undef XC_WANT_COMPAT_GNTTAB_API +#undef XC_WANT_COMPAT_MAP_FOREIGN_API #include <xenctrl.h> +#include <xenstore.h> +#include <xenevtchn.h> +#include <xengnttab.h> +#include <xenforeignmemory.h> #include <stdint.h> +#include <xen/hvm/hvm_info_table.h> +#if !defined(HVM_MAX_VCPUS) +# error HVM_MAX_VCPUS not defined +#endif int main(void) { xc_interface *xc = NULL; + xenforeignmemory_handle *xfmem; + xenevtchn_handle *xe; + xengnttab_handle *xg; xen_domain_handle_t handle; + + xs_daemon_open(); + + xc = xc_interface_open(0, 0, 0); + xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); + xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); + xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); + xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); xc_domain_create(xc, 0, handle, 0, NULL, NULL); + + xfmem = xenforeignmemory_open(0, 0); + xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); + + xe = xenevtchn_open(0, 0); + xenevtchn_fd(xe); + + xg = xengnttab_open(0, 0); + xengnttab_map_grant_ref(xg, 0, 0, 0); + return 0; } EOF - compile_prog "" "$xen_libs" + compile_prog "" "$xen_libs $xen_stable_libs" then xen_ctrl_version=470 xen=yes@@ -2138,6 +2175,9 @@ EOF fi if test "$xen" = yes; then + if test $xen_ctrl_version -ge 470 ; then + libs_softmmu="$xen_stable_libs $libs_softmmu" + fi libs_softmmu="$xen_libs $libs_softmmu" fi fiinclude/hw/xen/xen_common.h +33
-2@@ -6,6 +6,15 @@#include <stddef.h> #include <inttypes.h> +/* +* If we have new enough libxenctrl then we do not want/need these compat +* interfaces, despite what the user supplied cflags might say. They +* must be undefined before including xenctrl.h +*/ +#undef XC_WANT_COMPAT_EVTCHN_API +#undef XC_WANT_COMPAT_GNTTAB_API +#undef XC_WANT_COMPAT_MAP_FOREIGN_API +#include <xenctrl.h> #if CONFIG_XEN_CTRL_INTERFACE_VERSION <420 # include <xs.h> @@ -159,8 +168,8 @@ static inline void xs_close(struct xs_handle *xsh) } -/* Xen 4.1 */ -#else +/* Xen 4.1 thru 4.6 */ +#elif CONFIG_XEN_CTRL_INTERFACE_VERSION < 470typedef xc_interface *XenXC ;typedef xc_interface *xenforeignmemory_handle ;@@ -207,6 +216,28 @@ static inline void *xenforeignmemory_map(XenXC *h, uint32_t dom,#define xenforeignmemory_unmap (h, p, s) munmap(p, s * XC_PAGE_SIZE) +/* FIXME There is no way to have the xen fd */ +static inline int xc_fd (xc_interface *xen_xc) +{ +return -1 ; +} +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 470 */ + +typedef xc_interface *XenXC ; + +# define XC_INTERFACE_FMT "%p" +# define XC_HANDLER_INITIAL_VALUE NULL + +#include <xenevtchn.h> +#include <xengnttab.h> +#include <xenforeignmemory.h> + +static inline XenXC xen_xc_interface_open (void *logger,void *dombuild_logger, +unsigned int open_flags) +{ +return xc_interface_open (logger, dombuild_logger, open_flags); +} +/* FIXME There is now way to have the xen fd */ static inline int xc_fd (xc_interface *xen_xc) {Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH QEMU-XEN v6 6/8] xen: Use stable library interfaces when they are available.
In reply to Ian CampbellQuoted 15 lines · Ian Campbell
In Xen 4.7 we are refactoring parts libxenctrl into a number of separate libraries which will provide backward and forward API and ABI compatiblity.
Specifically libxenevtchn, libxengnttab and libxenforeignmemory.
Previous patches have already laid the groundwork for using these by switching the existing compatibility shims to reflect the intefaces to these libraries.
So all which remains is to update configure to detect the libraries and enable their use. Although they are notionally independent we take an all or nothing approach to the three libraries since they were added at the same time.
Quoted 7 lines
The only non-obvious bit is that we now open a proper xenforeignmemory handle for
xen_fmeminstead of reusing thexen_xchandle.Build tested with 4.0 .. 4.6 (inclusive) and the patches targetting 4.7 which adds these libraries.
Signed-off-by Ian Campbell <[email protected]>
Quoted 167 lines
v6: Two minor formatting things.
Rebase onto "xen: fix usage ofxc_domain_createin domain builder", required adjusting the configure script changes.The rebase wasn't entirely trivial (semantically), so dropped Stefano's reviwed by.
v5: Remove ifdef check when undeffing the compat stuff.
s/now way/no way/v4:
xenforeignmemory_openis now a compat wrapper, so no ifdef.Simplify configury by asserting that interface version 470 will always have the libraries (lack of them makes it 460).
Ran checkpatch and fixed everything except:
ERROR: need consistent spacing around '*' (ctx:WxV) +typedef
xc_interface*XenXC;Which I think is a false +ve.
Simpler configure stuff
--- configure | 42 +++++++++++++++++++++++++++++++++++++++++- include/hw/xen/xen_common.h | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 3 deletions(-)configure +41
-1@@ -1923,6 +1923,7 @@ fi if test "$xen" != "no" ; then xen_libs="-lxenstore -lxenctrl -lxenguest" + xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" # First we test whether Xen headers and libraries are available. # If no, we are done and there is no Xen support.@@ -1945,16 +1946,52 @@ EOF # Xen unstable elif cat > $TMPC <<EOF && +/* + * If we have stable libs the we don't want the libxc compat + * layers, regardless of what CFLAGS we may have been given. + */ +#undef XC_WANT_COMPAT_EVTCHN_API +#undef XC_WANT_COMPAT_GNTTAB_API +#undef XC_WANT_COMPAT_MAP_FOREIGN_API #include <xenctrl.h> +#include <xenstore.h> +#include <xenevtchn.h> +#include <xengnttab.h> +#include <xenforeignmemory.h> #include <stdint.h> +#include <xen/hvm/hvm_info_table.h> +#if !defined(HVM_MAX_VCPUS) +# error HVM_MAX_VCPUS not defined +#endif int main(void) { xc_interface *xc = NULL; + xenforeignmemory_handle *xfmem; + xenevtchn_handle *xe; + xengnttab_handle *xg; xen_domain_handle_t handle; + + xs_daemon_open(); + + xc = xc_interface_open(0, 0, 0); + xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); + xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); + xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); + xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); xc_domain_create(xc, 0, handle, 0, NULL, NULL); + + xfmem = xenforeignmemory_open(0, 0); + xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); + + xe = xenevtchn_open(0, 0); + xenevtchn_fd(xe); + + xg = xengnttab_open(0, 0); + xengnttab_map_grant_ref(xg, 0, 0, 0); + return 0; } EOF - compile_prog "" "$xen_libs" + compile_prog "" "$xen_libs $xen_stable_libs" then xen_ctrl_version=470 xen=yes@@ -2138,6 +2175,9 @@ EOF fi if test "$xen" = yes; then + if test $xen_ctrl_version -ge 470 ; then + libs_softmmu="$xen_stable_libs $libs_softmmu" + fi libs_softmmu="$xen_libs $libs_softmmu" fi fiinclude/hw/xen/xen_common.h +33
-2@@ -6,6 +6,15 @@#include <stddef.h> #include <inttypes.h> +/* +* If we have new enough libxenctrl then we do not want/need these compat +* interfaces, despite what the user supplied cflags might say. They +* must be undefined before including xenctrl.h +*/ +#undef XC_WANT_COMPAT_EVTCHN_API +#undef XC_WANT_COMPAT_GNTTAB_API +#undef XC_WANT_COMPAT_MAP_FOREIGN_API +#include <xenctrl.h> #if CONFIG_XEN_CTRL_INTERFACE_VERSION <420 # include <xs.h> @@ -159,8 +168,8 @@ static inline void xs_close(struct xs_handle *xsh) } -/* Xen 4.1 */ -#else +/* Xen 4.1 thru 4.6 */ +#elif CONFIG_XEN_CTRL_INTERFACE_VERSION < 470typedef xc_interface *XenXC ;typedef xc_interface *xenforeignmemory_handle ;@@ -207,6 +216,28 @@ static inline void *xenforeignmemory_map(XenXC *h, uint32_t dom,#define xenforeignmemory_unmap (h, p, s) munmap(p, s * XC_PAGE_SIZE) +/* FIXME There is no way to have the xen fd */ +static inline int xc_fd (xc_interface *xen_xc) +{ +return -1 ; +} +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 470 */ + +typedef xc_interface *XenXC ; + +# define XC_INTERFACE_FMT "%p" +# define XC_HANDLER_INITIAL_VALUE NULL + +#include <xenevtchn.h> +#include <xengnttab.h> +#include <xenforeignmemory.h> + +static inline XenXC xen_xc_interface_open (void *logger,void *dombuild_logger, +unsigned int open_flags) +{ +return xc_interface_open (logger, dombuild_logger, open_flags); +} +/* FIXME There is now way to have the xen fd */ static inline int xc_fd (xc_interface *xen_xc) {Signature · 1 line
2.1.4
PATCH v6 7/8 xen: domainbuild: reopen libxenctrl interface after forking for domain watcher.
In reply to Ian CampbellUsing an existing libxenctrl handle after a fork was never particularly safe (especially if foreign mappings existed at the time of the fork) and the xc fd has been unavailable for many releases.
Reopen the handle after fork and therefore do away with xc_fd().
---
The fact that xc_fd hasn't been useful since at least Xen 4.1 makes me question the utility of this domainbuild in QEMU. Perhaps we should just nuke it?
--- hw/xenpv/xen_domainbuild.c | 9 ++++++--- include/hw/xen/xen_common.h | 17 ----------------- 2 files changed, 6 insertions(+), 20 deletions(-)
hw/xenpv/xen_domainbuild.c +6 -3
@@ -174,12 +174,15 @@ static int xen_domain_watcher(void)for (i =3 ; i < n; i++) {if (i == fd[0 ])continue ; -if (i ==xc_fd (xen_xc)) { -continue ; - }close (i); } +/* +* Reopen xc interface, since the original is unsafe after fork +* and was closed above. +*/ + xen_xc =xc_interface_open (0 ,0 ,0 ); +/* ignore term signals */ signal (SIGINT ,SIG_IGN );signal (SIGTERM ,SIG_IGN );
include/hw/xen/xen_common.h +0 -17
@@ -127,12 +127,6 @@ static inline void *xenforeignmemory_map(XenXC *h, uint32_t dom, }#define xenforeignmemory_unmap (h, p, s) munmap(p, s * XC_PAGE_SIZE) -static inline int xc_fd (int xen_xc) -{ -return xen_xc; -} - -static inline int xc_domain_populate_physmap_exact (XenXC xc_handle,uint32_t domid,unsigned long nr_extents,unsigned int extent_order,unsigned int mem_flags,xen_pfn_t *extent_start)
@@ -216,11 +210,6 @@ static inline void *xenforeignmemory_map(XenXC *h, uint32_t dom,#define xenforeignmemory_unmap (h, p, s) munmap(p, s * XC_PAGE_SIZE) -/* FIXME There is no way to have the xen fd */ -static inline int xc_fd (xc_interface *xen_xc) -{ -return -1 ; -}#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 470 */ typedef xc_interface *XenXC ;
@@ -237,12 +226,6 @@ static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger, {return xc_interface_open (logger, dombuild_logger, open_flags); } - -/* FIXME There is now way to have the xen fd */ -static inline int xc_fd (xc_interface *xen_xc) -{ -return -1 ; -}#endif /* Xen before 4.2 */
Signature · 1 line
2.1.4
PATCH v6 8/8 xen: make it possible to build without the Xen PV domain builder
In reply to Ian CampbellUntil the previous patch this relied on xc_fd(), which was only implemented for Xen 4.0 and earlier.
Given this wasn't working since Xen 4.0 I have marked this as disabled by default.
Removing this support drops the use of a bunch of symbols from libxenctrl, specifically:
- xc_domain_create
- xc_domain_destroy
- xc_domain_getinfo
- xc_domain_max_vcpus
- xc_domain_setmaxmem
- xc_domain_unpause
- xc_evtchn_alloc_unbound
- xc_linux_build
This is another step towards only using Xen libraries which provide a stable inteface.
---
v6: Rebase onto "xen: fix usage of xc_domain_create in domain
builder" (trivial, Reviewed-by retained)
v5: XEN_CREATE entirely wihtin CONFIG_XEN_PV_DOMAIN_BUILD ifdef.
Simplify configure'ry.
v4: Fixed all checkpatch errors.
Disabled by default.
--- configure | 15 +++++++++++++++ hw/xenpv/Makefile.objs | 4 +++- hw/xenpv/xen_machine_pv.c | 15 +++++++++++---- include/hw/xen/xen_common.h | 4 ++++ 4 files changed, 33 insertions(+), 5 deletions(-)
configure +15 -0
@@ -250,6 +250,7 @@ vnc_jpeg="" vnc_png="" xen="" xen_ctrl_version="" +xen_pv_domain_build="no" xen_pci_passthrough="" linux_aio="" cap_ng=""
@@ -925,6 +926,10 @@ for opt do ;; --enable-xen-pci-passthrough) xen_pci_passthrough="yes" ;; + --disable-xen-pv-domain-build) xen_pv_domain_build="no" + ;; + --enable-xen-pv-domain-build) xen_pv_domain_build="yes" + ;; --disable-brlapi) brlapi="no" ;; --enable-brlapi) brlapi="yes"
@@ -2199,6 +2204,12 @@ if test "$xen_pci_passthrough" != "no"; then fi fi +if test "$xen_pv_domain_build" = "yes" && + test "$xen" != "yes"; then + error_exit "User requested Xen PV domain builder support" \ + "which requires Xen support." +fi + ########################################## # libtool probe
@@ -4806,6 +4817,7 @@ fi echo "xen support $xen" if test "$xen" = "yes" ; then echo "xen ctrl version $xen_ctrl_version" + echo "pv dom build $xen_pv_domain_build" fi echo "brlapi support $brlapi" echo "bluez support $bluez"
@@ -5174,6 +5186,9 @@ fi if test "$xen" = "yes" ; then echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak + if test "$xen_pv_domain_build" = "yes" ; then + echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak + fi fi if test "$linux_aio" = "yes" ; then echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
hw/xenpv/Makefile.objs +3 -1
@@ -1,2 +1,4 @@ # Xen PV machine support -obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o +obj-$(CONFIG_XEN) += xen_machine_pv.o +# Xen PV machine builder support +obj-$(CONFIG_XEN_PV_DOMAIN_BUILD) += xen_domainbuild.o
hw/xenpv/xen_machine_pv.c +11 -4
@@ -30,9 +30,6 @@static void xen_init_pv (MachineState *machine) { -const char *kernel_filename = machine->kernel_filename; -const char *kernel_cmdline = machine->kernel_cmdline; -const char *initrd_filename = machine->initrd_filename;DriveInfo *dinfo;int i;
@@ -46,17 +43,27 @@ static void xen_init_pv(MachineState *machine)case XEN_ATTACH :/* nothing to do, xend handles everything */ break ; -case XEN_CREATE : +#ifdef CONFIG_XEN_PV_DOMAIN_BUILD +case XEN_CREATE : { +const char *kernel_filename = machine->kernel_filename; +const char *kernel_cmdline = machine->kernel_cmdline; +const char *initrd_filename = machine->initrd_filename;if (xen_domain_build_pv (kernel_filename, initrd_filename, kernel_cmdline) <0 ) {fprintf (stderr,"xen pv domain creation failed\n" );exit (1 ); }break ; + } +#endif case XEN_EMULATE :fprintf (stderr,"xen emulation not implemented (yet)\n" );exit (1 );break ; +default : +fprintf (stderr,"unhandled xen_mode %d\n" , xen_mode); +exit (1 ); +break ; }xen_be_register ("console" , &xen_console_ops);
include/hw/xen/xen_common.h +4 -0
@@ -528,6 +528,8 @@ static inline int xen_xc_domain_add_to_physmap(XenXC xch, uint32_t domid, }#endif +#ifdef CONFIG_XEN_PV_DOMAIN_BUILD +#if CONFIG_XEN_CTRL_INTERFACE_VERSION <470 static inline int xen_domain_create(XenXC xc, uint32_t ssidref, xen_domain_handle_t handle, uint32_t flags,
@@ -544,4 +546,6 @@ static inline int xen_domain_create(XenXC xc, uint32_t ssidref, }#endif +#endif +#endif /* QEMU_HW_XEN_COMMON_H */
Signature · 1 line
2.1.4
v6 cover Begin to disentangle libxenctrl and provide some stable libraries
In reply to Ian CampbellWe intend to stabilise some parts of the libxenctrl interface by splitting out some functionality into separate stable libraries.
This is the qemu-xen-traditional part of the first phase of that change.
This mail is (or is intended to be) a reply to a "0/<VARIOUS>" super-intro mail covering all of the related patch series and which contains more details.
Ian Campbell (5):
qemu-xen-traditional: Use xentoollog as a separate library
qemu-xen-traditional: Use libxenevtchn
qemu-xen-traditional: Use libxengnttab
qemu-xen-traditional: Add libxencall to rpath-link
qemu-xen-traditional: Add libxenforeignmemory to rpath-link
hw/xen_backend.c | 30 +++++++++++++++--------------- hw/xen_backend.h | 4 ++-- hw/xen_common.h | 2 ++ hw/xen_console.c | 4 ++-- hw/xen_disk.c | 24 ++++++++++++------------ i386-dm/helper2.c | 19 ++++++++++--------- xen-hooks.mak | 9 +++++++++ 7 files changed, 52 insertions(+), 40 deletions(-)
Signature · 1 line
2.1.4
PATCH v6 1/5 qemu-xen-traditional: Use xentoollog as a separate library
This has been split out of libxenctrl, so the build needs to be able to find the header and the library. QEMU does not use xtl_* itself so -rpath-link is sufficient to allow linking to libxenctrl.so (which links against libxentoollog).
---
v3: Library moved to tools/libs/
--- xen-hooks.mak | 2 ++ 1 file changed, 2 insertions(+)
xen-hooks.mak +2 -0
@@ -1,3 +1,4 @@ +CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/toollog/include CPPFLAGS+= -I$(XEN_ROOT)/tools/libxc/include CPPFLAGS+= -I$(XEN_ROOT)/tools/xenstore/include CPPFLAGS+= -I$(XEN_ROOT)/tools/include
@@ -19,6 +20,7 @@ CFLAGS += $(CMDLINE_CFLAGS) LIBS += -L$(XEN_ROOT)/tools/libxc -lxenctrl -lxenguest LIBS += -L$(XEN_ROOT)/tools/xenstore -lxenstore +LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog LDFLAGS := $(CFLAGS) $(LDFLAGS)
Signature · 1 line
2.1.4
PATCH v6 2/5 qemu-xen-traditional: Use libxenevtchn
In reply to Ian Campbell/dev/xen/evtchn related wrappers have been moved out of libxenctrl into their own library.
Note that i386-dm/helper2.c's xc_interface * was always really an xc_evtchn *, it's just they used to be typedefs to the same thing...
---
v3: Library moved to tools/libs/
--- hw/xen_backend.c | 26 +++++++++++++------------- hw/xen_backend.h | 2 +- hw/xen_common.h | 1 + i386-dm/helper2.c | 19 ++++++++++--------- xen-hooks.mak | 2 ++ 5 files changed, 27 insertions(+), 23 deletions(-)
hw/xen_backend.c +13 -13
@@ -208,19 +208,19 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev, xendev->debug = debug; xendev->local_port =-1 ; - xendev->evtchndev =xc_evtchn_open (NULL ,0 ); + xendev->evtchndev =xenevtchn_open (NULL ,0 );if (xendev->evtchndev ==NULL ) {xen_be_printf (NULL ,0 ,"can't open evtchn device\n" );qemu_free (xendev);return NULL ; } -fcntl (xc_evtchn_fd (xendev->evtchndev),F_SETFD ,FD_CLOEXEC ); +fcntl (xenevtchn_fd (xendev->evtchndev),F_SETFD ,FD_CLOEXEC );if (ops->flags &DEVOPS_FLAG_NEED_GNTDEV ) { xendev->gnttabdev =xc_gnttab_open (NULL ,0 );if (xendev->gnttabdev ==NULL ) {xen_be_printf (NULL ,0 ,"can't open gnttab device\n" ); -xc_evtchn_close (xendev->evtchndev); +xenevtchn_close (xendev->evtchndev);qemu_free (xendev);return NULL ; }
@@ -268,7 +268,7 @@ static struct XenDevice *xen_be_del_xendev(int dom, int dev) }if (xendev->evtchndev !=NULL ) -xc_evtchn_close (xendev->evtchndev); +xenevtchn_close (xendev->evtchndev);if (xendev->gnttabdev !=NULL )xc_gnttab_close (xendev->gnttabdev);
@@ -630,13 +630,13 @@ static void xen_be_evtchn_event(void *opaque)struct XenDevice *xendev = opaque;evtchn_port_t port; - port =xc_evtchn_pending (xendev->evtchndev); + port =xenevtchn_pending (xendev->evtchndev);if (port != xendev->local_port) { -xen_be_printf (xendev,0 ,"xc_evtchn_pending returned %d (expected %d)\n" , +xen_be_printf (xendev,0 ,"xenevtchn_pending returned %d (expected %d)\n" , port, xendev->local_port);return ; } -xc_evtchn_unmask (xendev->evtchndev, port); +xenevtchn_unmask (xendev->evtchndev, port);if (xendev->ops->event) xendev->ops->event (xendev);
@@ -683,14 +683,14 @@ int xen_be_bind_evtchn(struct XenDevice *xendev) {if (xendev->local_port !=-1 )return 0 ; - xendev->local_port =xc_evtchn_bind_interdomain + xendev->local_port =xenevtchn_bind_interdomain (xendev->evtchndev, xendev->dom, xendev->remote_port);if (xendev->local_port ==-1 ) { -xen_be_printf (xendev,0 ,"xc_evtchn_bind_interdomain failed\n" ); +xen_be_printf (xendev,0 ,"xenevtchn_bind_interdomain failed\n" );return -1 ; }xen_be_printf (xendev,2 ,"bind evtchn port %d\n" , xendev->local_port); -qemu_set_fd_handler (xc_evtchn_fd (xendev->evtchndev), +qemu_set_fd_handler (xenevtchn_fd (xendev->evtchndev), xen_be_evtchn_event,NULL , xendev);return 0 ; }
@@ -699,15 +699,15 @@ void xen_be_unbind_evtchn(struct XenDevice *xendev) {if (xendev->local_port ==-1 )return ; -qemu_set_fd_handler (xc_evtchn_fd (xendev->evtchndev),NULL ,NULL ,NULL ); -xc_evtchn_unbind (xendev->evtchndev, xendev->local_port); +qemu_set_fd_handler (xenevtchn_fd (xendev->evtchndev),NULL ,NULL ,NULL ); +xenevtchn_unbind (xendev->evtchndev, xendev->local_port);xen_be_printf (xendev,2 ,"unbind evtchn port %d\n" , xendev->local_port); xendev->local_port =-1 ; }int xen_be_send_notify (struct XenDevice *xendev) { -return xc_evtchn_notify (xendev->evtchndev, xendev->local_port); +return xenevtchn_notify (xendev->evtchndev, xendev->local_port); }/*
hw/xen_backend.h +1 -1
@@ -44,7 +44,7 @@ struct XenDevice {int remote_port;int local_port; -xc_evtchn *evtchndev; +xenevtchn_handle *evtchndev;xc_gnttab *gnttabdev;struct XenDevOps *ops;
hw/xen_common.h +1 -0
@@ -4,6 +4,7 @@#include <stddef.h> #include <inttypes.h> +#include <xenevtchn.h> #include <xenctrl.h> #include <xenstore.h> #include <xen/io/xenbus.h>
i386-dm/helper2.c +10 -9
@@ -48,6 +48,7 @@#include <limits.h> #include <fcntl.h> +#include <xenevtchn.h> #include <xenctrl.h> #include <xen/hvm/ioreq.h> #include <xen/hvm/hvm_info_table.h>
@@ -104,7 +105,7 @@ buffered_iopage_t *buffered_io_page = NULL;QEMUTimer *buffered_io_timer;/* the evtchn fd for polling */ -xc_interface *xce_handle =NULL ; +xenevtchn_handle *xce_handle =NULL ;/* which vcpu we are serving */ int send_vcpu =0 ;
@@ -141,7 +142,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model) cpu_single_env = env; - xce_handle =xc_evtchn_open (NULL ,0 ); + xce_handle =xenevtchn_open (NULL ,0 );if (xce_handle ==NULL ) {perror ("open" );return NULL ;
@@ -149,7 +150,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model)/* FIXME: how about if we overflow the page here? */ for (i =0 ; i < vcpus; i++) { - rc =xc_evtchn_bind_interdomain ( + rc =xenevtchn_bind_interdomain ( xce_handle, domid, shared_page->vcpu_ioreq[i].vp_eport);if (rc ==-1 ) {fprintf (logfile,"bind interdomain ioctl error %d\n" , errno);
@@ -164,7 +165,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model) errno);return NULL ; } - rc =xc_evtchn_bind_interdomain (xce_handle, domid, (uint32_t )bufioreq_evtchn); + rc =xenevtchn_bind_interdomain (xce_handle, domid, (uint32_t )bufioreq_evtchn);if (rc ==-1 ) {fprintf (logfile,"bind interdomain ioctl error %d\n" , errno);return NULL ;
@@ -278,7 +279,7 @@ static ioreq_t *cpu_get_ioreq(void)int i;evtchn_port_t port; - port =xc_evtchn_pending (xce_handle); + port =xenevtchn_pending (xce_handle);if (port == bufioreq_local_port) {qemu_mod_timer (buffered_io_timer,BUFFER_IO_MAX_DELAY +qemu_get_clock (rt_clock));
@@ -296,7 +297,7 @@ static ioreq_t *cpu_get_ioreq(void) }// unmask the wanted port again -xc_evtchn_unmask (xce_handle, port); +xenevtchn_unmask (xce_handle, port);//get the io packet from shared memory send_vcpu = i;
@@ -539,7 +540,7 @@ static void handle_buffered_io(void *opaque) BUFFER_IO_MAX_DELAY + qemu_get_clock(rt_clock)); }else {qemu_del_timer (buffered_io_timer); -xc_evtchn_unmask (xce_handle, bufioreq_local_port); +xenevtchn_unmask (xce_handle, bufioreq_local_port); } }
@@ -583,7 +584,7 @@ static void cpu_handle_ioreq(void *opaque) } req->state =STATE_IORESP_READY ; -xc_evtchn_notify (xce_handle, ioreq_local_port[send_vcpu]); +xenevtchn_notify (xce_handle, ioreq_local_port[send_vcpu]); } }
@@ -592,7 +593,7 @@ int xen_pause_requested;int main_loop (void ) {CPUState *env = cpu_single_env; -int evtchn_fd = xce_handle ==NULL ?-1 :xc_evtchn_fd (xce_handle); +int evtchn_fd = xce_handle ==NULL ?-1 :xenevtchn_fd (xce_handle);char *qemu_file;fd_set fds;
xen-hooks.mak +2 -0
@@ -1,4 +1,5 @@ CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/toollog/include +CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/evtchn/include CPPFLAGS+= -I$(XEN_ROOT)/tools/libxc/include CPPFLAGS+= -I$(XEN_ROOT)/tools/xenstore/include CPPFLAGS+= -I$(XEN_ROOT)/tools/include
@@ -18,6 +19,7 @@ endif CFLAGS += $(CMDLINE_CFLAGS) +LIBS += -L$(XEN_ROOT)/tools/libs/evtchn -lxenevtchn LIBS += -L$(XEN_ROOT)/tools/libxc -lxenctrl -lxenguest LIBS += -L$(XEN_ROOT)/tools/xenstore -lxenstore LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog
Signature · 1 line
2.1.4
PATCH v6 3/5 qemu-xen-traditional: Use libxengnttab
In reply to Ian Campbell/dev/xen/gntdev related wrappers have been moved out of libxenctrl into their own library.
---
v3: Library moved to tools/libs/
--- hw/xen_backend.c | 4 ++-- hw/xen_backend.h | 2 +- hw/xen_common.h | 1 + hw/xen_console.c | 4 ++-- hw/xen_disk.c | 24 ++++++++++++------------ xen-hooks.mak | 2 ++ 6 files changed, 20 insertions(+), 17 deletions(-)
hw/xen_backend.c +2 -2
@@ -217,7 +217,7 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,fcntl (xenevtchn_fd (xendev->evtchndev),F_SETFD ,FD_CLOEXEC );if (ops->flags &DEVOPS_FLAG_NEED_GNTDEV ) { - xendev->gnttabdev =xc_gnttab_open (NULL ,0 ); + xendev->gnttabdev =xengnttab_open (NULL ,0 );if (xendev->gnttabdev ==NULL ) {xen_be_printf (NULL ,0 ,"can't open gnttab device\n" );xenevtchn_close (xendev->evtchndev);
@@ -270,7 +270,7 @@ static struct XenDevice *xen_be_del_xendev(int dom, int dev)if (xendev->evtchndev !=NULL )xenevtchn_close (xendev->evtchndev);if (xendev->gnttabdev !=NULL ) -xc_gnttab_close (xendev->gnttabdev); +xengnttab_close (xendev->gnttabdev);TAILQ_REMOVE (&xendevs, xendev, next);qemu_free (xendev);
hw/xen_backend.h +1 -1
@@ -45,7 +45,7 @@ struct XenDevice {int local_port;xenevtchn_handle *evtchndev; -xc_gnttab *gnttabdev; +xengnttab_handle *gnttabdev;struct XenDevOps *ops;TAILQ_ENTRY (XenDevice) next;
hw/xen_common.h +1 -0
@@ -5,6 +5,7 @@#include <inttypes.h> #include <xenevtchn.h> +#include <xengnttab.h> #include <xenctrl.h> #include <xenstore.h> #include <xen/io/xenbus.h>
hw/xen_console.c +2 -2
@@ -230,7 +230,7 @@ static int con_initialise(struct XenDevice *xendev)PROT_READ |PROT_WRITE , con->ring_ref); else - con->sring = xc_gnttab_map_grant_ref(xendev->gnttabdev, con->xendev.dom, + con->sring = xengnttab_map_grant_ref(xendev->gnttabdev, con->xendev.dom, con->ring_ref,PROT_READ |PROT_WRITE );if (!con->sring)
@@ -263,7 +263,7 @@ static void con_disconnect(struct XenDevice *xendev)if (!xendev->gnttabdev)munmap (con->sring,XC_PAGE_SIZE );else -xc_gnttab_munmap (xendev->gnttabdev, con->sring,1 ); +xengnttab_munmap (xendev->gnttabdev, con->sring,1 ); con->sring =NULL ; } }
hw/xen_disk.c +12 -12
@@ -266,7 +266,7 @@ err:static void ioreq_unmap (struct ioreq *ioreq) { -xc_gnttab *gnt = ioreq->blkdev->xendev.gnttabdev; +xengnttab_handle *gnt = ioreq->blkdev->xendev.gnttabdev;int i;if (ioreq->v.niov ==0 )
@@ -274,8 +274,8 @@ static void ioreq_unmap(struct ioreq *ioreq)if (batch_maps) {if (!ioreq->pages)return ; -if (xc_gnttab_munmap (gnt, ioreq->pages, ioreq->v.niov) !=0 ) -xen_be_printf (&ioreq->blkdev->xendev,0 ,"xc_gnttab_munmap failed: %s\n" , +if (xengnttab_munmap (gnt, ioreq->pages, ioreq->v.niov) !=0 ) +xen_be_printf (&ioreq->blkdev->xendev,0 ,"xengnttab_munmap failed: %s\n" ,strerror (errno)); ioreq->blkdev->cnt_map -= ioreq->v.niov; ioreq->pages =NULL ;
@@ -283,8 +283,8 @@ static void ioreq_unmap(struct ioreq *ioreq)for (i =0 ; i < ioreq->v.niov; i++) {if (!ioreq->page[i])continue ; -if (xc_gnttab_munmap (gnt, ioreq->page[i],1 ) !=0 ) -xen_be_printf (&ioreq->blkdev->xendev,0 ,"xc_gnttab_munmap failed: %s\n" , +if (xengnttab_munmap (gnt, ioreq->page[i],1 ) !=0 ) +xen_be_printf (&ioreq->blkdev->xendev,0 ,"xengnttab_munmap failed: %s\n" ,strerror (errno)); ioreq->blkdev->cnt_map--; ioreq->page[i] =NULL ;
@@ -294,13 +294,13 @@ static void ioreq_unmap(struct ioreq *ioreq)static int ioreq_map (struct ioreq *ioreq) { -xc_gnttab *gnt = ioreq->blkdev->xendev.gnttabdev; +xengnttab_handle *gnt = ioreq->blkdev->xendev.gnttabdev;int i;if (ioreq->v.niov ==0 )return 0 ;if (batch_maps) { - ioreq->pages =xc_gnttab_map_grant_refs + ioreq->pages =xengnttab_map_grant_refs (gnt, ioreq->v.niov, ioreq->domids, ioreq->refs, ioreq->prot);if (ioreq->pages ==NULL ) { xen_be_printf(&ioreq->blkdev->xendev, 0,
@@ -314,7 +314,7 @@ static int ioreq_map(struct ioreq *ioreq) ioreq->blkdev->cnt_map += ioreq->v.niov; }else {for (i =0 ; i < ioreq->v.niov; i++) { - ioreq->page[i] =xc_gnttab_map_grant_ref + ioreq->page[i] =xengnttab_map_grant_ref (gnt, ioreq->domids[i], ioreq->refs[i], ioreq->prot);if (ioreq->page[i] ==NULL ) { xen_be_printf(&ioreq->blkdev->xendev, 0,
@@ -611,9 +611,9 @@ static void blk_alloc(struct XenDevice *xendev) blkdev->bh =qemu_bh_new (blk_bh, blkdev);if (xen_mode !=XEN_EMULATE ) batch_maps =1 ; -if (xc_gnttab_set_max_grants (xendev->gnttabdev, +if (xengnttab_set_max_grants (xendev->gnttabdev,MAX_GRANTS (max_requests,BLKIF_MAX_SEGMENTS_PER_REQUEST )) <0 ) { -xen_be_printf (xendev,0 ,"xc_gnttab_set_max_grants failed: %s\n" , +xen_be_printf (xendev,0 ,"xengnttab_set_max_grants failed: %s\n" ,strerror (errno)); } }
@@ -734,7 +734,7 @@ static int blk_connect(struct XenDevice *xendev) blkdev->protocol =BLKIF_PROTOCOL_X86_64 ; } - blkdev->sring =xc_gnttab_map_grant_ref (blkdev->xendev.gnttabdev, + blkdev->sring =xengnttab_map_grant_ref (blkdev->xendev.gnttabdev, blkdev->xendev.dom, blkdev->ring_ref,PROT_READ |PROT_WRITE );
@@ -787,7 +787,7 @@ static void blk_disconnect(struct XenDevice *xendev)xen_be_unbind_evtchn (&blkdev->xendev);if (blkdev->sring) { -xc_gnttab_munmap (blkdev->xendev.gnttabdev, blkdev->sring,1 ); +xengnttab_munmap (blkdev->xendev.gnttabdev, blkdev->sring,1 ); blkdev->cnt_map--; blkdev->sring =NULL ; }
xen-hooks.mak +2 -0
@@ -1,5 +1,6 @@ CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/toollog/include CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/evtchn/include +CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/gnttab/include CPPFLAGS+= -I$(XEN_ROOT)/tools/libxc/include CPPFLAGS+= -I$(XEN_ROOT)/tools/xenstore/include CPPFLAGS+= -I$(XEN_ROOT)/tools/include
@@ -20,6 +21,7 @@ endif CFLAGS += $(CMDLINE_CFLAGS) LIBS += -L$(XEN_ROOT)/tools/libs/evtchn -lxenevtchn +LIBS += -L$(XEN_ROOT)/tools/libs/gnttab -lxengnttab LIBS += -L$(XEN_ROOT)/tools/libxc -lxenctrl -lxenguest LIBS += -L$(XEN_ROOT)/tools/xenstore -lxenstore LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog
Signature · 1 line
2.1.4
PATCH v6 4/5 qemu-xen-traditional: Add libxencall to rpath-link
In reply to Ian Campbelllibxenctrl links against this library
---
v3: Library moved to tools/libs
--- xen-hooks.mak | 1 + 1 file changed, 1 insertion(+)
xen-hooks.mak +1 -0
@@ -25,6 +25,7 @@ LIBS += -L$(XEN_ROOT)/tools/libs/gnttab -lxengnttab LIBS += -L$(XEN_ROOT)/tools/libxc -lxenctrl -lxenguest LIBS += -L$(XEN_ROOT)/tools/xenstore -lxenstore LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog +LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/call LDFLAGS := $(CFLAGS) $(LDFLAGS)
Signature · 1 line
2.1.4
PATCH v6 5/5 qemu-xen-traditional: Add libxenforeignmemory to rpath-link
In reply to Ian Campbelllibxenctrl links against this library.
Also, request the compat xc_map_foreign API from libxc.
---
v3: Library moved to tools/libs/
--- xen-hooks.mak | 2 ++ 1 file changed, 2 insertions(+)
xen-hooks.mak +2 -0
@@ -1,6 +1,7 @@ CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/toollog/include CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/evtchn/include CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/gnttab/include +CPPFLAGS+= -DXC_WANT_COMPAT_MAP_FOREIGN_API CPPFLAGS+= -I$(XEN_ROOT)/tools/libxc/include CPPFLAGS+= -I$(XEN_ROOT)/tools/xenstore/include CPPFLAGS+= -I$(XEN_ROOT)/tools/include
@@ -26,6 +27,7 @@ LIBS += -L$(XEN_ROOT)/tools/libxc -lxenctrl -lxenguest LIBS += -L$(XEN_ROOT)/tools/xenstore -lxenstore LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/call +LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/foreignmemory LDFLAGS := $(CFLAGS) $(LDFLAGS)
Signature · 1 line
2.1.4
v6 cover Begin to disentangle libxenctrl and provide some stable libraries
In reply to Ian CampbellWe intend to stabilise some parts of the libxenctrl interface by splitting out some functionality into separate stable libraries.
This is the mini-os part of the first phase of that change.
This mail is (or is intended to be) a reply to a "0/<VARIOUS>" super-intro mail covering all of the related patch series and which contains more details.
Ian Campbell (5):
mini-os: Include libxentoollog with libxc
mini-os: Include libxenevtchn with libxc
mini-os: Include libxengnttab with libxc
mini-os: Include libxencall with libxc
mini-os: Include libxenforeignmemory with libxc
Makefile | 5 +++++ 1 file changed, 5 insertions(+)
Signature · 1 line
2.1.4
PATCH v6 1/5 mini-os: Include libxentoollog with libxc
libxentoollog has just been split out from libxc. From mini-os's point of view we don't care about the distinction, so keep things simple by just including libxentoollog if libxc is enabled.
---
v2: Adjust for libs/$lib layout.
--- Makefile | 1 + 1 file changed, 1 insertion(+)
Makefile +1 -0
@@ -165,6 +165,7 @@ OBJS := $(filter-out $(OBJ_DIR)/lwip%.o $(LWO), $(OBJS)) ifeq ($(libc),y) ifeq ($(CONFIG_XC),y) +APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/toollog -whole-archive -lxentoollog -no-whole-archive APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(MINIOS_TARGET_ARCH) -whole-archive -lxenguest -lxenctrl -no-whole-archive endif APP_LDLIBS += -lpci
Signature · 1 line
2.1.4
PATCH v6 2/5 mini-os: Include libxenevtchn with libxc
In reply to Ian Campbelllibxenevtchn has just been split out from libxc. From mini-os's point of view we don't care about the distinction, so keep things simple by just including libxenevtchn if libxc is enabled.
---
v2: Adjust for libs/$lib layout.
--- Makefile | 1 + 1 file changed, 1 insertion(+)
Makefile +1 -0
@@ -166,6 +166,7 @@ OBJS := $(filter-out $(OBJ_DIR)/lwip%.o $(LWO), $(OBJS)) ifeq ($(libc),y) ifeq ($(CONFIG_XC),y) APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/toollog -whole-archive -lxentoollog -no-whole-archive +APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/evtchn -whole-archive -lxenevtchn -no-whole-archive APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(MINIOS_TARGET_ARCH) -whole-archive -lxenguest -lxenctrl -no-whole-archive endif APP_LDLIBS += -lpci
Signature · 1 line
2.1.4
PATCH v6 3/5 mini-os: Include libxengnttab with libxc
In reply to Ian Campbelllibxengnttab has just been split out from libxc. From mini-os's point of view we don't care about the distinction, so keep things simple by just including libxengnttab if libxc is enabled.
---
v2: Adjust for libs/$lib layout.
--- Makefile | 1 + 1 file changed, 1 insertion(+)
Makefile +1 -0
@@ -167,6 +167,7 @@ ifeq ($(libc),y) ifeq ($(CONFIG_XC),y) APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/toollog -whole-archive -lxentoollog -no-whole-archive APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/evtchn -whole-archive -lxenevtchn -no-whole-archive +APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/gnttab -whole-archive -lxengnttab -no-whole-archive APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(MINIOS_TARGET_ARCH) -whole-archive -lxenguest -lxenctrl -no-whole-archive endif APP_LDLIBS += -lpci
Signature · 1 line
2.1.4
PATCH v6 4/5 mini-os: Include libxencall with libxc
In reply to Ian Campbelllibxencall has just been split out from libxc. From mini-os's point of view we don't care about the distinction, so keep things simple by just including libxencall if libxc is enabled.
---
v2: Adjust for libs/$lib layout.
--- Makefile | 1 + 1 file changed, 1 insertion(+)
Makefile +1 -0
@@ -168,6 +168,7 @@ ifeq ($(CONFIG_XC),y) APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/toollog -whole-archive -lxentoollog -no-whole-archive APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/evtchn -whole-archive -lxenevtchn -no-whole-archive APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/gnttab -whole-archive -lxengnttab -no-whole-archive +APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/call -whole-archive -lxencall -no-whole-archive APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(MINIOS_TARGET_ARCH) -whole-archive -lxenguest -lxenctrl -no-whole-archive endif APP_LDLIBS += -lpci
Signature · 1 line
2.1.4
PATCH v6 5/5 mini-os: Include libxenforeignmemory with libxc
In reply to Ian Campbelllibxenforeignmemory has just been split out from libxc. From mini-os's point of view we don't care about the distinction, so keep things simple by just including libxenforeignmemory if libxc is enabled.
---
v2: Adjust for libs/$lib layout.
--- Makefile | 1 + 1 file changed, 1 insertion(+)
Makefile +1 -0
@@ -169,6 +169,7 @@ APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/toollog -whole-ar APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/evtchn -whole-archive -lxenevtchn -no-whole-archive APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/gnttab -whole-archive -lxengnttab -no-whole-archive APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/call -whole-archive -lxencall -no-whole-archive +APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/foreignmemory -whole-archive -lxenforeignmemory -no-whole-archive APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(MINIOS_TARGET_ARCH) -whole-archive -lxenguest -lxenctrl -no-whole-archive endif APP_LDLIBS += -lpci
Signature · 1 line
2.1.4
Quoted 9 lines · Ian Campbell
Last time proposed that these precursors (and the corresponding qemu-xen- traditional + mini-os patches) should go in now:
tools/Rules.mk: Properly handle libraries with recursive dependencies.
tools: Refactor "xentoollog" into its own libraryBut I subsequently found a couple of build issues, which are addressed by two new patches at the head of the xen series.
Which have now been acked, thanks.
I have therefore applied:
To xen.git:
mce-test: do not include libxenguest internal headers tools/ocaml: simplify compile/link of test apps tools/Rules.mk: Properly handle libraries with recursive dependencies.
tools: Refactor "xentoollog" into its own library
To qemu-xen-traditional.git:
qemu-xen-traditional: Use xentoollog as a separate library
To mini-os.git:
mini-os: Include libxentoollog with libxc
and I have folded in updates to QEMU_TRADITIONAL_REVISION and MINIOS_UPSTREAM_REVISION into the xen.git commit "tools: Refactor "xentoollog" into its own library".
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 9 lines · Ian Campbell
Last time proposed that these precursors (and the corresponding qemu-xen- traditional + mini-os patches) should go in now:
tools/Rules.mk: Properly handle libraries with recursive dependencies.
tools: Refactor "xentoollog" into its own libraryBut I subsequently found a couple of build issues, which are addressed by two new patches at the head of the xen series.
Which have now been acked, thanks.
I have therefore applied:
To xen.git:
mce-test: do not include libxenguest internal headers tools/ocaml: simplify compile/link of test apps tools/Rules.mk: Properly handle libraries with recursive dependencies.
tools: Refactor "xentoollog" into its own library
To qemu-xen-traditional.git:
qemu-xen-traditional: Use xentoollog as a separate library
To mini-os.git:
mini-os: Include libxentoollog with libxc
and I have folded in updates to QEMU_TRADITIONAL_REVISION and MINIOS_UPSTREAM_REVISION into the xen.git commit "tools: Refactor "xentoollog" into its own library".
Ian.