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 2/4] kexec/xen: use libxc to get location of crash notes
Date: Wed, 6 Nov 2013 14:55:20 +0000	[thread overview]
Message-ID: <1383749722-12091-3-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>

Use xc_kexec_get_range(KEXEC_RANGE_MA_CPU) instead of parsing
/proc/iomem (which is only populated by non-upstream ("classic") Xen
kernels).

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 kexec/crashdump-xen.c |   67 +++++++++++++++++++++++++++++-------------------
 1 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index ff4706c..8185423 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -163,42 +163,55 @@ unsigned long xen_architecture(struct crash_elf_info *elf_info)
 	return machine;
 }
 
-static int xen_crash_note_callback(void *UNUSED(data), int nr,
-				   char *UNUSED(str),
-				   unsigned long base,
-				   unsigned long length)
-{
-	struct crash_note_info *note = xen_phys_notes + nr;
-
-	note->base = base;
-	note->length = length;
-
-	return 0;
-}
-
+#ifdef HAVE_LIBXENCTRL
 int xen_get_nr_phys_cpus(void)
 {
-	char *match = "Crash note\n";
-	int cpus, n;
+	xc_interface *xc;
+	int max_cpus;
+	int cpu = -1;
 
 	if (xen_phys_cpus)
 		return xen_phys_cpus;
 
-	if ((cpus = kexec_iomem_for_each_line(match, NULL, NULL))) {
-		n = sizeof(struct crash_note_info) * cpus;
-		xen_phys_notes = malloc(n);
-		if (!xen_phys_notes) {
-			fprintf(stderr, "failed to allocate xen_phys_notes.\n");
-			return -1;
-		}
-		memset(xen_phys_notes, 0, n);
-		kexec_iomem_for_each_line(match,
-					  xen_crash_note_callback, NULL);
-		xen_phys_cpus = cpus;
+	xc = xc_interface_open(NULL, NULL, 0);
+	if (!xc) {
+		fprintf(stderr, "failed to open xen control interface.\n");
+		return -1;
 	}
 
-	return cpus;
+	max_cpus = xc_get_max_cpus(xc);
+	if (max_cpus <= 0)
+		goto out;
+
+	xen_phys_notes = calloc(max_cpus, sizeof(*xen_phys_notes));
+	if (xen_phys_notes == NULL)
+		goto out;
+
+	for (cpu = 0; cpu < max_cpus; cpu++) {
+		uint64_t size, start;
+		int ret;
+
+		ret = xc_kexec_get_range(xc, KEXEC_RANGE_MA_CPU, cpu, &size, &start);
+		if (ret < 0)
+			break;
+
+		xen_phys_notes[cpu].base = start;
+		xen_phys_notes[cpu].length = size;
+	}
+
+	xen_phys_cpus = cpu;
+
+out:
+	xc_interface_close(xc);
+	return cpu;
 }
+#else
+int xen_get_nr_phys_cpus(void)
+{
+	return -1;
+}
+#endif
+
 
 int xen_get_note(int cpu, uint64_t *addr, uint64_t *len)
 {
-- 
1.7.2.5

  parent 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 ` [PATCH 1/4] kexec/xen: require libxc from " David Vrabel
2013-11-07 20:35   ` Don Slutz
2013-11-06 14:55 ` David Vrabel [this message]
2013-11-07 20:36   ` [PATCH 2/4] kexec/xen: use libxc to get location of crash notes 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 2/4] kexec/xen: use libxc to get location of crash notes 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 Xen 4.4 David Vrabel
2013-09-20 13:16 ` [PATCH 2/4] kexec/xen: use libxc to get location of crash notes 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-3-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).