[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] Re: [PATCH] tools: add closure to xc_domain_save switch_qemu_logdirty callback
Brendan, forgot to CC you on this. Sorry for mangling your name below too. On Tue, 2010-10-12 at 17:05 +0100, Ian Campbell wrote: > # HG changeset patch > # User Ian Campbell <ian.campbell@xxxxxxxxxx> > # Date 1286899422 -3600 > # Node ID 92be1317280b14e63b381285cdf342dfae014e66 > # Parent 372959917c012db7d90aad0626a4af6b8f9b186f > tools: add closure to xc_domain_save switch_qemu_logdirty callback > > Also move the function into struct save_callbacks with the others. > > Use this in libxl to pass the save context to > libxl__domain_suspend_common_switch_qemu_logdirty allowing us to reuse > the parent's xenstore handle, gc context etc. > > Also add an apparently missing libxl__free_all to > libxl__domain_suspend_common. > > (Now that switch_qemu_logdirty takes a closure it's not clear if > checkpoint can be changed to use the callback rather than doing the > switch itself and implementing a nop callback, Branden?) > > Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> > --- > Change from v1: > Compile test from missed call to xc_domain_save in > tools/python/xen/lowlevel/checkpoint/libcheckpoint.c > > diff -r 372959917c01 -r 92be1317280b tools/libxc/xc_domain_save.c > --- a/tools/libxc/xc_domain_save.c Tue Oct 12 17:03:42 2010 +0100 > +++ b/tools/libxc/xc_domain_save.c Tue Oct 12 17:03:42 2010 +0100 > @@ -879,7 +879,7 @@ int xc_domain_save(xc_interface *xch, in > int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t > max_iters, > uint32_t max_factor, uint32_t flags, > struct save_callbacks* callbacks, > - int hvm, void (*switch_qemu_logdirty)(int, unsigned)) > + int hvm) > { > xc_dominfo_t info; > DECLARE_DOMCTL; > @@ -1015,7 +1015,7 @@ int xc_domain_save(xc_interface *xch, in > > /* Enable qemu-dm logging dirty pages to xen */ > if ( hvm ) > - switch_qemu_logdirty(dom, 1); > + callbacks->switch_qemu_logdirty(dom, 1, callbacks->data); > } > else > { > @@ -1876,7 +1876,7 @@ int xc_domain_save(xc_interface *xch, in > NULL, 0, NULL, 0, NULL) < 0 ) > DPRINTF("Warning - couldn't disable shadow mode"); > if ( hvm ) > - switch_qemu_logdirty(dom, 0); > + callbacks->switch_qemu_logdirty(dom, 0, callbacks->data); > } > > if ( live_shinfo ) > diff -r 372959917c01 -r 92be1317280b tools/libxc/xenguest.h > --- a/tools/libxc/xenguest.h Tue Oct 12 17:03:42 2010 +0100 > +++ b/tools/libxc/xenguest.h Tue Oct 12 17:03:42 2010 +0100 > @@ -40,6 +40,8 @@ struct save_callbacks { > * 1: take another checkpoint */ > int (*checkpoint)(void* data); > > + void (*switch_qemu_logdirty)(int domid, unsigned enable, void *data); /* > HVM only */ > + > /* to be provided as the first argument to each callback function */ > void* data; > }; > @@ -55,7 +57,7 @@ int xc_domain_save(xc_interface *xch, in > int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t > max_iters, > uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */, > struct save_callbacks* callbacks, > - int hvm, void (*switch_qemu_logdirty)(int, unsigned)); /* > HVM only */ > + int hvm); > > > /** > diff -r 372959917c01 -r 92be1317280b tools/libxl/libxl_dom.c > --- a/tools/libxl/libxl_dom.c Tue Oct 12 17:03:42 2010 +0100 > +++ b/tools/libxl/libxl_dom.c Tue Oct 12 17:03:42 2010 +0100 > @@ -325,21 +325,18 @@ struct suspendinfo { > unsigned int flags; > }; > > -static void libxl__domain_suspend_common_switch_qemu_logdirty(int domid, > unsigned int enable) > +static void libxl__domain_suspend_common_switch_qemu_logdirty(int domid, > unsigned int enable, void *data) > { > - struct xs_handle *xsh; > - char path[64]; > + struct suspendinfo *si = data; > + libxl_ctx *ctx = libxl__gc_owner(si->gc); > + char *path; > > - snprintf(path, sizeof(path), > "/local/domain/0/device-model/%u/logdirty/cmd", domid); > - > - xsh = xs_daemon_open(); > + path = libxl__sprintf(si->gc, > "/local/domain/0/device-model/%u/logdirty/cmd", domid); > > if (enable) > - xs_write(xsh, XBT_NULL, path, "enable", strlen("enable")); > + xs_write(ctx->xsh, XBT_NULL, path, "enable", strlen("enable")); > else > - xs_write(xsh, XBT_NULL, path, "disable", strlen("disable")); > - > - xs_daemon_close(xsh); > + xs_write(ctx->xsh, XBT_NULL, path, "disable", strlen("disable")); > } > > static int libxl__domain_suspend_common_callback(void *data) > @@ -437,11 +434,11 @@ int libxl__domain_suspend_common(libxl_c > > memset(&callbacks, 0, sizeof(callbacks)); > callbacks.suspend = libxl__domain_suspend_common_callback; > + callbacks.switch_qemu_logdirty = > libxl__domain_suspend_common_switch_qemu_logdirty; > callbacks.data = &si; > > xc_domain_save(ctx->xch, fd, domid, 0, 0, flags, > - &callbacks, hvm, > - &libxl__domain_suspend_common_switch_qemu_logdirty); > + &callbacks, hvm); > > if (si.suspend_eventchn > 0) > xc_suspend_evtchn_release(ctx->xch, si.xce, domid, > si.suspend_eventchn); > @@ -450,6 +447,7 @@ int libxl__domain_suspend_common(libxl_c > > rc = 0; > out: > + libxl__free_all(&gc); > return rc; > } > > diff -r 372959917c01 -r 92be1317280b > tools/python/xen/lowlevel/checkpoint/libcheckpoint.c > --- a/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c Tue Oct 12 > 17:03:42 2010 +0100 > +++ b/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c Tue Oct 12 > 17:03:42 2010 +0100 > @@ -164,7 +164,7 @@ void checkpoint_close(checkpoint_state* > > /* we toggle logdirty ourselves around the xc_domain_save call -- > * it avoids having to pass around checkpoint_state */ > -static void noop_switch_logdirty(int domid, unsigned enable) > +static void noop_switch_logdirty(int domid, unsigned enable, void *data) > { > return; > } > @@ -189,8 +189,9 @@ int checkpoint_start(checkpoint_state* s > return rc; > } > > - rc = xc_domain_save(s->xch, fd, s->domid, 0, 0, flags, callbacks, hvm, > - noop_switch_logdirty); > + callbacks->switch_qemu_logdirty = noop_switch_logdirty; > + > + rc = xc_domain_save(s->xch, fd, s->domid, 0, 0, flags, callbacks, hvm); > > if (hvm) > switch_qemu_logdirty(s, 0); > diff -r 372959917c01 -r 92be1317280b tools/xcutils/xc_save.c > --- a/tools/xcutils/xc_save.c Tue Oct 12 17:03:42 2010 +0100 > +++ b/tools/xcutils/xc_save.c Tue Oct 12 17:03:42 2010 +0100 > @@ -102,7 +102,7 @@ static int suspend(void* data) > * active buffer. */ > > > -static void switch_qemu_logdirty(int domid, unsigned int enable) > +static void switch_qemu_logdirty(int domid, unsigned int enable, void *data) > { > struct xs_handle *xs; > char *path, *p, *ret_str, *cmd_str, **watch; > @@ -205,9 +205,9 @@ main(int argc, char **argv) > } > memset(&callbacks, 0, sizeof(callbacks)); > callbacks.suspend = suspend; > + callbacks.switch_qemu_logdirty = switch_qemu_logdirty; > ret = xc_domain_save(si.xch, io_fd, si.domid, maxit, max_f, si.flags, > - &callbacks, !!(si.flags & XCFLAGS_HVM), > - &switch_qemu_logdirty); > + &callbacks, !!(si.flags & XCFLAGS_HVM)); > > if (si.suspend_evtchn > 0) > xc_suspend_evtchn_release(si.xch, si.xce, si.domid, si.suspend_evtchn); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |