All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@citrix.com>
To: Chunyan Liu <cyliu@suse.com>, ian.jackson@eu.citrix.com
Cc: wei.liu2@citrix.com, xen-devel@lists.xen.org
Subject: Re: [PATCH] fix restore: xenstore entries left when restore failed
Date: Wed, 19 Nov 2014 09:35:35 +0000	[thread overview]
Message-ID: <1416389735.29243.3.camel@citrix.com> (raw)
In-Reply-To: <1416381171-16772-1-git-send-email-cyliu@suse.com>

On Wed, 2014-11-19 at 15:12 +0800, Chunyan Liu wrote:
> While running libvirt-tck domain/102-broken-save-restore.t
> test (save domain, corrupt saved file by truncate the last 512k,
> then restore), found that restore domain failed, but domain
> related xenstore entries still exist in xenstore.
> 
> Add a patch to clear xenstore entries in this case.
> 
> Signed-off-by: Chunyan Liu <cyliu@suse.com>
> ---
>  tools/libxl/libxl.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
> 
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index de23fec..447840d 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -1525,6 +1525,54 @@ static void devices_destroy_cb(libxl__egc *egc,
>                                 libxl__devices_remove_state *drs,
>                                 int rc);
>  
> +static void libxl_clear_xs_entry(libxl__gc *gc, uint32_t domid)

This seems to duplicate a bunch of stuff already done by
libxl__destroy_domid and libxl__devices_destroy etc. I think rather than
duplicating this libxl__destroy_domid should be made to Do The Right
Thing by trying to clean up any remnants of the domid even if it doesn't
currently exist.

Alternatively perhaps the real bug is in the error path of the restore
functionality, which isn't calling the correct unwind path. Ian, any
thoughts?

Ian.

> +    const char *dom_path, *vm_path;
> +    char *path;
> +    unsigned int num_kinds, num_dev_xsentries;
> +    char **kinds = NULL, **devs = NULL;
> +    int i, j;
> +
> +    /* remove libxl path */
> +    libxl__xs_rm_checked(gc, XBT_NULL, libxl__xs_libxl_path(gc, domid));
> +
> +    dom_path = libxl__xs_get_dompath(gc, domid);
> +    if (!dom_path)
> +        return;
> +
> +    /* remove backend entries */
> +    path = GCSPRINTF("%s/device", dom_path);
> +    kinds = libxl__xs_directory(gc, XBT_NULL, path, &num_kinds);
> +    if (kinds && num_kinds) {
> +        for (i = 0; i < num_kinds; i++) {
> +            path = GCSPRINTF("%s/device/%s", dom_path, kinds[i]);
> +            devs = libxl__xs_directory(gc, XBT_NULL, path, &num_dev_xsentries);
> +            if (!devs)
> +                continue;
> +            for (j = 0; j < num_dev_xsentries; j++) {
> +                path = GCSPRINTF("%s/device/%s/%s/backend",
> +                                 dom_path, kinds[i], devs[j]);
> +                path = libxl__xs_read(gc, XBT_NULL, path);
> +                if (path)
> +                    libxl__xs_rm_checked(gc, XBT_NULL, path);
> +            }
> +        }
> +    }
> +
> +    path = GCSPRINTF("%s/console/backend", dom_path);
> +    path = libxl__xs_read(gc, XBT_NULL, path);
> +    if (path)
> +        libxl__xs_rm_checked(gc, XBT_NULL, path);
> +
> +    /* remove vm path */
> +    vm_path = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/vm", dom_path));
> +    if (vm_path)
> +        libxl__xs_rm_checked(gc, XBT_NULL, vm_path);
> +
> +    /* remove dom path */
> +    libxl__xs_rm_checked(gc, XBT_NULL, dom_path);
> +}
> +
>  void libxl__destroy_domid(libxl__egc *egc, libxl__destroy_domid_state *dis)
>  {
>      STATE_AO_GC(dis->ao);
> @@ -1540,6 +1588,10 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__destroy_domid_state *dis)
>          break;
>      case ERROR_INVAL:
>          LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "non-existant domain %d", domid);
> +        /* domain may not started successfully but some xenstore entries
> +         * might be created already in earlier stage. We need to clear
> +         * those entries. */
> +        libxl_clear_xs_entry(gc, domid);
>      default:
>          goto out;
>      }

      reply	other threads:[~2014-11-19  9:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-19  7:12 [PATCH] fix restore: xenstore entries left when restore failed Chunyan Liu
2014-11-19  9:35 ` Ian Campbell [this message]

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=1416389735.29243.3.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=cyliu@suse.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --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.