Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Kiper <daniel.kiper@oracle.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: elena.ufimtseva@oracle.com, xen-devel@lists.xenproject.org,
	kexec@lists.infradead.org, david.vrabel@citrix.com
Subject: Re: [PATCH v1 1/2] xen/kexec: Find out whether an kexec type is loaded.
Date: Tue, 15 Nov 2016 10:36:12 +0100	[thread overview]
Message-ID: <20161115093612.GA17718@olila.local.net-space.pl> (raw)
In-Reply-To: <1479161573-12671-2-git-send-email-konrad.wilk@oracle.com>

On Mon, Nov 14, 2016 at 05:12:52PM -0500, Konrad Rzeszutek Wilk wrote:
> The tools that use kexec are asynchronous in nature and do
> not keep state changes. As such provide an hypercall to find
> out whether an image has been loaded for either type.
>
> Note: No need to modify XSM as it has one size fits all
> check and does not check for subcommands.
>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
> v0: Internal version.
> v1: Dropped Reviewed-by, posting on xen-devel.
>
> CC: Elena Ufimtseva <elena.ufimtseva@oracle.com>
> CC: Daniel Kiper <daniel.kiper@oracle.com>
> ---
>  tools/libxc/include/xenctrl.h |  8 ++++++++
>  tools/libxc/xc_kexec.c        | 27 +++++++++++++++++++++++++++
>  xen/common/kexec.c            | 25 +++++++++++++++++++++++++
>  xen/include/public/kexec.h    | 11 +++++++++++
>  4 files changed, 71 insertions(+)
>
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index 2c83544..aa5d798 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
> @@ -2574,6 +2574,14 @@ int xc_kexec_load(xc_interface *xch, uint8_t type, uint16_t arch,
>   */
>  int xc_kexec_unload(xc_interface *xch, int type);
>
> +/*
> + * Find out whether the image has been succesfully loaded.
> + *
> + * The can be either KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH.
> + * If zero is returned that means the image is loaded for the type.
> + */
> +int xc_kexec_status(xc_interface *xch, int type);
> +
>  typedef xenpf_resource_entry_t xc_resource_entry_t;
>
>  /*
> diff --git a/tools/libxc/xc_kexec.c b/tools/libxc/xc_kexec.c
> index 1cceb5d..95d36ff 100644
> --- a/tools/libxc/xc_kexec.c
> +++ b/tools/libxc/xc_kexec.c
> @@ -126,3 +126,30 @@ out:
>
>      return ret;
>  }
> +
> +int xc_kexec_status(xc_interface *xch, int type)
> +{
> +    DECLARE_HYPERCALL;
> +    DECLARE_HYPERCALL_BUFFER(xen_kexec_status_t, status);
> +    int ret = -1;
> +
> +    status = xc_hypercall_buffer_alloc(xch, status, sizeof(*status));
> +    if ( status == NULL )
> +    {
> +        PERROR("Count not alloc buffer for kexec status hypercall");

Could not? It looks that you copied this from existing code. Could you
send separate patch fixing this issue in two other places too?

> +        goto out;
> +    }
> +
> +    status->type = type;
> +
> +    hypercall.op = __HYPERVISOR_kexec_op;
> +    hypercall.arg[0] = KEXEC_CMD_kexec_status;
> +    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(status);
> +
> +    ret = do_xen_hypercall(xch, &hypercall);
> +
> +out:
> +    xc_hypercall_buffer_free(xch, status);
> +
> +    return ret;
> +}
> diff --git a/xen/common/kexec.c b/xen/common/kexec.c
> index c83d48f..1148f85 100644
> --- a/xen/common/kexec.c
> +++ b/xen/common/kexec.c
> @@ -1169,6 +1169,28 @@ static int kexec_unload(XEN_GUEST_HANDLE_PARAM(void) uarg)
>      return kexec_do_unload(&unload);
>  }
>
> +static int kexec_status(XEN_GUEST_HANDLE_PARAM(void) uarg)
> +{
> +    xen_kexec_status_t status;
> +    int base, bit, pos;
> +
> +    if ( unlikely(copy_from_guest(&status, uarg, 1)) )
> +        return -EFAULT;
> +
> +    if ( test_bit(KEXEC_FLAG_IN_PROGRESS, &kexec_flags) )
> +        return -EBUSY;
> +
> +    if ( kexec_load_get_bits(status.type, &base, &bit) )
> +        return -EINVAL;
> +
> +    pos = (test_bit(bit, &kexec_flags) != 0);
> +
> +    if ( !test_bit(base + pos, &kexec_flags) )
> +        return -ENOENT;
> +
> +    return 0;
> +}
> +
>  static int do_kexec_op_internal(unsigned long op,
>                                  XEN_GUEST_HANDLE_PARAM(void) uarg,
>                                  bool_t compat)
> @@ -1208,6 +1230,9 @@ static int do_kexec_op_internal(unsigned long op,
>      case KEXEC_CMD_kexec_unload:
>          ret = kexec_unload(uarg);
>          break;
> +    case KEXEC_CMD_kexec_status:
> +	ret = kexec_status(uarg);
> +	break;
>      }
>
>      return ret;
> diff --git a/xen/include/public/kexec.h b/xen/include/public/kexec.h
> index a6a0a88..29dcb5d 100644
> --- a/xen/include/public/kexec.h
> +++ b/xen/include/public/kexec.h
> @@ -227,6 +227,17 @@ typedef struct xen_kexec_unload {
>  } xen_kexec_unload_t;
>  DEFINE_XEN_GUEST_HANDLE(xen_kexec_unload_t);
>
> +/*
> + * Figure out whether we have an image loaded. An return value of
> + * zero indicates success while XEN_ENODEV implies no image loaded.

It seems to me that you thought about -ENOENT instead of XEN_ENODEV.

If you fix both things then Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2016-11-15  9:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 22:12 [PATCH v1] Add in kexec -S for status, and add new Xen hypercall to support this Konrad Rzeszutek Wilk
2016-11-14 22:12 ` [PATCH v1 1/2] xen/kexec: Find out whether an kexec type is loaded Konrad Rzeszutek Wilk
2016-11-15  9:36   ` Daniel Kiper [this message]
2016-11-15 10:51   ` David Vrabel
2016-11-14 22:12 ` [PATCH v1 2/2] kexec: Support -S paramter to return whether the kexec payload " Konrad Rzeszutek Wilk
2016-11-15  4:44   ` Pratyush Anand
2016-11-16 12:50   ` Simon Horman
2016-11-15  4:48 ` [PATCH v1] Add in kexec -S for status, and add new Xen hypercall to support this Pratyush Anand

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=20161115093612.GA17718@olila.local.net-space.pl \
    --to=daniel.kiper@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=elena.ufimtseva@oracle.com \
    --cc=kexec@lists.infradead.org \
    --cc=konrad.wilk@oracle.com \
    --cc=xen-devel@lists.xenproject.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