From: Vincent Hanquez Subject: [PATCH 6/7] pass the suspend_context through function and allocate the context on the save function stack. Date: Tue, 1 Dec 2009 06:59:13 +0000 Message-ID: <1259650754-15971-7-git-send-email-vincent.hanquez@eu.citrix.com> References: <1259650754-15971-1-git-send-email-vincent.hanquez@eu.citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1.6.5.2" Return-path: In-Reply-To: <1259650754-15971-1-git-send-email-vincent.hanquez@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Xen Devel Cc: Vincent Hanquez List-Id: xen-devel@lists.xenproject.org --------------1.6.5.2 Content-Type: text/plain; charset="UTF-8"; format=fixed Content-Transfer-Encoding: quoted-printable Signed-off-by: Vincent Hanquez --- tools/libxc/xc_domain_save.c | 27 ++++++++++++++------------- 1 files changed, 14 insertions(+), 13 deletions(-) --------------1.6.5.2 Content-Type: text/x-patch; name="0006-pass-the-suspend_context-through-function-and-alloca.patch" Content-Disposition: attachment; filename="0006-pass-the-suspend_context-through-function-and-alloca.patch" Content-Transfer-Encoding: quoted-printable diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c index 6ea86e4..3f351ad 100644 --- a/tools/libxc/xc_domain_save.c +++ b/tools/libxc/xc_domain_save.c @@ -40,13 +40,6 @@ struct save_ctx { struct domain_info_context dinfo; }; =20 -static struct save_ctx _ctx =3D { - .live_p2m =3D NULL, - .live_m2p =3D NULL, -}; - -static struct save_ctx *ctx =3D &_ctx; - /* buffer for output */ struct outbuf { void* buf; @@ -396,7 +389,7 @@ static int print_stats(int xc_handle, uint32_t domid,= int pages_sent, } =20 =20 -static int analysis_phase(int xc_handle, uint32_t domid, +static int analysis_phase(int xc_handle, uint32_t domid, struct save_ctx= *ctx, unsigned long *arr, int runs) { long long start, now; @@ -454,6 +447,7 @@ static int suspend_and_state(int (*suspend)(void*), v= oid* data, ** it to update the MFN to a reasonable value. */ static void *map_frame_list_list(int xc_handle, uint32_t dom, + struct save_ctx *ctx, shared_info_any_t *shinfo) { int count =3D 100; @@ -489,7 +483,8 @@ static void *map_frame_list_list(int xc_handle, uint3= 2_t dom, ** which entries do not require canonicalization (in particular, those ** entries which map the virtual address reserved for the hypervisor). */ -static int canonicalize_pagetable(unsigned long type, unsigned long pfn, +static int canonicalize_pagetable(struct save_ctx *ctx, + unsigned long type, unsigned long pfn, const void *spage, void *dpage) { struct domain_info_context *dinfo =3D &ctx->dinfo; @@ -670,6 +665,7 @@ err0: static xen_pfn_t *map_and_save_p2m_table(int xc_handle,=20 int io_fd,=20 uint32_t dom, + struct save_ctx *ctx, shared_info_any_t *live_shinfo) { vcpu_guest_context_any_t ctxt; @@ -688,7 +684,7 @@ static xen_pfn_t *map_and_save_p2m_table(int xc_handl= e, =20 int i, success =3D 0; =20 - live_p2m_frame_list_list =3D map_frame_list_list(xc_handle, dom, + live_p2m_frame_list_list =3D map_frame_list_list(xc_handle, dom, ctx= , live_shinfo); if ( !live_p2m_frame_list_list ) goto out; @@ -912,6 +908,11 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_= t dom, uint32_t max_iters, unsigned long mfn; =20 struct outbuf ob; + static struct save_ctx _ctx =3D { + .live_p2m =3D NULL, + .live_m2p =3D NULL, + }; + static struct save_ctx *ctx =3D &_ctx; struct domain_info_context *dinfo =3D &ctx->dinfo; =20 int completed =3D 0; @@ -1043,7 +1044,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32= _t dom, uint32_t max_iters, } } =20 - analysis_phase(xc_handle, dom, to_skip, 0); + analysis_phase(xc_handle, dom, ctx, to_skip, 0); =20 pfn_type =3D xg_memalign(PAGE_SIZE, ROUNDUP( MAX_BATCH_SIZE * sizeof(*pfn_type), PAGE_S= HIFT)); @@ -1082,7 +1083,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32= _t dom, uint32_t max_iters, int err =3D 0; =20 /* Map the P2M table, and write the list of P2M frames */ - ctx->live_p2m =3D map_and_save_p2m_table(xc_handle, io_fd, dom, = live_shinfo); + ctx->live_p2m =3D map_and_save_p2m_table(xc_handle, io_fd, dom, = ctx, live_shinfo); if ( ctx->live_p2m =3D=3D NULL ) { ERROR("Failed to map/save the p2m frame list"); @@ -1376,7 +1377,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32= _t dom, uint32_t max_iters, { /* We have a pagetable page: need to rewrite it. */ race =3D=20 - canonicalize_pagetable(pagetype, pfn, spage, pag= e);=20 + canonicalize_pagetable(ctx, pagetype, pfn, spage= , page);=20 =20 if ( race && !live ) { --------------1.6.5.2 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------1.6.5.2--