From patchwork Tue Feb 9 16:17:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 8263721 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 171D2BEEED for ; Tue, 9 Feb 2016 16:20:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC95F20260 for ; Tue, 9 Feb 2016 16:20:01 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 424BD20270 for ; Tue, 9 Feb 2016 16:20:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTAyk-0006Va-DP; Tue, 09 Feb 2016 16:17:26 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTAyj-0006UU-5b for xen-devel@lists.xen.org; Tue, 09 Feb 2016 16:17:25 +0000 Received: from [85.158.143.35] by server-3.bemta-4.messagelabs.com id 7C/8F-31122-4111AB65; Tue, 09 Feb 2016 16:17:24 +0000 X-Env-Sender: prvs=840c16f44=Ian.Campbell@citrix.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1455034642!14826104!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 32492 invoked from network); 9 Feb 2016 16:17:23 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 9 Feb 2016 16:17:23 -0000 X-IronPort-AV: E=Sophos;i="5.22,421,1449532800"; d="scan'208";a="330600110" From: Ian Campbell To: , Date: Tue, 9 Feb 2016 16:17:14 +0000 Message-ID: <1455034636-27829-3-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455034615.19857.96.camel@citrix.com> References: <1455034615.19857.96.camel@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Campbell , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH 3/5] xen: drop XenXC and associated interface wrappers X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Now that 4.2 and earlier are no longer supported "xc_interface *" is always the right type for the xc interface handle. Signed-off-by: Ian Campbell Reviewed-by: Stefano Stabellini --- hw/xen/xen_backend.c | 4 +-- include/hw/xen/xen_backend.h | 2 +- include/hw/xen/xen_common.h | 82 +++++++++++++++++--------------------------- xen-common.c | 4 +-- xen-hvm.c | 16 ++++----- 5 files changed, 44 insertions(+), 64 deletions(-) diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index ef7843f..60575ad 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -36,7 +36,7 @@ /* ------------------------------------------------------------- */ /* public */ -XenXC xen_xc = XC_HANDLER_INITIAL_VALUE; +xc_interface *xen_xc = NULL; xenforeignmemory_handle *xen_fmem = NULL; struct xs_handle *xenstore = NULL; const char *xen_protocol; @@ -710,7 +710,7 @@ int xen_be_init(void) qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL); - if (xen_xc == XC_HANDLER_INITIAL_VALUE || xen_fmem == NULL) { + if (xen_xc == NULL || xen_fmem == NULL) { /* Check if xen_init() have been called */ goto err; } diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h index e0d52ee..c839eeb 100644 --- a/include/hw/xen/xen_backend.h +++ b/include/hw/xen/xen_backend.h @@ -56,7 +56,7 @@ struct XenDevice { /* ------------------------------------------------------------- */ /* variables */ -extern XenXC xen_xc; +extern xc_interface *xen_xc; extern xenforeignmemory_handle *xen_fmem; extern struct xs_handle *xenstore; extern const char *xen_protocol; diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index ec3ca56..254ef14 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -32,14 +32,10 @@ /* Xen 4.2 thru 4.6 */ #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471 -typedef xc_interface *XenXC; -typedef xc_interface *xenforeignmemory_handle; +typedef xc_interface xenforeignmemory_handle; typedef xc_evtchn xenevtchn_handle; typedef xc_gnttab xengnttab_handle; -# define XC_INTERFACE_FMT "%p" -# define XC_HANDLER_INITIAL_VALUE NULL - #define xenevtchn_open(l, f) xc_evtchn_open(l, f); #define xenevtchn_close(h) xc_evtchn_close(h) #define xenevtchn_fd(h) xc_evtchn_fd(h) @@ -57,30 +53,14 @@ typedef xc_gnttab xengnttab_handle; #define xengnttab_map_grant_refs(h, c, d, r, p) \ xc_gnttab_map_grant_refs(h, c, d, r, p) -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); -} - /* See below for xenforeignmemory_* APIs */ #else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 471 */ -typedef xc_interface *XenXC; - -# define XC_INTERFACE_FMT "%p" -# define XC_HANDLER_INITIAL_VALUE NULL - #include #include #include -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); -} #endif void destroy_hvm_domain(bool reboot); @@ -89,7 +69,7 @@ void destroy_hvm_domain(bool reboot); void xen_shutdown_fatal_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2); #ifdef HVM_PARAM_VMPORT_REGS_PFN -static inline int xen_get_vmport_regs_pfn(XenXC xc, domid_t dom, +static inline int xen_get_vmport_regs_pfn(xc_interface *xc, domid_t dom, xen_pfn_t *vmport_regs_pfn) { int rc; @@ -101,7 +81,7 @@ static inline int xen_get_vmport_regs_pfn(XenXC xc, domid_t dom, return rc; } #else -static inline int xen_get_vmport_regs_pfn(XenXC xc, domid_t dom, +static inline int xen_get_vmport_regs_pfn(xc_interface *xc, domid_t dom, xen_pfn_t *vmport_regs_pfn) { return -ENOSYS; @@ -128,54 +108,54 @@ static inline int xen_get_vmport_regs_pfn(XenXC xc, domid_t dom, typedef uint16_t ioservid_t; -static inline void xen_map_memory_section(XenXC xc, domid_t dom, +static inline void xen_map_memory_section(xc_interface *xc, domid_t dom, ioservid_t ioservid, MemoryRegionSection *section) { } -static inline void xen_unmap_memory_section(XenXC xc, domid_t dom, +static inline void xen_unmap_memory_section(xc_interface *xc, domid_t dom, ioservid_t ioservid, MemoryRegionSection *section) { } -static inline void xen_map_io_section(XenXC xc, domid_t dom, +static inline void xen_map_io_section(xc_interface *xc, domid_t dom, ioservid_t ioservid, MemoryRegionSection *section) { } -static inline void xen_unmap_io_section(XenXC xc, domid_t dom, +static inline void xen_unmap_io_section(xc_interface *xc, domid_t dom, ioservid_t ioservid, MemoryRegionSection *section) { } -static inline void xen_map_pcidev(XenXC xc, domid_t dom, +static inline void xen_map_pcidev(xc_interface *xc, domid_t dom, ioservid_t ioservid, PCIDevice *pci_dev) { } -static inline void xen_unmap_pcidev(XenXC xc, domid_t dom, +static inline void xen_unmap_pcidev(xc_interface *xc, domid_t dom, ioservid_t ioservid, PCIDevice *pci_dev) { } -static inline int xen_create_ioreq_server(XenXC xc, domid_t dom, +static inline int xen_create_ioreq_server(xc_interface *xc, domid_t dom, ioservid_t *ioservid) { return 0; } -static inline void xen_destroy_ioreq_server(XenXC xc, domid_t dom, +static inline void xen_destroy_ioreq_server(xc_interface *xc, domid_t dom, ioservid_t ioservid) { } -static inline int xen_get_ioreq_server_info(XenXC xc, domid_t dom, +static inline int xen_get_ioreq_server_info(xc_interface *xc, domid_t dom, ioservid_t ioservid, xen_pfn_t *ioreq_pfn, xen_pfn_t *bufioreq_pfn, @@ -212,7 +192,7 @@ static inline int xen_get_ioreq_server_info(XenXC xc, domid_t dom, return 0; } -static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom, +static inline int xen_set_ioreq_server_state(xc_interface *xc, domid_t dom, ioservid_t ioservid, bool enable) { @@ -222,7 +202,7 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom, /* Xen 4.5 */ #else -static inline void xen_map_memory_section(XenXC xc, domid_t dom, +static inline void xen_map_memory_section(xc_interface *xc, domid_t dom, ioservid_t ioservid, MemoryRegionSection *section) { @@ -235,7 +215,7 @@ static inline void xen_map_memory_section(XenXC xc, domid_t dom, start_addr, end_addr); } -static inline void xen_unmap_memory_section(XenXC xc, domid_t dom, +static inline void xen_unmap_memory_section(xc_interface *xc, domid_t dom, ioservid_t ioservid, MemoryRegionSection *section) { @@ -248,7 +228,7 @@ static inline void xen_unmap_memory_section(XenXC xc, domid_t dom, start_addr, end_addr); } -static inline void xen_map_io_section(XenXC xc, domid_t dom, +static inline void xen_map_io_section(xc_interface *xc, domid_t dom, ioservid_t ioservid, MemoryRegionSection *section) { @@ -261,7 +241,7 @@ static inline void xen_map_io_section(XenXC xc, domid_t dom, start_addr, end_addr); } -static inline void xen_unmap_io_section(XenXC xc, domid_t dom, +static inline void xen_unmap_io_section(xc_interface *xc, domid_t dom, ioservid_t ioservid, MemoryRegionSection *section) { @@ -274,7 +254,7 @@ static inline void xen_unmap_io_section(XenXC xc, domid_t dom, start_addr, end_addr); } -static inline void xen_map_pcidev(XenXC xc, domid_t dom, +static inline void xen_map_pcidev(xc_interface *xc, domid_t dom, ioservid_t ioservid, PCIDevice *pci_dev) { @@ -286,7 +266,7 @@ static inline void xen_map_pcidev(XenXC xc, domid_t dom, PCI_FUNC(pci_dev->devfn)); } -static inline void xen_unmap_pcidev(XenXC xc, domid_t dom, +static inline void xen_unmap_pcidev(xc_interface *xc, domid_t dom, ioservid_t ioservid, PCIDevice *pci_dev) { @@ -298,7 +278,7 @@ static inline void xen_unmap_pcidev(XenXC xc, domid_t dom, PCI_FUNC(pci_dev->devfn)); } -static inline int xen_create_ioreq_server(XenXC xc, domid_t dom, +static inline int xen_create_ioreq_server(xc_interface *xc, domid_t dom, ioservid_t *ioservid) { int rc = xc_hvm_create_ioreq_server(xc, dom, HVM_IOREQSRV_BUFIOREQ_ATOMIC, @@ -311,14 +291,14 @@ static inline int xen_create_ioreq_server(XenXC xc, domid_t dom, return rc; } -static inline void xen_destroy_ioreq_server(XenXC xc, domid_t dom, +static inline void xen_destroy_ioreq_server(xc_interface *xc, domid_t dom, ioservid_t ioservid) { trace_xen_ioreq_server_destroy(ioservid); xc_hvm_destroy_ioreq_server(xc, dom, ioservid); } -static inline int xen_get_ioreq_server_info(XenXC xc, domid_t dom, +static inline int xen_get_ioreq_server_info(xc_interface *xc, domid_t dom, ioservid_t ioservid, xen_pfn_t *ioreq_pfn, xen_pfn_t *bufioreq_pfn, @@ -329,7 +309,7 @@ static inline int xen_get_ioreq_server_info(XenXC xc, domid_t dom, bufioreq_evtchn); } -static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom, +static inline int xen_set_ioreq_server_state(xc_interface *xc, domid_t dom, ioservid_t ioservid, bool enable) { @@ -340,7 +320,7 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom, #endif #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 460 -static inline int xen_xc_domain_add_to_physmap(XenXC xch, uint32_t domid, +static inline int xen_xc_domain_add_to_physmap(xc_interface *xch, uint32_t domid, unsigned int space, unsigned long idx, xen_pfn_t gpfn) @@ -348,7 +328,7 @@ static inline int xen_xc_domain_add_to_physmap(XenXC xch, uint32_t domid, return xc_domain_add_to_physmap(xch, domid, space, idx, gpfn); } #else -static inline int xen_xc_domain_add_to_physmap(XenXC xch, uint32_t domid, +static inline int xen_xc_domain_add_to_physmap(xc_interface *xch, uint32_t domid, unsigned int space, unsigned long idx, xen_pfn_t gpfn) @@ -363,14 +343,14 @@ static inline int xen_xc_domain_add_to_physmap(XenXC xch, uint32_t domid, #ifdef CONFIG_XEN_PV_DOMAIN_BUILD #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 470 -static inline int xen_domain_create(XenXC xc, uint32_t ssidref, +static inline int xen_domain_create(xc_interface *xc, uint32_t ssidref, xen_domain_handle_t handle, uint32_t flags, uint32_t *pdomid) { return xc_domain_create(xc, ssidref, handle, flags, pdomid); } #else -static inline int xen_domain_create(XenXC xc, uint32_t ssidref, +static inline int xen_domain_create(xc_interface *xc, uint32_t ssidref, xen_domain_handle_t handle, uint32_t flags, uint32_t *pdomid) { @@ -381,17 +361,17 @@ static inline int xen_domain_create(XenXC xc, uint32_t ssidref, #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471 -#define xenforeignmemory_open(l, f) &xen_xc +#define xenforeignmemory_open(l, f) xen_xc -static inline void *xenforeignmemory_map(XenXC *h, uint32_t dom, +static inline void *xenforeignmemory_map(xc_interface *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); + return xc_map_foreign_bulk(h, dom, prot, arr, err, pages); else - return xc_map_foreign_pages(*h, dom, prot, arr, pages); + return xc_map_foreign_pages(h, dom, prot, arr, pages); } #define xenforeignmemory_unmap(h, p, s) munmap(p, s * XC_PAGE_SIZE) diff --git a/xen-common.c b/xen-common.c index 4860b2e..e641ad1 100644 --- a/xen-common.c +++ b/xen-common.c @@ -114,8 +114,8 @@ static void xen_change_state_handler(void *opaque, int running, static int xen_init(MachineState *ms) { - xen_xc = xen_xc_interface_open(0, 0, 0); - if (xen_xc == XC_HANDLER_INITIAL_VALUE) { + xen_xc = xc_interface_open(0, 0, 0); + if (xen_xc == NULL) { xen_be_printf(NULL, 0, "can't open xen interface\n"); return -1; } diff --git a/xen-hvm.c b/xen-hvm.c index 918cabc..fbe0e3a 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -1224,7 +1224,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) &ioreq_pfn, &bufioreq_pfn, &bufioreq_evtchn); if (rc < 0) { - error_report("failed to get ioreq server info: error %d handle=" XC_INTERFACE_FMT, + error_report("failed to get ioreq server info: error %d handle=%p", errno, xen_xc); goto err; } @@ -1237,7 +1237,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) PROT_READ|PROT_WRITE, 1, &ioreq_pfn, NULL); if (state->shared_page == NULL) { - error_report("map shared IO page returned error %d handle=" XC_INTERFACE_FMT, + error_report("map shared IO page returned error %d handle=%p", errno, xen_xc); goto err; } @@ -1249,8 +1249,8 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ|PROT_WRITE, 1, &ioreq_pfn, NULL); if (state->shared_vmport_page == NULL) { - error_report("map shared vmport IO page returned error %d handle=" - XC_INTERFACE_FMT, errno, xen_xc); + error_report("map shared vmport IO page returned error %d handle=%p", + errno, xen_xc); goto err; } } else if (rc != -ENOSYS) { @@ -1272,7 +1272,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) rc = xen_set_ioreq_server_state(xen_xc, xen_domid, state->ioservid, true); if (rc < 0) { - error_report("failed to enable ioreq server info: error %d handle=" XC_INTERFACE_FMT, + error_report("failed to enable ioreq server info: error %d handle=%p", errno, xen_xc); goto err; } @@ -1333,11 +1333,11 @@ err: void destroy_hvm_domain(bool reboot) { - XenXC xc_handle; + xc_interface *xc_handle; int sts; - xc_handle = xen_xc_interface_open(0, 0, 0); - if (xc_handle == XC_HANDLER_INITIAL_VALUE) { + xc_handle = xc_interface_open(0, 0, 0); + if (xc_handle == NULL) { fprintf(stderr, "Cannot acquire xenctrl handle\n"); } else { sts = xc_domain_shutdown(xc_handle, xen_domid,