All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@citrix.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Wei Liu <wei.liu2@citrix.com>, Andrew Jones <drjones@redhat.com>,
	Julien Grall <julien.grall@linaro.org>,
	Keir Fraser <keir@xen.org>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Olaf Hering <olaf@aepfle.de>, Tim Deegan <tim@xen.org>,
	David Vrabel <david.vrabel@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v5 8/9] libxl: soft reset support
Date: Tue, 13 Jan 2015 14:21:07 +0000	[thread overview]
Message-ID: <1421158867.19103.83.camel@citrix.com> (raw)
In-Reply-To: <1418305541-5135-9-git-send-email-vkuznets@redhat.com>

On Thu, 2014-12-11 at 14:45 +0100, Vitaly Kuznetsov wrote:
> Supported for HVM guests only.

Is it specifically PVHVM guests, or are unaware HVM guests also
supported? (I think the answer is that an unaware HVM guest has no way
to trigger a soft reset, so maybe it's moot...)

> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> index 0a123f1..710dc0e 100644
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -929,6 +929,12 @@ int static inline libxl_domain_create_restore_0x040200(
>  
>  #endif
>  
> +int libxl_domain_soft_reset(libxl_ctx *ctx, libxl_domain_config *d_config,
> +                            uint32_t *domid, uint32_t domid_old,
> +                            const libxl_asyncop_how *ao_how,
> +                            const libxl_asyncprogress_how *aop_console_how)
> +                            LIBXL_EXTERNAL_CALLERS_ONLY;
> +
>    /* A progress report will be made via ao_console_how, of type
>     * domain_create_console_available, when the domain's primary
>     * console is available and can be connected to.
> diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> index 1198225..0a840c9 100644
> --- a/tools/libxl/libxl_create.c
> +++ b/tools/libxl/libxl_create.c
> @@ -25,6 +25,8 @@
>  #include <xen/hvm/hvm_info_table.h>
>  #include <xen/hvm/e820.h>
>  
> +#define INVALID_DOMID ~0

Is this completely internal to this file, or are you requiring that it
matches the one in xl_cmdimpl.c (i.e does it cross the library
interface)?

> +
> +void libxl__xc_domain_soft_reset(libxl__egc *egc,
> +                                 libxl__domain_create_state *dcs)
> +{
> +    STATE_AO_GC(dcs->ao);
> +    libxl_ctx *ctx = libxl__gc_owner(gc);
> +    const uint32_t domid_soft_reset = dcs->domid_soft_reset;
> +    const uint32_t domid = dcs->guest_domid;
> +    libxl_domain_config *const d_config = dcs->guest_config;
> +    libxl_domain_build_info *const info = &d_config->b_info;
> +    uint8_t *buf;
> +    uint32_t len;
> +    uint32_t console_domid, store_domid;
> +    unsigned long store_mfn, console_mfn;
> +    int rc;
> +    struct libxl__domain_suspend_state *dss;
> +
> +    GCNEW(dss);
> +
> +    dss->ao = ao;
> +    dss->domid = domid_soft_reset;
> +    dss->dm_savefile = GCSPRINTF("/var/lib/xen/qemu-save.%d",
> +                                 domid_soft_reset);
> +
> +    if (info->type == LIBXL_DOMAIN_TYPE_HVM) {

I thought the alternative  (PV) wasn't possible?

> +        rc = libxl__domain_suspend_device_model(gc, dss);
> +        if (rc) goto out;
> +    }
> +
> +    console_domid = dcs->build_state.console_domid;
> +    store_domid = dcs->build_state.store_domid;
[...]
> +    rc = xc_domain_soft_reset(ctx->xch, domid_soft_reset, domid, console_domid,
> +                              &console_mfn, store_domid, &store_mfn);
> +    if (rc) goto out;
[..]
> +    dcs->build_state.store_mfn = store_mfn;
> +    dcs->build_state.console_mfn = console_mfn;

Are you trying to avoid passing &dcs->build_state.store_mfn to the xc
function directly for some reason?

> +
> +    rc = libxl__toolstack_save(domid_soft_reset, &buf, &len, dss);
> +    if (rc) goto out;
> +
> +    rc = libxl__toolstack_restore(domid, buf, len, &dcs->shs);
> +    if (rc) goto out;
> +out:
> +    /*
> +     * Now pretend we did normal restore and simply call
> +     * libxl__xc_domain_restore_done().
> +     */
> +    libxl__xc_domain_restore_done(egc, dcs, rc, 0, 0);
> +}
> +
>  void libxl__srm_callout_callback_restore_results(unsigned long store_mfn,
>            unsigned long console_mfn, void *user)
>  {
> diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> index 4a0e2be..10ef652 100644
> --- a/tools/libxl/libxl_types.idl
> +++ b/tools/libxl/libxl_types.idl
> @@ -121,6 +121,8 @@ libxl_action_on_shutdown = Enumeration("action_on_shutdown", [
>  
>      (5, "COREDUMP_DESTROY"),
>      (6, "COREDUMP_RESTART"),
> +
> +    (7, "SOFT_RESET"),

I think I mention a LIBXL_HAVE #define earlier on, since they are all
related I think you can have a single one for the overall feature rather
than ones for each new enum value. function etc. Probably
LIBXL_HAVE_DOMAIN_SOFT_RESET fits best?

> @@ -2519,7 +2538,17 @@ start:
>           * restore/migrate-receive it again.
>           */
>          restoring = 0;
> -    }else{
> +    } else if (domid_old != INVALID_DOMID) {
> +        /* Do soft reset */
> +        ret = libxl_domain_soft_reset(ctx, &d_config,
> +                                      &domid, domid_old,
> +                                      0, 0);
> +
> +        if ( ret ) {
> +            goto error_out;
> +        }
> +        domid_old = INVALID_DOMID;
> +    } else {
>          ret = libxl_domain_create_new(ctx, &d_config, &domid,
>                                        0, autoconnect_console_how);
>      }
> @@ -2583,6 +2612,8 @@ start:
>                  event->u.domain_shutdown.shutdown_reason,
>                  event->u.domain_shutdown.shutdown_reason);
>              switch (handle_domain_death(&domid, event, &d_config)) {
> +            case 3:
> +                domid_old = domid;

Please comment when falling through is deliberate.

I think we've now passed the point where the raw numbers are tolerable
any more, please could you convert to an enum and then add the new
value.

>              case 2:
>                  if (!preserve_domain(&domid, event, &d_config)) {
>                      /* If we fail then exit leaving the old domain in place. */

Ian.

  reply	other threads:[~2015-01-13 14:21 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-11 13:45 [PATCH v5 0/9] toolstack-based approach to pvhvm guest kexec Vitaly Kuznetsov
2014-12-11 13:45 ` [PATCH v5 1/9] xen: introduce DOMDYING_locked state Vitaly Kuznetsov
2014-12-18 13:23   ` Jan Beulich
2014-12-11 13:45 ` [PATCH v5 2/9] xen: introduce SHUTDOWN_soft_reset shutdown reason Vitaly Kuznetsov
2014-12-18 13:28   ` Jan Beulich
2015-01-13 12:20   ` Ian Campbell
2014-12-11 13:45 ` [PATCH v5 3/9] libxl: support " Vitaly Kuznetsov
2015-01-13 12:22   ` Ian Campbell
2015-01-13 12:23   ` Ian Campbell
2014-12-11 13:45 ` [PATCH v5 4/9] xen: introduce XEN_DOMCTL_devour Vitaly Kuznetsov
2014-12-18 13:57   ` Jan Beulich
2015-01-13 12:26     ` Ian Campbell
2015-01-13 13:53   ` Ian Campbell
2015-01-13 14:48     ` Tim Deegan
2015-01-13 16:17     ` Vitaly Kuznetsov
2015-01-13 16:24       ` Jan Beulich
2015-01-13 16:45         ` Vitaly Kuznetsov
2015-01-13 16:56           ` Jan Beulich
2015-01-13 16:41       ` Ian Campbell
2014-12-11 13:45 ` [PATCH v5 5/9] libxc: support XEN_DOMCTL_devour Vitaly Kuznetsov
2014-12-11 13:45 ` [PATCH v5 6/9] libxl: add libxl__domain_soft_reset_destroy() Vitaly Kuznetsov
2015-01-13 13:58   ` Ian Campbell
2014-12-11 13:45 ` [PATCH v5 7/9] libxc: introduce soft reset for HVM domains Vitaly Kuznetsov
2015-01-13 14:08   ` Ian Campbell
2014-12-11 13:45 ` [PATCH v5 8/9] libxl: soft reset support Vitaly Kuznetsov
2015-01-13 14:21   ` Ian Campbell [this message]
2014-12-11 13:45 ` [PATCH v5 9/9] xsm: add XEN_DOMCTL_devour support Vitaly Kuznetsov
2014-12-18 13:59   ` Jan Beulich
2015-01-05 12:46 ` [PATCH v5 0/9] toolstack-based approach to pvhvm guest kexec Wei Liu
2015-01-05 13:00   ` Vitaly Kuznetsov
2015-01-07  9:10     ` Olaf Hering
2015-01-07 10:41       ` David Vrabel
2015-01-07 10:54         ` Jan Beulich
2015-01-07 11:59           ` Vitaly Kuznetsov
2015-01-07 11:01         ` Olaf Hering
2015-01-13 12:18         ` Ian Campbell
2015-01-07 10:49       ` Vitaly Kuznetsov
2015-01-07 11:03         ` Olaf Hering
2015-01-14 11:06           ` George Dunlap

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=1421158867.19103.83.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=david.vrabel@citrix.com \
    --cc=drjones@redhat.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@linaro.org \
    --cc=keir@xen.org \
    --cc=olaf@aepfle.de \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=vkuznets@redhat.com \
    --cc=wei.liu2@citrix.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 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.