From patchwork Fri Sep 17 11:14:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 65059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4CB44B70AB for ; Fri, 17 Sep 2010 21:18:22 +1000 (EST) Received: from localhost ([127.0.0.1]:54456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OwYxO-0006QN-DV for incoming@patchwork.ozlabs.org; Fri, 17 Sep 2010 07:18:18 -0400 Received: from [140.186.70.92] (port=37050 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OwYvf-0006LO-OQ for qemu-devel@nongnu.org; Fri, 17 Sep 2010 07:16:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OwYvc-00081Q-Le for qemu-devel@nongnu.org; Fri, 17 Sep 2010 07:16:30 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:45944) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OwYvc-00081M-Cr for qemu-devel@nongnu.org; Fri, 17 Sep 2010 07:16:28 -0400 X-IronPort-AV: E=Sophos;i="4.56,381,1280721600"; d="scan'208";a="114266504" Received: from ftlpexchmx01.citrite.net ([10.9.154.126]) by FTLPIPO02.CITRIX.COM with ESMTP; 17 Sep 2010 07:16:27 -0400 Received: from smtp01.ad.xensource.com ([10.219.128.104]) by FTLPEXCHMX01.citrite.net with Microsoft SMTPSVC(6.0.3790.4675); Fri, 17 Sep 2010 07:16:16 -0400 Received: from localhost.localdomain (perard.cam.xci-test.com [10.80.248.106]) by smtp01.ad.xensource.com (8.13.1/8.13.1) with ESMTP id o8HBFpao017817; Fri, 17 Sep 2010 04:16:26 -0700 From: anthony.perard@citrix.com To: qemu-devel@nongnu.org Date: Fri, 17 Sep 2010 12:14:56 +0100 Message-Id: <1284722107-28550-2-git-send-email-anthony.perard@citrix.com> X-Mailer: git-send-email 1.6.5 In-Reply-To: <1284722107-28550-1-git-send-email-anthony.perard@citrix.com> References: <1284722107-28550-1-git-send-email-anthony.perard@citrix.com> X-OriginalArrivalTime: 17 Sep 2010 11:16:16.0694 (UTC) FILETIME=[BF036560:01CB5659] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: anthony.perard@citrix.com, Stefano Stabellini , xen-devel@lists.xensource.com, Stefano.Stabellini@eu.citrix.com Subject: [Qemu-devel] [PATCH RFC V3 01/12] xen: Support new libxc calls from xen unstable. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Anthony PERARD Update the libxenctrl calls in Qemu to use the new interface, otherwise Qemu wouldn't be able to build against new versions of the library. Signed-off-by: Anthony PERARD Signed-off-by: Stefano Stabellini --- configure | 5 +++++ hw/xen_backend.c | 10 +++++----- hw/xen_backend.h | 2 +- hw/xen_common.h | 23 ++++++++++++++++++++++- hw/xen_disk.c | 12 ++++++------ hw/xen_domainbuild.c | 2 +- hw/xen_nic.c | 16 ++++++++-------- 7 files changed, 48 insertions(+), 22 deletions(-) diff --git a/configure b/configure index 4061cb7..0d745e0 100755 --- a/configure +++ b/configure @@ -1113,7 +1113,12 @@ if test "$xen" != "no" ; then cat > $TMPC < #include +#include +#if __XEN_LATEST_INTERFACE_VERSION__ < 0x0003020a int main(void) { xs_daemon_open(); xc_interface_open(); return 0; } +#else +int main(void) { xs_daemon_open(); xc_interface_open(0, 0, 0); return 0; } +#endif EOF if compile_prog "" "$xen_libs" ; then xen=yes diff --git a/hw/xen_backend.c b/hw/xen_backend.c index a2e408f..b23620f 100644 --- a/hw/xen_backend.c +++ b/hw/xen_backend.c @@ -43,7 +43,7 @@ /* ------------------------------------------------------------- */ /* public */ -int xen_xc; +qemu_xc_interface xen_xc = XC_HANDLER_INITIAL_VALUE; struct xs_handle *xenstore = NULL; const char *xen_protocol; @@ -216,7 +216,7 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev, fcntl(xc_evtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC); if (ops->flags & DEVOPS_FLAG_NEED_GNTDEV) { - xendev->gnttabdev = xc_gnttab_open(); + xendev->gnttabdev = xc_gnttab_open(xen_xc); if (xendev->gnttabdev < 0) { xen_be_printf(NULL, 0, "can't open gnttab device\n"); xc_evtchn_close(xendev->evtchndev); @@ -269,7 +269,7 @@ static struct XenDevice *xen_be_del_xendev(int dom, int dev) if (xendev->evtchndev >= 0) xc_evtchn_close(xendev->evtchndev); if (xendev->gnttabdev >= 0) - xc_gnttab_close(xendev->gnttabdev); + xc_gnttab_close(xen_xc, xendev->gnttabdev); QTAILQ_REMOVE(&xendevs, xendev, next); qemu_free(xendev); @@ -627,8 +627,8 @@ int xen_be_init(void) if (qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL) < 0) goto err; - xen_xc = xc_interface_open(); - if (xen_xc == -1) { + xen_xc = xc_interface_open(NULL, NULL, 0); + if (xen_xc == XC_HANDLER_INITIAL_VALUE) { xen_be_printf(NULL, 0, "can't open xen interface\n"); goto err; } diff --git a/hw/xen_backend.h b/hw/xen_backend.h index 292126d..1f23cde 100644 --- a/hw/xen_backend.h +++ b/hw/xen_backend.h @@ -55,7 +55,7 @@ struct XenDevice { /* ------------------------------------------------------------- */ /* variables */ -extern int xen_xc; +extern qemu_xc_interface xen_xc; extern struct xs_handle *xenstore; extern const char *xen_protocol; diff --git a/hw/xen_common.h b/hw/xen_common.h index 8a55b44..2cbc376 100644 --- a/hw/xen_common.h +++ b/hw/xen_common.h @@ -16,7 +16,8 @@ * tweaks needed to build with different xen versions * 0x00030205 -> 3.1.0 * 0x00030207 -> 3.2.0 - * 0x00030208 -> unstable + * 0x00030209 -> 3.3.0 + * 0x0003020a -> unstable */ #include #if __XEN_LATEST_INTERFACE_VERSION__ < 0x00030205 @@ -31,4 +32,24 @@ # define xen_wmb() wmb() #endif +#if __XEN_LATEST_INTERFACE_VERSION__ < 0x0003020a +typedef int qemu_xc_interface; +# define XC_HANDLER_INITIAL_VALUE -1 +# define xc_fd(xen_xc) xen_xc +# define xc_interface_open(l, dl, f) xc_interface_open() +# define xc_gnttab_open(xc) xc_gnttab_open() +# define xc_gnttab_map_grant_ref(xc, gnt, domid, ref, flags) \ + xc_gnttab_map_grant_ref(gnt, domid, ref, flags) +# define xc_gnttab_map_grant_refs(xc, gnt, count, domids, refs, flags) \ + xc_gnttab_map_grant_refs(gnt, count, domids, refs, flags) +# define xc_gnttab_munmap(xc, gnt, pages, niov) xc_gnttab_munmap(gnt, pages, niov) +# define xc_gnttab_close(xc, dev) xc_gnttab_close(dev) +#else +typedef xc_interface *qemu_xc_interface; +# define XC_HANDLER_INITIAL_VALUE NULL +/* FIXME The fd of xen_xc is now xen_xc->fd */ +/* fd is the first field, so this works */ +# define xc_fd(xen_xc) (*(int*)xen_xc) +#endif + #endif /* QEMU_HW_XEN_COMMON_H */ diff --git a/hw/xen_disk.c b/hw/xen_disk.c index 134ac33..e38e155 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -243,7 +243,7 @@ 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) + if (xc_gnttab_munmap(xen_xc, gnt, ioreq->pages, ioreq->v.niov) != 0) xen_be_printf(&ioreq->blkdev->xendev, 0, "xc_gnttab_munmap failed: %s\n", strerror(errno)); ioreq->blkdev->cnt_map -= ioreq->v.niov; @@ -252,7 +252,7 @@ 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) + if (xc_gnttab_munmap(xen_xc, gnt, ioreq->page[i], 1) != 0) xen_be_printf(&ioreq->blkdev->xendev, 0, "xc_gnttab_munmap failed: %s\n", strerror(errno)); ioreq->blkdev->cnt_map--; @@ -270,7 +270,7 @@ static int ioreq_map(struct ioreq *ioreq) return 0; if (batch_maps) { ioreq->pages = xc_gnttab_map_grant_refs - (gnt, ioreq->v.niov, ioreq->domids, ioreq->refs, ioreq->prot); + (xen_xc, gnt, ioreq->v.niov, ioreq->domids, ioreq->refs, ioreq->prot); if (ioreq->pages == NULL) { xen_be_printf(&ioreq->blkdev->xendev, 0, "can't map %d grant refs (%s, %d maps)\n", @@ -284,7 +284,7 @@ static int ioreq_map(struct ioreq *ioreq) } else { for (i = 0; i < ioreq->v.niov; i++) { ioreq->page[i] = xc_gnttab_map_grant_ref - (gnt, ioreq->domids[i], ioreq->refs[i], ioreq->prot); + (xen_xc, gnt, ioreq->domids[i], ioreq->refs[i], ioreq->prot); if (ioreq->page[i] == NULL) { xen_be_printf(&ioreq->blkdev->xendev, 0, "can't map grant ref %d (%s, %d maps)\n", @@ -684,7 +684,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 = xc_gnttab_map_grant_ref(xen_xc, blkdev->xendev.gnttabdev, blkdev->xendev.dom, blkdev->ring_ref, PROT_READ | PROT_WRITE); @@ -739,7 +739,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); + xc_gnttab_munmap(xen_xc, blkdev->xendev.gnttabdev, blkdev->sring, 1); blkdev->cnt_map--; blkdev->sring = NULL; } diff --git a/hw/xen_domainbuild.c b/hw/xen_domainbuild.c index 7f1fd66..232a456 100644 --- a/hw/xen_domainbuild.c +++ b/hw/xen_domainbuild.c @@ -176,7 +176,7 @@ static int xen_domain_watcher(void) for (i = 3; i < n; i++) { if (i == fd[0]) continue; - if (i == xen_xc) + if (i == xc_fd(xen_xc)) continue; close(i); } diff --git a/hw/xen_nic.c b/hw/xen_nic.c index 08055b8..4f68850 100644 --- a/hw/xen_nic.c +++ b/hw/xen_nic.c @@ -166,7 +166,7 @@ static void net_tx_packets(struct XenNetDev *netdev) (txreq.flags & NETTXF_more_data) ? " more_data" : "", (txreq.flags & NETTXF_extra_info) ? " extra_info" : ""); - page = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev, + page = xc_gnttab_map_grant_ref(xen_xc, netdev->xendev.gnttabdev, netdev->xendev.dom, txreq.gref, PROT_READ); if (page == NULL) { @@ -185,7 +185,7 @@ static void net_tx_packets(struct XenNetDev *netdev) } else { qemu_send_packet(&netdev->nic->nc, page + txreq.offset, txreq.size); } - xc_gnttab_munmap(netdev->xendev.gnttabdev, page, 1); + xc_gnttab_munmap(xen_xc, netdev->xendev.gnttabdev, page, 1); net_tx_response(netdev, &txreq, NETIF_RSP_OKAY); } if (!netdev->tx_work) @@ -272,7 +272,7 @@ static ssize_t net_rx_packet(VLANClientState *nc, const uint8_t *buf, size_t siz memcpy(&rxreq, RING_GET_REQUEST(&netdev->rx_ring, rc), sizeof(rxreq)); netdev->rx_ring.req_cons = ++rc; - page = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev, + page = xc_gnttab_map_grant_ref(xen_xc, netdev->xendev.gnttabdev, netdev->xendev.dom, rxreq.gref, PROT_WRITE); if (page == NULL) { @@ -282,7 +282,7 @@ static ssize_t net_rx_packet(VLANClientState *nc, const uint8_t *buf, size_t siz return -1; } memcpy(page + NET_IP_ALIGN, buf, size); - xc_gnttab_munmap(netdev->xendev.gnttabdev, page, 1); + xc_gnttab_munmap(xen_xc, netdev->xendev.gnttabdev, page, 1); net_rx_response(netdev, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, size, 0); return size; @@ -350,11 +350,11 @@ static int net_connect(struct XenDevice *xendev) return -1; } - netdev->txs = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev, + netdev->txs = xc_gnttab_map_grant_ref(xen_xc, netdev->xendev.gnttabdev, netdev->xendev.dom, netdev->tx_ring_ref, PROT_READ | PROT_WRITE); - netdev->rxs = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev, + netdev->rxs = xc_gnttab_map_grant_ref(xen_xc, netdev->xendev.gnttabdev, netdev->xendev.dom, netdev->rx_ring_ref, PROT_READ | PROT_WRITE); @@ -381,11 +381,11 @@ static void net_disconnect(struct XenDevice *xendev) xen_be_unbind_evtchn(&netdev->xendev); if (netdev->txs) { - xc_gnttab_munmap(netdev->xendev.gnttabdev, netdev->txs, 1); + xc_gnttab_munmap(xen_xc, netdev->xendev.gnttabdev, netdev->txs, 1); netdev->txs = NULL; } if (netdev->rxs) { - xc_gnttab_munmap(netdev->xendev.gnttabdev, netdev->rxs, 1); + xc_gnttab_munmap(xen_xc, netdev->xendev.gnttabdev, netdev->rxs, 1); netdev->rxs = NULL; } if (netdev->nic) {