From: Tim Deegan Subject: [PATCH v2] tools/xen-access: don't use libxc internals directly. Date: Wed, 19 Mar 2014 11:35:35 +0100 Message-ID: <20140319103535.GA76025@deinos.phlegethon.org> References: <97A500D504438F4ABC02EBA81613CC63317CB3F2@xmb-aln-x02.cisco.com> <20140318101332.GA85408@deinos.phlegethon.org> <97A500D504438F4ABC02EBA81613CC63317CD8DC@xmb-aln-x02.cisco.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WQDqT-0002qx-Sf for xen-devel@lists.xenproject.org; Wed, 19 Mar 2014 10:35:38 +0000 Content-Disposition: inline In-Reply-To: <97A500D504438F4ABC02EBA81613CC63317CD8DC@xmb-aln-x02.cisco.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "Aravindh Puthiyaparambil (aravindp)" Cc: xen-devel@lists.xenproject.org, Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Signed-off-by: Tim Deegan Acked-by: Ian Campbell Tested-by: Aravindh Puthiyaparambil --- v2: DPRINTF() doesn't need to add a newline. diff --git a/tools/tests/xen-access/xen-access.c b/tools/tests/xen-access/xen-access.c index b00c05a..f6522a1 100644 --- a/tools/tests/xen-access/xen-access.c +++ b/tools/tests/xen-access/xen-access.c @@ -26,23 +26,24 @@ * DEALINGS IN THE SOFTWARE. */ +#include #include #include #include #include +#include #include #include #include +#include #include -#include -#include +#include #include -//#if 0 -#undef DPRINTF #define DPRINTF(a, b...) fprintf(stderr, a, ## b) -//#endif +#define ERROR(a, b...) fprintf(stderr, a "\n", ## b) +#define PERROR(a, b...) fprintf(stderr, a ": %s\n", ## b, strerror(errno)) /* Spinlock and mem event definitions */ @@ -104,17 +105,9 @@ typedef struct mem_event { spinlock_t ring_lock; } mem_event_t; -typedef struct xc_platform_info { - unsigned long max_mfn; - unsigned long hvirt_start; - unsigned int pt_levels; - unsigned int guest_width; -} xc_platform_info_t; - typedef struct xenaccess { xc_interface *xc_handle; - xc_platform_info_t *platform_info; xc_domaininfo_t *domain_info; mem_event_t mem_event; @@ -178,7 +171,7 @@ int xenaccess_teardown(xc_interface *xch, xenaccess_t *xenaccess) /* Tear down domain xenaccess in Xen */ if ( xenaccess->mem_event.ring_page ) - munmap(xenaccess->mem_event.ring_page, PAGE_SIZE); + munmap(xenaccess->mem_event.ring_page, XC_PAGE_SIZE); if ( mem_access_enable ) { @@ -219,7 +212,6 @@ int xenaccess_teardown(xc_interface *xch, xenaccess_t *xenaccess) } xenaccess->xc_handle = NULL; - free(xenaccess->platform_info); free(xenaccess->domain_info); free(xenaccess); @@ -328,32 +320,13 @@ xenaccess_t *xenaccess_init(xc_interface **xch_r, domid_t domain_id) SHARED_RING_INIT((mem_event_sring_t *)xenaccess->mem_event.ring_page); BACK_RING_INIT(&xenaccess->mem_event.back_ring, (mem_event_sring_t *)xenaccess->mem_event.ring_page, - PAGE_SIZE); + XC_PAGE_SIZE); /* Now that the ring is set, remove it from the guest's physmap */ if ( xc_domain_decrease_reservation_exact(xch, xenaccess->mem_event.domain_id, 1, 0, &ring_pfn) ) PERROR("Failed to remove ring from guest physmap"); - /* Get platform info */ - xenaccess->platform_info = malloc(sizeof(xc_platform_info_t)); - if ( xenaccess->platform_info == NULL ) - { - ERROR("Error allocating memory for platform info"); - goto err; - } - - rc = get_platform_info(xenaccess->xc_handle, domain_id, - &xenaccess->platform_info->max_mfn, - &xenaccess->platform_info->hvirt_start, - &xenaccess->platform_info->pt_levels, - &xenaccess->platform_info->guest_width); - if ( rc != 1 ) - { - ERROR("Error getting platform info"); - goto err; - } - /* Get domaininfo */ xenaccess->domain_info = malloc(sizeof(xc_domaininfo_t)); if ( xenaccess->domain_info == NULL )