From patchwork Fri Jan 15 13:23:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 8041171 Return-Path: X-Original-To: patchwork-xen-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 DECC59F859 for ; Fri, 15 Jan 2016 13:55:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DCDD7203F4 for ; Fri, 15 Jan 2016 13:55:24 +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 B2868203B4 for ; Fri, 15 Jan 2016 13:55:23 +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 1aK4nn-0003Yk-Bl; Fri, 15 Jan 2016 13:52:31 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aK4ME-0004Fw-Ab for xen-devel@lists.xen.org; Fri, 15 Jan 2016 13:24:02 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id D9/06-09708-2F2F8965; Fri, 15 Jan 2016 13:24:02 +0000 X-Env-Sender: prvs=815b692d9=Ian.Campbell@citrix.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1452864226!10324840!8 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 25235 invoked from network); 15 Jan 2016 13:24:01 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-5.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 15 Jan 2016 13:24:01 -0000 X-IronPort-AV: E=Sophos;i="5.22,299,1449532800"; d="scan'208";a="325395886" From: Ian Campbell To: , , Date: Fri, 15 Jan 2016 13:23:54 +0000 Message-ID: <1452864236-2645-3-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452864236-2645-1-git-send-email-ian.campbell@citrix.com> References: <1452864168.32341.97.camel@citrix.com> <1452864236-2645-1-git-send-email-ian.campbell@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Campbell Subject: [Xen-devel] [PATCH QEMU-XEN-TRADITIONAL v8 2/4] qemu-xen-traditional: Use libxengnttab 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 /dev/xen/gntdev related wrappers have been moved out of libxenctrl into their own library. Signed-off-by: Ian Campbell Acked-by: Ian Jackson --- v3: Library moved to tools/libs/ v7: s/gnttab_munmap/gnttab_unmap/ to reflect change to the library API. --- 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(-) diff --git a/hw/xen_backend.c b/hw/xen_backend.c index 40f6887..97d25da 100644 --- a/hw/xen_backend.c +++ b/hw/xen_backend.c @@ -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); diff --git a/hw/xen_backend.h b/hw/xen_backend.h index 60f18f8..ba1e12f 100644 --- a/hw/xen_backend.h +++ b/hw/xen_backend.h @@ -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; diff --git a/hw/xen_common.h b/hw/xen_common.h index cee908f..cc48892 100644 --- a/hw/xen_common.h +++ b/hw/xen_common.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include diff --git a/hw/xen_console.c b/hw/xen_console.c index 80beb31..0bb4469 100644 --- a/hw/xen_console.c +++ b/hw/xen_console.c @@ -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_unmap(xendev->gnttabdev, con->sring, 1); con->sring = NULL; } } diff --git a/hw/xen_disk.c b/hw/xen_disk.c index 250d806..bc78748 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -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_unmap(gnt, ioreq->pages, ioreq->v.niov) != 0) + xen_be_printf(&ioreq->blkdev->xendev, 0, "xengnttab_unmap 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_unmap(gnt, ioreq->page[i], 1) != 0) + xen_be_printf(&ioreq->blkdev->xendev, 0, "xengnttab_unmap 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_unmap(blkdev->xendev.gnttabdev, blkdev->sring, 1); blkdev->cnt_map--; blkdev->sring = NULL; } diff --git a/xen-hooks.mak b/xen-hooks.mak index 18259d4..179a6b7 100644 --- a/xen-hooks.mak +++ b/xen-hooks.mak @@ -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