From patchwork Fri Feb 12 17:31:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 8294191 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 35B6C9F1E0 for ; Fri, 12 Feb 2016 17:34:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE5362042A for ; Fri, 12 Feb 2016 17:34:08 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74644203ED for ; Fri, 12 Feb 2016 17:34:07 +0000 (UTC) Received: from localhost ([::1]:34749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUHba-0001a2-RK for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 Feb 2016 12:34:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUHZR-0006OG-5U for qemu-devel@nongnu.org; Fri, 12 Feb 2016 12:31:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUHZN-0006Gg-ON for qemu-devel@nongnu.org; Fri, 12 Feb 2016 12:31:53 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:40216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUHZN-0006Fr-Fx for qemu-devel@nongnu.org; Fri, 12 Feb 2016 12:31:49 -0500 X-IronPort-AV: E=Sophos;i="5.22,436,1449532800"; d="scan'208";a="337881391" From: Stefano Stabellini To: Date: Fri, 12 Feb 2016 17:31:01 +0000 Message-ID: <1455298265-16795-1-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.63 Cc: Ian Campbell , xen-devel@lists.xensource.com, qemu-devel@nongnu.org, Stefano Stabellini Subject: [Qemu-devel] [PULL 1/5] xen: drop support for Xen 4.1 and older. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ian Campbell Xen 4.2 become unsupported upstream in 09/2015 (see http://wiki.xen.org/wiki/Xen_Release_Features). However as far as the interfaces provided by the toolstack libraries go 4.2 and 4.3 are indistinguishable. Therefore drop support for Xen 4.1 and earlier which removes a whole pile of compatibility code which makes future work (to use stable library interfaces provided by upstream) more difficult. In particular all supported versions now use a pointer as a libxc handle (4.1 and earlier used an integer, resulting in various shim layers). Also Xen 4.2 was the first version of Xen to formally support upstream QEMU (as a preview) so that makes sense as a cut-off now. This change drops all the configure-y and resulting ifdefs in a mostly mechanical way. A follow up will refactor wrappers which are now unused. Signed-off-by: Ian Campbell Reviewed-by: Stefano Stabellini Signed-off-by: Stefano Stabellini --- configure | 101 +----------------------------- hw/i386/xen/xen_apic.c | 4 -- include/hw/xen/xen.h | 4 -- include/hw/xen/xen_common.h | 146 ++----------------------------------------- xen-hvm.c | 19 ------ 5 files changed, 7 insertions(+), 267 deletions(-) diff --git a/configure b/configure index d4411a1..16c7956 100755 --- a/configure +++ b/configure @@ -2111,100 +2111,10 @@ EOF xen_ctrl_version=420 xen=yes - elif - cat > $TMPC < -#include -#include -#include -#if !defined(HVM_MAX_VCPUS) -# error HVM_MAX_VCPUS not defined -#endif -int main(void) { - xs_daemon_open(); - xc_interface_open(0, 0, 0); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - xc_gnttab_open(NULL, 0); - xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); - return 0; -} -EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=410 - xen=yes - - # Xen 4.0.0 - elif - cat > $TMPC < -#include -#include -#include -#if !defined(HVM_MAX_VCPUS) -# error HVM_MAX_VCPUS not defined -#endif -int main(void) { - struct xen_add_to_physmap xatp = { - .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0, - }; - xs_daemon_open(); - xc_interface_open(); - xc_gnttab_open(); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - xc_memory_op(0, XENMEM_add_to_physmap, &xatp); - return 0; -} -EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=400 - xen=yes - - # Xen 3.4.0 - elif - cat > $TMPC < -#include -int main(void) { - struct xen_add_to_physmap xatp = { - .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0, - }; - xs_daemon_open(); - xc_interface_open(); - xc_gnttab_open(); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - xc_memory_op(0, XENMEM_add_to_physmap, &xatp); - return 0; -} -EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=340 - xen=yes - - # Xen 3.3.0 - elif - cat > $TMPC < -#include -int main(void) { - xs_daemon_open(); - xc_interface_open(); - xc_gnttab_open(); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - return 0; -} -EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=330 - xen=yes - - # Xen version unsupported else if test "$xen" = "yes" ; then - feature_not_found "xen (unsupported version)" "Install supported xen (e.g. 4.0, 3.4, 3.3)" + feature_not_found "xen (unsupported version)" \ + "Install a supported xen (xen 4.2 or newer)" fi xen=no fi @@ -2218,15 +2128,10 @@ EOF fi if test "$xen_pci_passthrough" != "no"; then - if test "$xen" = "yes" && test "$linux" = "yes" && - test "$xen_ctrl_version" -ge 340; then + if test "$xen" = "yes" && test "$linux" = "yes"; then xen_pci_passthrough=yes else if test "$xen_pci_passthrough" = "yes"; then - if test "$xen_ctrl_version" -lt 340; then - error_exit "User requested feature Xen PCI Passthrough" \ - "This feature does not work with Xen 3.3" - fi error_exit "User requested feature Xen PCI Passthrough" \ " but this feature requires /sys from Linux" fi diff --git a/hw/i386/xen/xen_apic.c b/hw/i386/xen/xen_apic.c index 5128146..2b8d709 100644 --- a/hw/i386/xen/xen_apic.c +++ b/hw/i386/xen/xen_apic.c @@ -44,11 +44,7 @@ static void xen_apic_realize(DeviceState *dev, Error **errp) s->vapic_control = 0; memory_region_init_io(&s->io_memory, OBJECT(s), &xen_apic_io_ops, s, "xen-apic-msi", APIC_SPACE_SIZE); - -#if defined(CONFIG_XEN_CTRL_INTERFACE_VERSION) \ - && CONFIG_XEN_CTRL_INTERFACE_VERSION >= 420 msi_supported = true; -#endif } static void xen_apic_set_base(APICCommonState *s, uint64_t val) diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index c577354..df33481 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -48,8 +48,4 @@ void xen_modified_memory(ram_addr_t start, ram_addr_t length); void xen_register_framebuffer(struct MemoryRegion *mr); -#if defined(CONFIG_XEN) && CONFIG_XEN_CTRL_INTERFACE_VERSION < 400 -# define HVM_MAX_VCPUS 32 -#endif - #endif /* QEMU_HW_XEN_H */ diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index 0d83891..3a5b537 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -16,11 +16,7 @@ #undef XC_WANT_COMPAT_MAP_FOREIGN_API #include -#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 420 -# include -#else -# include -#endif +#include #include #include "hw/hw.h" @@ -30,129 +26,11 @@ #include "trace.h" /* - * We don't support Xen prior to 3.3.0. + * We don't support Xen prior to 4.2.0. */ -/* Xen before 4.0 */ -#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 400 -static inline void *xc_map_foreign_bulk(int xc_handle, uint32_t dom, int prot, - xen_pfn_t *arr, int *err, - unsigned int num) -{ - return xc_map_foreign_batch(xc_handle, dom, prot, arr, num); -} -#endif - - -/* Xen before 4.1 */ -#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 410 - -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 - -static inline xenevtchn_handle *xenevtchn_open(void *logger, - unsigned int open_flags) -{ - xenevtchn_handle *h = malloc(sizeof(*h)); - if (!h) { - return NULL; - } - *h = xc_evtchn_open(); - if (*h == -1) { - free(h); - h = NULL; - } - return h; -} -static inline int xenevtchn_close(xenevtchn_handle *h) -{ - int rc = xc_evtchn_close(*h); - free(h); - return rc; -} -#define xenevtchn_fd(h) xc_evtchn_fd(*h) -#define xenevtchn_pending(h) xc_evtchn_pending(*h) -#define xenevtchn_notify(h, p) xc_evtchn_notify(*h, p) -#define xenevtchn_bind_interdomain(h, d, p) xc_evtchn_bind_interdomain(*h, d, p) -#define xenevtchn_unmask(h, p) xc_evtchn_unmask(*h, p) -#define xenevtchn_unbind(h, p) xc_evtchn_unmask(*h, p) - -static inline xengnttab_handle *xengnttab_open(void *logger, - unsigned int open_flags) -{ - xengnttab_handle *h = malloc(sizeof(*h)); - if (!h) { - return NULL; - } - *h = xc_gnttab_open(); - if (*h == -1) { - free(h); - h = NULL; - } - return h; -} -static inline int xengnttab_close(xengnttab_handle *h) -{ - int rc = xc_gnttab_close(*h); - free(h); - return rc; -} -#define xengnttab_set_max_grants(h, n) xc_gnttab_set_max_grants(*h, n) -#define xengnttab_map_grant_ref(h, d, r, p) xc_gnttab_map_grant_ref(*h, d, r, p) -#define xengnttab_map_grant_refs(h, c, d, r, p) \ - xc_gnttab_map_grant_refs(*h, c, d, r, p) -#define xengnttab_unmap(h, a, n) xc_gnttab_munmap(*h, a, n) - -static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger, - unsigned int open_flags) -{ - return xc_interface_open(); -} - -/* See below for xenforeignmemory_* APIs */ - -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) -{ - return xc_domain_memory_populate_physmap - (xc_handle, domid, nr_extents, extent_order, mem_flags, extent_start); -} - -static inline int xc_domain_add_to_physmap(int xc_handle, uint32_t domid, - unsigned int space, unsigned long idx, - xen_pfn_t gpfn) -{ - struct xen_add_to_physmap xatp = { - .domid = domid, - .space = space, - .idx = idx, - .gpfn = gpfn, - }; - - return xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp); -} - -static inline struct xs_handle *xs_open(unsigned long flags) -{ - return xs_daemon_open(); -} - -static inline void xs_close(struct xs_handle *xsh) -{ - if (xsh != NULL) { - xs_daemon_close(xsh); - } -} - - -/* Xen 4.1 thru 4.6 */ -#elif CONFIG_XEN_CTRL_INTERFACE_VERSION < 471 +/* Xen 4.2 thru 4.6 */ +#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471 typedef xc_interface *XenXC; typedef xc_interface *xenforeignmemory_handle; @@ -205,27 +83,11 @@ static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger, } #endif -/* Xen before 4.2 */ -#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 420 -static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom, - uint64_t addr, uint32_t data) -{ - return -ENOSYS; -} -/* The followings are only to compile op_discard related code on older - * Xen releases. */ -#define BLKIF_OP_DISCARD 5 -struct blkif_request_discard { - uint64_t nr_sectors; - uint64_t sector_number; -}; -#else static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom, uint64_t addr, uint32_t data) { return xc_hvm_inject_msi(xen_xc, dom, addr, data); } -#endif void destroy_hvm_domain(bool reboot); diff --git a/xen-hvm.c b/xen-hvm.c index 6861c51..8350ca2 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -316,7 +316,6 @@ static hwaddr xen_phys_offset_to_gaddr(hwaddr start_addr, return start_addr; } -#if CONFIG_XEN_CTRL_INTERFACE_VERSION >= 340 static int xen_add_to_physmap(XenIOState *state, hwaddr start_addr, ram_addr_t size, @@ -451,24 +450,6 @@ static int xen_remove_from_physmap(XenIOState *state, return 0; } -#else -static int xen_add_to_physmap(XenIOState *state, - hwaddr start_addr, - ram_addr_t size, - MemoryRegion *mr, - hwaddr offset_within_region) -{ - return -ENOSYS; -} - -static int xen_remove_from_physmap(XenIOState *state, - hwaddr start_addr, - ram_addr_t size) -{ - return -ENOSYS; -} -#endif - static void xen_set_memory(struct MemoryListener *listener, MemoryRegionSection *section, bool add)