From 8c4c3807119f27957e6c7f87d505d66d0ea4c3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 18 Nov 2023 18:27:28 +0100 Subject: [PATCH] Support changed libxenctrl API in Xen 4.18.0 The xc_domain_getinfo() is gone, it's replaced with xc_domain_getinfo_single. While the new API is a bit nicer, xenctrl.h does not provide any #define to know which one is available. Check library version in the makefile for that. --- vchan/Makefile.linux | 4 ++++ vchan/io.c | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/vchan/Makefile.linux b/vchan/Makefile.linux index 281f2b5..587cb34 100644 --- a/vchan/Makefile.linux +++ b/vchan/Makefile.linux @@ -27,6 +27,10 @@ CFLAGS += -g -Wall -Wextra -Werror -fPIC -O2 -D_GNU_SOURCE -MD -MP -MF $@.dep all: libvchan-xen.so vchan-xen.pc -include *.dep +# xenctrl.h does not provide any #define to distinguish API versions +XENCTRL_VERSION := $(shell pkg-config --modversion xencontrol) +CFLAGS += $(shell if printf '%s\n' '4.18.0' '$(XENCTRL_VERSION)' | \ + sort -CV; then echo -DHAVE_XC_DOMAIN_GETINFO_SINGLE; fi) SO_VER = 1 libvchan-xen.so.$(SO_VER): init.o io.o diff --git a/vchan/io.c b/vchan/io.c index 3d0ed35..0c23223 100644 --- a/vchan/io.c +++ b/vchan/io.c @@ -33,14 +33,24 @@ /* check if domain is still alive */ int libvchan__check_domain_alive(xc_interface *xc_handle, int dom) { struct evtchn_status evst; +#ifdef HAVE_XC_DOMAIN_GETINFO_SINGLE + xc_domaininfo_t dominfo; +#else xc_dominfo_t dominfo; +#endif int ret; /* first try using domctl, more reliable but available in a privileged * domain only */ +#ifdef HAVE_XC_DOMAIN_GETINFO_SINGLE + ret = xc_domain_getinfo_single(xc_handle, dom, &dominfo); + if (ret == 0) + return !(dominfo.flags & XEN_DOMINF_dying); +#else ret = xc_domain_getinfo(xc_handle, dom, 1, &dominfo); if (ret == 1) return dominfo.domid == (uint32_t)dom && !dominfo.dying; +#endif else if (ret == -1 && errno == ESRCH) return 0; /* otherwise fallback to xc_evtchn_status method */