xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: xen-devel@lists.xen.org
Cc: Daniel Kiper <daniel.kiper@oracle.com>,
	Simon Horman <horms@verge.net.au>,
	kexec@lists.infradead.org, David Vrabel <david.vrabel@citrix.com>
Subject: [PATCH 1/4] kexec/xen: require libxc from Xen 4.4
Date: Wed, 6 Nov 2013 14:55:19 +0000	[thread overview]
Message-ID: <1383749722-12091-2-git-send-email-david.vrabel@citrix.com> (raw)
In-Reply-To: <1383749722-12091-1-git-send-email-david.vrabel@citrix.com>

From: David Vrabel <david.vrabel@citrix.com>

libxc from Xen 4.4 added xc_kexec_load() which will be required to
load images into Xen in the future.

Remove all the #ifdef'ery for older versions of libxc.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 configure.ac                       |    5 +-
 kexec/arch/i386/crashdump-x86.c    |  110 ------------------------------------
 kexec/arch/i386/kexec-x86-common.c |  103 ---------------------------------
 kexec/crashdump-xen.c              |   12 ----
 4 files changed, 1 insertions(+), 229 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7b61dbf..50b706a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,11 +161,8 @@ fi
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then
 	AC_CHECK_HEADER(xenctrl.h,
-		AC_CHECK_LIB(xenctrl, xc_version, ,
+		AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
 		AC_MSG_NOTICE([Xen support disabled])))
-	if test "$ac_cv_lib_xenctrl_xc_version" = yes ; then
-		AC_CHECK_FUNCS(xc_get_machine_memory_map)
-	fi
 fi
 
 dnl ---Sanity checks
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index e44fceb..7aa5a12 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -43,14 +43,7 @@
 #include "crashdump-x86.h"
 
 #ifdef HAVE_LIBXENCTRL
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 #include <xenctrl.h>
-#else
-#define __XEN_TOOLS__	1
-#include <xen/xen.h>
-#include <xen/memory.h>
-#include <xen/sys/privcmd.h>
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
 #endif /* HAVE_LIBXENCTRL */
 
 #include <x86/x86-linux.h>
@@ -300,34 +293,20 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 }
 
 #ifdef HAVE_LIBXENCTRL
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 static int get_crash_memory_ranges_xen(struct memory_range **range,
 					int *ranges, unsigned long lowmem_limit)
 {
 	int j, rc, ret = -1;
 	struct e820entry e820entries[CRASH_MAX_MEMORY_RANGES];
 	unsigned int i;
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc_interface *xc;
-#else
-	int xc;
-#endif
 
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc = xc_interface_open(NULL, NULL, 0);
 
 	if (!xc) {
 		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
 		goto err;
 	}
-#else
-	xc = xc_interface_open();
-
-	if (xc == -1) {
-		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
-		goto err;
-	}
-#endif
 
 	rc = xc_get_machine_memory_map(xc, e820entries, CRASH_MAX_MEMORY_RANGES);
 
@@ -364,95 +343,6 @@ err:
 static int get_crash_memory_ranges_xen(struct memory_range **range,
 					int *ranges, unsigned long lowmem_limit)
 {
-	int fd, j, rc, ret = -1;
-	privcmd_hypercall_t hypercall;
-	struct e820entry *e820entries = NULL;
-	struct xen_memory_map *xen_memory_map = NULL;
-	unsigned int i;
-
-	fd = open("/proc/xen/privcmd", O_RDWR);
-
-	if (fd == -1) {
-		fprintf(stderr, "%s: open(/proc/xen/privcmd): %m\n", __func__);
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&e820entries, getpagesize(),
-			    sizeof(struct e820entry) * CRASH_MAX_MEMORY_RANGES);
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(e820entries): %s\n", __func__, strerror(rc));
-		e820entries = NULL;
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&xen_memory_map, getpagesize(),
-			    sizeof(struct xen_memory_map));
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(xen_memory_map): %s\n", __func__, strerror(rc));
-		xen_memory_map = NULL;
-		goto err;
-	}
-
-	if (mlock(e820entries, sizeof(struct e820entry) * CRASH_MAX_MEMORY_RANGES) == -1) {
-		fprintf(stderr, "%s: mlock(e820entries): %m\n", __func__);
-		goto err;
-	}
-
-	if (mlock(xen_memory_map, sizeof(struct xen_memory_map)) == -1) {
-		fprintf(stderr, "%s: mlock(xen_memory_map): %m\n", __func__);
-		goto err;
-	}
-
-	xen_memory_map->nr_entries = CRASH_MAX_MEMORY_RANGES;
-	set_xen_guest_handle(xen_memory_map->buffer, e820entries);
-
-	hypercall.op = __HYPERVISOR_memory_op;
-	hypercall.arg[0] = XENMEM_machine_memory_map;
-	hypercall.arg[1] = (__u64)xen_memory_map;
-
-	rc = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, &hypercall);
-
-	if (rc == -1) {
-		fprintf(stderr, "%s: ioctl(IOCTL_PRIVCMD_HYPERCALL): %m\n", __func__);
-		goto err;
-	}
-
-	for (i = 0, j = 0; i < xen_memory_map->nr_entries &&
-				j < CRASH_MAX_MEMORY_RANGES; ++i, ++j) {
-		crash_memory_range[j].start = e820entries[i].addr;
-		crash_memory_range[j].end = e820entries[i].addr + e820entries[i].size - 1;
-		crash_memory_range[j].type = xen_e820_to_kexec_type(e820entries[i].type);
-		segregate_lowmem_region(&j, lowmem_limit);
-	}
-
-	*range = crash_memory_range;
-	*ranges = j;
-
-	qsort(*range, *ranges, sizeof(struct memory_range), compare_ranges);
-
-	for (i = 0; i < crash_reserved_mem_nr; i++)
-		if (exclude_region(ranges, crash_reserved_mem[i].start,
-						crash_reserved_mem[i].end) < 0)
-			goto err;
-
-	ret = 0;
-
-err:
-	munlock(xen_memory_map, sizeof(struct xen_memory_map));
-	munlock(e820entries, sizeof(struct e820entry) * CRASH_MAX_MEMORY_RANGES);
-	free(xen_memory_map);
-	free(e820entries);
-	close(fd);
-
-	return ret;
-}
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
-#else
-static int get_crash_memory_ranges_xen(struct memory_range **range,
-					int *ranges, unsigned long lowmem_limit)
-{
 	return 0;
 }
 #endif /* HAVE_LIBXENCTRL */
diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c
index ed6c950..bf58f53 100644
--- a/kexec/arch/i386/kexec-x86-common.c
+++ b/kexec/arch/i386/kexec-x86-common.c
@@ -40,15 +40,7 @@
 #include "kexec-x86.h"
 
 #ifdef HAVE_LIBXENCTRL
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 #include <xenctrl.h>
-#else
-#define __XEN_TOOLS__	1
-#include <x86/x86-linux.h>
-#include <xen/xen.h>
-#include <xen/memory.h>
-#include <xen/sys/privcmd.h>
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
 #endif /* HAVE_LIBXENCTRL */
 
 static struct memory_range memory_range[MAX_MEMORY_RANGES];
@@ -173,33 +165,19 @@ unsigned xen_e820_to_kexec_type(uint32_t type)
  *
  * @return 0 on success, any other value on failure.
  */
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 static int get_memory_ranges_xen(struct memory_range **range, int *ranges)
 {
 	int rc, ret = -1;
 	struct e820entry e820entries[MAX_MEMORY_RANGES];
 	unsigned int i;
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc_interface *xc;
-#else
-	int xc;
-#endif
 
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc = xc_interface_open(NULL, NULL, 0);
 
 	if (!xc) {
 		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
 		goto err;
 	}
-#else
-	xc = xc_interface_open();
-
-	if (xc == -1) {
-		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
-		goto err;
-	}
-#endif
 
 	rc = xc_get_machine_memory_map(xc, e820entries, MAX_MEMORY_RANGES);
 
@@ -229,87 +207,6 @@ err:
 #else
 static int get_memory_ranges_xen(struct memory_range **range, int *ranges)
 {
-	int fd, rc, ret = -1;
-	privcmd_hypercall_t hypercall;
-	struct e820entry *e820entries = NULL;
-	struct xen_memory_map *xen_memory_map = NULL;
-	unsigned int i;
-
-	fd = open("/proc/xen/privcmd", O_RDWR);
-
-	if (fd == -1) {
-		fprintf(stderr, "%s: open(/proc/xen/privcmd): %m\n", __func__);
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&e820entries, sysconf(_SC_PAGESIZE),
-			    sizeof(struct e820entry) * MAX_MEMORY_RANGES);
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(e820entries): %s\n", __func__, strerror(rc));
-		e820entries = NULL;
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&xen_memory_map, sysconf(_SC_PAGESIZE),
-			    sizeof(struct xen_memory_map));
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(xen_memory_map): %s\n", __func__, strerror(rc));
-		xen_memory_map = NULL;
-		goto err;
-	}
-
-	if (mlock(e820entries, sizeof(struct e820entry) * MAX_MEMORY_RANGES) == -1) {
-		fprintf(stderr, "%s: mlock(e820entries): %m\n", __func__);
-		goto err;
-	}
-
-	if (mlock(xen_memory_map, sizeof(struct xen_memory_map)) == -1) {
-		fprintf(stderr, "%s: mlock(xen_memory_map): %m\n", __func__);
-		goto err;
-	}
-
-	xen_memory_map->nr_entries = MAX_MEMORY_RANGES;
-	set_xen_guest_handle(xen_memory_map->buffer, e820entries);
-
-	hypercall.op = __HYPERVISOR_memory_op;
-	hypercall.arg[0] = XENMEM_machine_memory_map;
-	hypercall.arg[1] = (__u64)xen_memory_map;
-
-	rc = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, &hypercall);
-
-	if (rc == -1) {
-		fprintf(stderr, "%s: ioctl(IOCTL_PRIVCMD_HYPERCALL): %m\n", __func__);
-		goto err;
-	}
-
-	for (i = 0; i < xen_memory_map->nr_entries; ++i) {
-		memory_range[i].start = e820entries[i].addr;
-		memory_range[i].end = e820entries[i].addr + e820entries[i].size;
-		memory_range[i].type = xen_e820_to_kexec_type(e820entries[i].type);
-	}
-
-	qsort(memory_range, xen_memory_map->nr_entries, sizeof(struct memory_range), compare_ranges);
-
-	*range = memory_range;
-	*ranges = xen_memory_map->nr_entries;
-
-	ret = 0;
-
-err:
-	munlock(xen_memory_map, sizeof(struct xen_memory_map));
-	munlock(e820entries, sizeof(struct e820entry) * MAX_MEMORY_RANGES);
-	free(xen_memory_map);
-	free(e820entries);
-	close(fd);
-
-	return ret;
-}
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
-#else
-static int get_memory_ranges_xen(struct memory_range **range, int *ranges)
-{
 	return 0;
 }
 #endif /* HAVE_LIBXENCTRL */
diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index d8bd0f4..ff4706c 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -131,30 +131,18 @@ unsigned long xen_architecture(struct crash_elf_info *elf_info)
 #ifdef HAVE_LIBXENCTRL
 	int rc;
 	xen_capabilities_info_t capabilities;
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc_interface *xc;
-#else
-	int xc;
-#endif
 
 	if (!xen_present())
 		goto out;
 
 	memset(capabilities, '0', XEN_CAPABILITIES_INFO_LEN);
 
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc = xc_interface_open(NULL, NULL, 0);
 	if ( !xc ) {
 		fprintf(stderr, "failed to open xen control interface.\n");
 		goto out;
 	}
-#else
-	xc = xc_interface_open();
-	if ( xc == -1 ) {
-		fprintf(stderr, "failed to open xen control interface.\n");
-		goto out;
-	}
-#endif
 
 	rc = xc_version(xc, XENVER_capabilities, &capabilities[0]);
 	if ( rc == -1 ) {
-- 
1.7.2.5

  reply	other threads:[~2013-11-06 14:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-06 14:55 [PATCHv7 0/4] kexec-tools: add support for Xen 4.4 David Vrabel
2013-11-06 14:55 ` David Vrabel [this message]
2013-11-07 20:35   ` [PATCH 1/4] kexec/xen: require libxc from " Don Slutz
2013-11-06 14:55 ` [PATCH 2/4] kexec/xen: use libxc to get location of crash notes David Vrabel
2013-11-07 20:36   ` Don Slutz
2013-11-06 14:55 ` [PATCH 3/4] kexec/xen: switch to use xc_kexec_get_range for get_xen_vmcoreinfo David Vrabel
2013-11-06 14:55 ` [PATCH 4/4] kexec/xen: directly load images images into Xen David Vrabel
     [not found] ` <1383749722-12091-5-git-send-email-david.vrabel@citrix.com>
2013-11-07 20:36   ` Don Slutz
2013-11-19  1:20   ` Simon Horman
     [not found]   ` <20131119012014.GC17628@verge.net.au>
2013-11-19  8:28     ` Daniel Kiper
     [not found]     ` <20131119082827.GC30799@olila.local.net-space.pl>
2013-11-19  9:19       ` Simon Horman
2013-11-09 19:21 ` [PATCHv7 0/4] kexec-tools: add support for Xen 4.4 Daniel Kiper
     [not found] ` <20131109192143.GE3439@olila.local.net-space.pl>
2013-11-11 14:35   ` Don Slutz
2013-11-13 10:27 ` David Vrabel
     [not found] ` <52835429.8040708@citrix.com>
2013-11-19  1:15   ` Simon Horman
     [not found] <1381251574-30255-1-git-send-email-david.vrabel@citrix.com>
2013-10-08 16:59 ` [PATCH 1/4] kexec/xen: require libxc from " David Vrabel
     [not found] <1379683127-14349-1-git-send-email-david.vrabel@citrix.com>
2013-09-20 13:18 ` David Vrabel
  -- strict thread matches above, loose matches on Subject: below --
2013-09-20 13:16 [PATCHv5 0/4] kexec-tools: add support for " David Vrabel
2013-09-20 13:16 ` [PATCH 1/4] kexec/xen: require libxc from " David Vrabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1383749722-12091-2-git-send-email-david.vrabel@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=daniel.kiper@oracle.com \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).