From: Don Slutz <Don@CloudSwitch.com>
To: David Vrabel <david.vrabel@citrix.com>
Cc: Daniel Kiper <daniel.kiper@oracle.com>,
kexec@lists.infradead.org, xen-devel@lists.xen.org
Subject: Re: [Xen-devel] [PATCH 3/4] kexec/xen: use libxc to get location of crash notes
Date: Tue, 26 Feb 2013 08:53:52 -0500 [thread overview]
Message-ID: <512CBE70.2000902@CloudSwitch.com> (raw)
In-Reply-To: <1361469460-18771-4-git-send-email-david.vrabel@citrix.com>
On 02/21/13 12:57, David Vrabel wrote:
> 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>
> ---
> kexec/crashdump-xen.c | 61 ++++++++++++++++++++++++++++---------------------
> 1 files changed, 35 insertions(+), 26 deletions(-)
>
> diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
> index ff4706c..13335a5 100644
> --- a/kexec/crashdump-xen.c
> +++ b/kexec/crashdump-xen.c
> @@ -163,42 +163,51 @@ 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 cpu;
>
> 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");
> + xc = xc_interface_open(NULL, NULL, 0);
> + if ( !xc ) {
> + fprintf(stderr, "failed to open xen control interface.\n");
> + return -1;
> + }
> +
> + for (cpu = 0;; cpu++) {
This code does work. Not sure why you did not use xc_physinfo() to get
the number of cpus that there is data for and remove the need for
calling realloc.
> + 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 = realloc(xen_phys_notes,
> + sizeof(*xen_phys_notes) * (cpu + 1));
> + if (xen_phys_notes == NULL)
> return -1;
> - }
> - memset(xen_phys_notes, 0, n);
> - kexec_iomem_for_each_line(match,
> - xen_crash_note_callback, NULL);
> - xen_phys_cpus = cpus;
> +
> + xen_phys_notes[cpu].base = start;
> + xen_phys_notes[cpu].length = size;
> }
>
> - return cpus;
> + xc_interface_close(xc);
> +
> + xen_phys_cpus = cpu;
> +
> + 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)
> {
-Don Slutz
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2013-02-26 13:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
2013-02-21 17:57 ` [PATCH 1/4] purgatory: put variables altered by kexec in .data not .bss David Vrabel
2013-02-21 17:57 ` David Vrabel
2013-02-21 17:57 ` [PATCH 2/4] kexec/xen: require libxc from Xen 4.3 David Vrabel
2013-02-21 17:57 ` David Vrabel
2013-02-21 17:57 ` [PATCH 3/4] kexec/xen: use libxc to get location of crash notes David Vrabel
2013-02-21 17:57 ` David Vrabel
2013-02-26 13:53 ` Don Slutz
2013-02-26 13:53 ` Don Slutz [this message]
2013-02-21 17:57 ` [PATCH 4/4] kexec/xen: directly load images images into Xen David Vrabel
2013-03-12 11:29 ` Daniel Kiper
2013-03-12 11:29 ` Daniel Kiper
2013-02-21 17:57 ` David Vrabel
2013-02-22 8:14 ` [PATCH 0/4] kexec-tools: add support for Xen 4.3 Jan Beulich
2013-02-22 8:14 ` [Xen-devel] " Jan Beulich
2013-02-22 11:39 ` David Vrabel
2013-02-22 11:39 ` David Vrabel
2013-02-25 18:34 ` Don Slutz
2013-02-25 18:34 ` [Xen-devel] " Don Slutz
2013-02-25 19:34 ` David Vrabel
2013-02-25 19:34 ` David Vrabel
2013-03-08 10:30 ` Daniel Kiper
2013-03-08 10:30 ` Daniel Kiper
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=512CBE70.2000902@CloudSwitch.com \
--to=don@cloudswitch.com \
--cc=daniel.kiper@oracle.com \
--cc=david.vrabel@citrix.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.