From patchwork Tue Jan 11 15:37:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 78400 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 96675B70CC for ; Wed, 12 Jan 2011 03:01:21 +1100 (EST) Received: from localhost ([127.0.0.1]:57030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcgJR-0002gA-1G for incoming@patchwork.ozlabs.org; Tue, 11 Jan 2011 10:39:09 -0500 Received: from [140.186.70.92] (port=36467 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcgIK-0002Vj-7u for qemu-devel@nongnu.org; Tue, 11 Jan 2011 10:38:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PcgII-0001Fu-E9 for qemu-devel@nongnu.org; Tue, 11 Jan 2011 10:38:00 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:11624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PcgII-0001FT-7C for qemu-devel@nongnu.org; Tue, 11 Jan 2011 10:37:58 -0500 X-IronPort-AV: E=Sophos;i="4.60,307,1291611600"; d="scan'208";a="130506318" Received: from ftlpexchmx01.citrite.net ([10.9.154.126]) by FTLPIPO02.CITRIX.COM with ESMTP; 11 Jan 2011 10:37:57 -0500 Received: from smtp01.ad.xensource.com ([10.219.128.104]) by FTLPEXCHMX01.citrite.net with Microsoft SMTPSVC(6.0.3790.4675); Tue, 11 Jan 2011 10:37:56 -0500 Received: from perard.cam.xci-test.com (perard.cam.xci-test.com [10.80.248.106]) by smtp01.ad.xensource.com (8.13.1/8.13.1) with ESMTP id p0BFbrT0006240; Tue, 11 Jan 2011 07:37:55 -0800 From: anthony.perard@citrix.com To: QEMU-devel Date: Tue, 11 Jan 2011 15:37:02 +0000 Message-Id: <1294760223-26151-2-git-send-email-anthony.perard@citrix.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1294760223-26151-1-git-send-email-anthony.perard@citrix.com> References: <1294760223-26151-1-git-send-email-anthony.perard@citrix.com> X-OriginalArrivalTime: 11 Jan 2011 15:37:57.0168 (UTC) FILETIME=[85249B00:01CBB1A5] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Anthony PERARD , Xen Devel Subject: [Qemu-devel] [PATCH 1/2] xen: Add xc_domain_add_to_physmap to xen_interface. 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 This function will be used to support sync dirty bitmap. This come with a check against every Xen release, and special implementation for Xen version that doesn't have this specific call. This function will not be usable with Xen 3.3 because the behavior is different. Signed-off-by: Anthony PERARD --- configure | 29 ++++++++++++++++++++++++++++- hw/xen_interfaces.c | 31 +++++++++++++++++++++++++++++++ hw/xen_interfaces.h | 5 +++++ hw/xen_redirect.h | 1 + 4 files changed, 65 insertions(+), 1 deletions(-) diff --git a/configure b/configure index f3c524e..642d344 100755 --- a/configure +++ b/configure @@ -1154,6 +1154,7 @@ 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_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); xc_gnttab_open(xc); return 0; } @@ -1173,10 +1174,14 @@ EOF # 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 @@ -1185,7 +1190,29 @@ EOF xen_ctrl_version=400 xen=yes - # Xen 3.3.0, 3.4.0 + # 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 < diff --git a/hw/xen_interfaces.c b/hw/xen_interfaces.c index 129e8b2..4d9862b 100644 --- a/hw/xen_interfaces.c +++ b/hw/xen_interfaces.c @@ -124,6 +124,20 @@ static void *map_foreign_batch(int xc_handle, uint32_t dom, int prot, return xc_map_foreign_batch(xc_handle, dom, prot, (xen_pfn_t*)arr, num); } +static int domain_add_to_physmap(qemu_xc_interface 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); +} + struct XenIfOps xc_xen = { .interface_open = interface_open, .interface_close = xc_interface_close, @@ -131,6 +145,7 @@ struct XenIfOps xc_xen = { .map_foreign_pages = xc_map_foreign_pages, .map_foreign_bulk = map_foreign_batch, .domain_populate_physmap_exact = xc_domain_memory_populate_physmap, + .domain_add_to_physmap = domain_add_to_physmap, }; # elif CONFIG_XEN_CTRL_INTERFACE_VERSION < 410 @@ -141,6 +156,20 @@ static qemu_xc_interface interface_open(xentoollog_logger *logger, return xc_interface_open(); } +static int domain_add_to_physmap(qemu_xc_interface 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); +} + struct XenIfOps xc_xen = { .interface_open = interface_open, .interface_close = xc_interface_close, @@ -148,6 +177,7 @@ struct XenIfOps xc_xen = { .map_foreign_pages = xc_map_foreign_pages, .map_foreign_bulk = xc_map_foreign_bulk, .domain_populate_physmap_exact = xc_domain_memory_populate_physmap, + .domain_add_to_physmap = domain_add_to_physmap, }; # else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 410 */ @@ -158,6 +188,7 @@ struct XenIfOps xc_xen = { .map_foreign_pages = xc_map_foreign_pages, .map_foreign_bulk = xc_map_foreign_bulk, .domain_populate_physmap_exact = xc_domain_populate_physmap_exact, + .domain_add_to_physmap = xc_domain_add_to_physmap, }; # endif diff --git a/hw/xen_interfaces.h b/hw/xen_interfaces.h index 0f698dc..be38345 100644 --- a/hw/xen_interfaces.h +++ b/hw/xen_interfaces.h @@ -108,6 +108,11 @@ struct XenIfOps { unsigned int extent_order, unsigned int mem_flags, xen_pfn_t *extent_start); + int (*domain_add_to_physmap)(qemu_xc_interface xc_handle, + uint32_t domid, + unsigned int space, + unsigned long idx, + xen_pfn_t gpfn); }; extern struct XenIfOps xc; diff --git a/hw/xen_redirect.h b/hw/xen_redirect.h index 7cd6492..1b7c603 100644 --- a/hw/xen_redirect.h +++ b/hw/xen_redirect.h @@ -30,6 +30,7 @@ #define xc_map_foreign_bulk xc.map_foreign_bulk #define xc_domain_populate_physmap_exact \ xc.domain_populate_physmap_exact +#define xc_domain_add_to_physmap xc.domain_add_to_physmap /* xenstore interface */ #define xs_daemon_open xs.daemon_open