Remus support for Migration-v2
v2 cover Remus support for Migration-v2
This patchset implement the Remus support for Migration v2 but without memory compressing.
The series can be found on github:
https://github.com/macrosheep/xen/tree/Remus-newmig-v2
PATCH 1-7: Some refactor and prepare work.
PATCH 8-9: The main Remus loop implement.
PATCH 10: Fix for Remus.
v2:
- move to_send bitmap to ctx->save union and rename it to dirty_bitmap
- introduce setup() and cleanup() on save
- rename send_some_pages to send_dirty_pages
- remove "defer the setting of HVM_PARAM_IDENT_PT", it should be fixed on hypervisor side
- the last patch still there for my test purpose until Andrew find a suitable solution(which we commented on the first series) :)
v1:
initial support
Summary of changes:
M = modified
A = acked
N = new,
no mark = unchanged from last round
Yang Hongyang (10):
M tools/libxc: adjust the memory allocation for migration N tools/libxc: introduce setup() and cleanup() on save N tools/libxc: rename send_some_pages to send_dirty_pages N tools/libxc: introduce DECLARE_HYPERCALL_BUFFER_USER_POINTER M tools/libxc: reuse send_dirty_pages() in send_all_pages()
tools/libxc: introduce process_record()
tools/libxc: split read/handle qemu info tools/libxc: implement Remus checkpointed save tools/libxc: implement Remus checkpointed restore tools/libxc: X86_PV_INFO can be sent multiple times under Remus
tools/libxc/include/xenctrl.h | 8 ++ tools/libxc/include/xenguest.h | 1 + tools/libxc/xc_bitops.h | 5 + tools/libxc/xc_sr_common.h | 15 +++ tools/libxc/xc_sr_restore.c | 179 ++++++++++++++++++++++----- tools/libxc/xc_sr_restore_x86_hvm.c | 28 ++++- tools/libxc/xc_sr_restore_x86_pv.c | 2 +- tools/libxc/xc_sr_save.c | 234 +++++++++++++++++++----------------- tools/libxl/libxl_dom.c | 1 + 9 files changed, 330 insertions(+), 143 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/10 tools/libxc: adjust the memory allocation for migration
Move the memory allocation before the concrete live/nolive save in order to avoid the free/alloc memory loop when using Remus. Rename the to_send bitmap to dirty_bitmap.
--- tools/libxc/xc_sr_common.h | 1 + tools/libxc/xc_sr_save.c | 68 ++++++++++++++++++++-------------------------- 2 files changed, 31 insertions(+), 38 deletions(-)
tools/libxc/xc_sr_common.h +1 -0
@@ -182,6 +182,7 @@ struct xc_sr_contextunsigned nr_batch_pfns;unsigned long *deferred_pages;unsigned long nr_deferred_pages; +xc_hypercall_buffer_t dirty_bitmap_hbuf; } save; struct /* Restore data. */
tools/libxc/xc_sr_save.c +30 -38
139 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH Remus v2 01/10] tools/libxc: adjust the memory allocation for migration
Quoted 14 lines · Yang Hongyang
tools/libxc/xc_sr_save.c +0
-6@@ -475,24 +475,12 @@ static int update_progress_string(struct xc_sr_context *ctx,static int send_domain_memory_live (struct xc_sr_context *ctx) {xc_interface *xch = ctx->xch; - DECLARE_HYPERCALL_BUFFER(unsigned long, to_send);xc_shadow_op_stats_t stats = {0 , ctx->save.p2m_size };char *progress_str =NULL ;unsigned x;int rc =-1 ; - - to_send =xc_hypercall_buffer_alloc_pages ( - xch, to_send,NRPAGES (bitmap_size (ctx->save.p2m_size))); - - ctx->save.batch_pfns = malloc(MAX_BATCH_SIZE *
tools/libxc/xc_sr_save.c static int update_progress_string(struct xc_sr_context *ctx, · line 483
Quoted 10 lines
tools/libxc/xc_sr_save.c +2
-8- sizeof(*ctx->save.batch_pfns)); - ctx->save.deferred_pages =calloc (1 ,bitmap_size (ctx->save.p2m_size)); - -if ( !ctx->save.batch_pfns || !to_send || !ctx->save.deferred_pages ) - { -ERROR ("Unable to allocate memory for to_{send,fix}/batch bitmaps" ); - goto out; - } + DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, + (&ctx->save.dirty_bitmap_hbuf));
Nice bug. I have just put a fix to DECLARE_HYPERCALL_BUFFER_SHADOW() in my series.
~Andrew
Re: [PATCH Remus v2 01/10] tools/libxc: adjust the memory allocation for migration
In reply to Yang HongyangQuoted 3 lines · Yang Hongyang
Move the memory allocation before the concrete live/nolive save in order to avoid the free/alloc memory loop when using Remus. Rename the
to_sendbitmap todirty_bitmap.
Doing the rename in a precursor patch would make the functional change much easier to see.
Re: [PATCH Remus v2 01/10] tools/libxc: adjust the memory allocation for migration
Quoted 7 lines · Ian Campbell
Quoted 3 lines · Yang Hongyang
Move the memory allocation before the concrete live/nolive save in order to avoid the free/alloc memory loop when using Remus. Rename the
to_sendbitmap todirty_bitmap.Doing the rename in a precursor patch would make the functional change much easier to see.
Thank you! I've split the rename patch!
Quoted 4 lines
.
Signature · 2 lines
Thanks, Yang.
PATCH v2 2/10 tools/libxc: introduce setup() and cleanup() on save
In reply to Yang Hongyangintroduce setup() and cleanup() which subsume the ctx->save.ops.{setup,cleanup}() calls and also do allocate/free necessary memory.
The SHADOW_OP_OFF hypercall also included in the cleanup().
--- tools/libxc/xc_sr_save.c | 72 +++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 28 deletions(-)
tools/libxc/xc_sr_save.c +44 -28
@@ -607,13 +607,10 @@ static int send_domain_memory_nonlive(struct xc_sr_context *ctx)return rc; } -/* -* Save a domain. -*/ -static int save (struct xc_sr_context *ctx,uint16_t guest_type) +static int setup (struct xc_sr_context *ctx) {xc_interface *xch = ctx->xch; -int rc, saved_rc =0 , saved_errno =0 ; +int rc; DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, (&ctx->save.dirty_bitmap_hbuf));
@@ -632,13 +629,51 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) goto err; } -IPRINTF ("Saving domain %d, type %s" , - ctx->domid,dhdr_type_to_str (guest_type)); - rc = ctx->save.ops.setup (ctx);if ( rc ) goto err; + rc =0 ; + + err: +return rc; + +} + +static void cleanup (struct xc_sr_context *ctx) +{ +xc_interface *xch = ctx->xch; + DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, + (&ctx->save.dirty_bitmap_hbuf)); + +xc_shadow_control (xch, ctx->domid,XEN_DOMCTL_SHADOW_OP_OFF , +NULL ,0 ,NULL ,0 ,NULL ); + +if ( ctx->save.ops.cleanup (ctx) ) +PERROR ("Failed to clean up" ); + +if ( dirty_bitmap ) +xc_hypercall_buffer_free_pages (xch, dirty_bitmap, +NRPAGES (bitmap_size (ctx->save.p2m_size))); +free (ctx->save.deferred_pages); +free (ctx->save.batch_pfns); +} + +/* +* Save a domain. +*/ +static int save (struct xc_sr_context *ctx,uint16_t guest_type) +{ +xc_interface *xch = ctx->xch; +int rc; + + rc =setup (ctx); +if ( rc ) + goto err; + +IPRINTF ("Saving domain %d, type %s" , + ctx->domid,dhdr_type_to_str (guest_type)); +xc_report_progress_single (xch,"Start of stream" ); rc =write_headers (ctx, guest_type);
@@ -679,29 +714,10 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) goto done; err: - saved_errno = errno; - saved_rc = rc;PERROR ("Save failed" ); done: -xc_shadow_control (xch, ctx->domid,XEN_DOMCTL_SHADOW_OP_OFF , -NULL ,0 ,NULL ,0 ,NULL ); - - rc = ctx->save.ops.cleanup (ctx); -if ( rc ) -PERROR ("Failed to clean up" ); - -xc_hypercall_buffer_free_pages (xch, dirty_bitmap, -NRPAGES (bitmap_size (ctx->save.p2m_size))); -free (ctx->save.deferred_pages); -free (ctx->save.batch_pfns); - -if ( saved_rc ) - { - rc = saved_rc; - errno = saved_errno; - } - +cleanup (ctx);return rc; };
Signature · 1 line
1.9.1
Re: [PATCH Remus v2 02/10] tools/libxc: introduce setup() and cleanup() on save
Quoted 6 lines · Yang Hongyang
introduce
setup()andcleanup()which subsume the ctx->save.ops.{setup,cleanup}() calls and also do allocate/free necessary memory.
TheSHADOW_OP_OFFhypercall also included in thecleanup().Signed-off-by Yang Hongyang <[email protected]>
I would suggest swapping this with patch 1, to save introducing new code, just to move it again in the next patch.
In general, a good change, but some comments...
Quoted 47 lines
--- tools/libxc/xc_sr_save.c | 72 +++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 28 deletions(-)tools/libxc/xc_sr_save.c +14
-8@@ -607,13 +607,10 @@ static int send_domain_memory_nonlive(struct xc_sr_context *ctx)return rc; } -/* -* Save a domain. -*/ -static int save (struct xc_sr_context *ctx,uint16_t guest_type) +static int setup (struct xc_sr_context *ctx) {xc_interface *xch = ctx->xch; -int rc, saved_rc =0 , saved_errno =0 ; +int rc; DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, (&ctx->save.dirty_bitmap_hbuf));@@ -632,13 +629,51 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) goto err; } -IPRINTF ("Saving domain %d, type %s" , - ctx->domid,dhdr_type_to_str (guest_type)); - rc = ctx->save.ops.setup (ctx);if ( rc ) goto err; + rc =0 ; + + err: +return rc; + +} + +static void cleanup (struct xc_sr_context *ctx) +{ +xc_interface *xch = ctx->xch; + DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, + (&ctx->save.dirty_bitmap_hbuf));
tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type) · line 657
Quoted 10 lines
tools/libxc/xc_sr_save.c +10
-0+ +xc_shadow_control (xch, ctx->domid,XEN_DOMCTL_SHADOW_OP_OFF , +NULL ,0 ,NULL ,0 ,NULL ); + +if ( ctx->save.ops.cleanup (ctx) ) +PERROR ("Failed to clean up" ); + +if ( dirty_bitmap ) +xc_hypercall_buffer_free_pages (xch, dirty_bitmap, +NRPAGES (bitmap_size (ctx->save.p2m_size)));
xc_hypercall_buffer_free_pages() if fine dealing with NULL, just like free() is. You can drop the conditional.
Quoted 38 lines
tools/libxc/xc_sr_save.c +19
-9+free (ctx->save.deferred_pages); +free (ctx->save.batch_pfns); +} + +/* +* Save a domain. +*/ +static int save (struct xc_sr_context *ctx,uint16_t guest_type) +{ +xc_interface *xch = ctx->xch; +int rc; + + rc =setup (ctx); +if ( rc ) + goto err; + +IPRINTF ("Saving domain %d, type %s" , + ctx->domid,dhdr_type_to_str (guest_type)); +xc_report_progress_single (xch,"Start of stream" ); rc =write_headers (ctx, guest_type);@@ -679,29 +714,10 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) goto done; err: - saved_errno = errno; - saved_rc = rc;PERROR ("Save failed" ); done: -xc_shadow_control (xch, ctx->domid,XEN_DOMCTL_SHADOW_OP_OFF , -NULL ,0 ,NULL ,0 ,NULL ); - - rc = ctx->save.ops.cleanup (ctx); -if ( rc ) -PERROR ("Failed to clean up" ); -
tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type) · line 703
Quoted 10 lines
tools/libxc/xc_sr_save.c +0
-10-xc_hypercall_buffer_free_pages (xch, dirty_bitmap, -NRPAGES (bitmap_size (ctx->save.p2m_size))); -free (ctx->save.deferred_pages); -free (ctx->save.batch_pfns); - -if ( saved_rc ) - { - rc = saved_rc; - errno = saved_errno; - }
You must keep saved_{rc,errno}, so that the cleanup doesn't clobber the errno semantically relevant to why the save failed.
~Andrew
Quoted 5 lines
tools/libxc/xc_sr_save.c +1
-1- +cleanup (ctx);return rc; };
Re: [PATCH Remus v2 02/10] tools/libxc: introduce setup() and cleanup() on save
Quoted 10 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
introduce
setup()andcleanup()which subsume the ctx->save.ops.{setup,cleanup}() calls and also do allocate/free necessary memory.
TheSHADOW_OP_OFFhypercall also included in thecleanup().Signed-off-by Yang Hongyang <[email protected]>I would suggest swapping this with patch 1, to save introducing new code, just to move it again in the next patch.
OK
Quoted 55 lines
In general, a good change, but some comments...
Quoted 52 lines
--- tools/libxc/xc_sr_save.c | 72 +++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 28 deletions(-)tools/libxc/xc_sr_save.c +19
-8@@ -607,13 +607,10 @@ static int send_domain_memory_nonlive(struct xc_sr_context *ctx)return rc; } -/* -* Save a domain. -*/ -static int save (struct xc_sr_context *ctx,uint16_t guest_type) +static int setup (struct xc_sr_context *ctx) {xc_interface *xch = ctx->xch; -int rc, saved_rc =0 , saved_errno =0 ; +int rc; DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, (&ctx->save.dirty_bitmap_hbuf));@@ -632,13 +629,51 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) goto err; } -IPRINTF ("Saving domain %d, type %s" , - ctx->domid,dhdr_type_to_str (guest_type)); - rc = ctx->save.ops.setup (ctx);if ( rc ) goto err; + rc =0 ; + + err: +return rc; + +} + +static void cleanup (struct xc_sr_context *ctx) +{ +xc_interface *xch = ctx->xch; + DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, + (&ctx->save.dirty_bitmap_hbuf)); + +xc_shadow_control (xch, ctx->domid,XEN_DOMCTL_SHADOW_OP_OFF , +NULL ,0 ,NULL ,0 ,NULL ); + +if ( ctx->save.ops.cleanup (ctx) )
Quoted 8 lines
tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type) · line 657
Quoted 5 lines
tools/libxc/xc_sr_save.c +5
-0+PERROR ("Failed to clean up" ); + +if ( dirty_bitmap ) +xc_hypercall_buffer_free_pages (xch, dirty_bitmap, +NRPAGES (bitmap_size (ctx->save.p2m_size)));
xc_hypercall_buffer_free_pages()if fine dealing with NULL, just likefree()is. You can drop the conditional.
Actually this is another trick that I need to deal with those hypercall macros. DECLARE_HYPERCALL_BUFFER_SHADOW will define a user pointer "dirty_bitmap" and a shadow buffer, although xc_hypercall_buffer_free_pages takes "dirty_bitmap" as an augument, but it is also a MACRO, without
"if ( dirty_bitmap )", the compiler will report "dirty_bitmap" unused error...
Quoted 44 lines
Quoted 44 lines
tools/libxc/xc_sr_save.c +19
-14+free (ctx->save.deferred_pages); +free (ctx->save.batch_pfns); +} + +/* +* Save a domain. +*/ +static int save (struct xc_sr_context *ctx,uint16_t guest_type) +{ +xc_interface *xch = ctx->xch; +int rc; + + rc =setup (ctx); +if ( rc ) + goto err; + +IPRINTF ("Saving domain %d, type %s" , + ctx->domid,dhdr_type_to_str (guest_type)); +xc_report_progress_single (xch,"Start of stream" ); rc =write_headers (ctx, guest_type);@@ -679,29 +714,10 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) goto done; err: - saved_errno = errno; - saved_rc = rc;PERROR ("Save failed" ); done: -xc_shadow_control (xch, ctx->domid,XEN_DOMCTL_SHADOW_OP_OFF , -NULL ,0 ,NULL ,0 ,NULL ); - - rc = ctx->save.ops.cleanup (ctx); -if ( rc ) -PERROR ("Failed to clean up" ); - -xc_hypercall_buffer_free_pages (xch, dirty_bitmap, -NRPAGES (bitmap_size (ctx->save.p2m_size))); -free (ctx->save.deferred_pages); -free (ctx->save.batch_pfns); -
Quoted 9 lines
tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type) · line 703
Quoted 5 lines
tools/libxc/xc_sr_save.c +0
-5-if ( saved_rc ) - { - rc = saved_rc; - errno = saved_errno; - }You must keep saved_{rc,errno}, so that the cleanup doesn't clobber the errno semantically relevant to why the save failed.
OK
Quoted 10 lines
~Andrew
tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type) · line 723
Quoted 5 lines
tools/libxc/xc_sr_save.c +1
-1- +cleanup (ctx);return rc; };.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH Remus v2 02/10] tools/libxc: introduce setup() and cleanup() on save
Quoted 69 lines · Hongyang Yang
Quoted 60 lines
In general, a good change, but some comments...
Quoted 56 lines
--- tools/libxc/xc_sr_save.c | 72 +++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 28 deletions(-)tools/libxc/xc_sr_save.c +20
-8@@ -607,13 +607,10 @@ static int send_domain_memory_nonlive(struct xc_sr_context *ctx)return rc; } -/* -* Save a domain. -*/ -static int save (struct xc_sr_context *ctx,uint16_t guest_type) +static int setup (struct xc_sr_context *ctx) {xc_interface *xch = ctx->xch; -int rc, saved_rc =0 , saved_errno =0 ; +int rc; DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, (&ctx->save.dirty_bitmap_hbuf));@@ -632,13 +629,51 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) goto err; } -IPRINTF ("Saving domain %d, type %s" , - ctx->domid,dhdr_type_to_str (guest_type)); - rc = ctx->save.ops.setup (ctx);if ( rc ) goto err; + rc =0 ; + + err: +return rc; + +} + +static void cleanup (struct xc_sr_context *ctx) +{ +xc_interface *xch = ctx->xch; + DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, + (&ctx->save.dirty_bitmap_hbuf)); + +xc_shadow_control (xch, ctx->domid,XEN_DOMCTL_SHADOW_OP_OFF , +NULL ,0 ,NULL ,0 ,NULL ); + +if ( ctx->save.ops.cleanup (ctx) ) +PERROR ("Failed to clean up" );Quoted 8 lines
tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type)
Quoted 5 lines
tools/libxc/xc_sr_save.c +4
-0+ +if ( dirty_bitmap ) +xc_hypercall_buffer_free_pages (xch, dirty_bitmap, +NRPAGES (bitmap_size (ctx->save.p2m_size)));
xc_hypercall_buffer_free_pages()if fine dealing with NULL, just likefree()is. You can drop the conditional.
Quoted 7 lines
Actually this is another trick that I need to deal with those hypercall macros.
DECLARE_HYPERCALL_BUFFER_SHADOWwill define a user pointer "dirty_bitmap" and a shadow buffer, althoughxc_hypercall_buffer_free_pagestakes "dirty_bitmap" as an augument, but it is also a MACRO, without "if (dirty_bitmap)", the compiler will report "dirty_bitmap" unused error...
Ah, in which case you would be better using xc__hypercall_buffer_free_pages() and not creating the local shadow in the first place.
~Andrew
Re: [PATCH Remus v2 02/10] tools/libxc: introduce setup() and cleanup() on save
Quoted 78 lines · Andrew Cooper
Quoted 69 lines · Hongyang Yang
Quoted 60 lines
In general, a good change, but some comments...
Quoted 56 lines
--- tools/libxc/xc_sr_save.c | 72 +++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 28 deletions(-)tools/libxc/xc_sr_save.c +20
-8@@ -607,13 +607,10 @@ static int send_domain_memory_nonlive(struct xc_sr_context *ctx)return rc; } -/* -* Save a domain. -*/ -static int save (struct xc_sr_context *ctx,uint16_t guest_type) +static int setup (struct xc_sr_context *ctx) {xc_interface *xch = ctx->xch; -int rc, saved_rc =0 , saved_errno =0 ; +int rc; DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, (&ctx->save.dirty_bitmap_hbuf));@@ -632,13 +629,51 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) goto err; } -IPRINTF ("Saving domain %d, type %s" , - ctx->domid,dhdr_type_to_str (guest_type)); - rc = ctx->save.ops.setup (ctx);if ( rc ) goto err; + rc =0 ; + + err: +return rc; + +} + +static void cleanup (struct xc_sr_context *ctx) +{ +xc_interface *xch = ctx->xch; + DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, + (&ctx->save.dirty_bitmap_hbuf)); + +xc_shadow_control (xch, ctx->domid,XEN_DOMCTL_SHADOW_OP_OFF , +NULL ,0 ,NULL ,0 ,NULL ); + +if ( ctx->save.ops.cleanup (ctx) ) +PERROR ("Failed to clean up" );Quoted 8 lines
tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type)
Quoted 5 lines
tools/libxc/xc_sr_save.c +4
-0+ +if ( dirty_bitmap ) +xc_hypercall_buffer_free_pages (xch, dirty_bitmap, +NRPAGES (bitmap_size (ctx->save.p2m_size)));
xc_hypercall_buffer_free_pages()if fine dealing with NULL, just likefree()is. You can drop the conditional.Quoted 7 lines
Actually this is another trick that I need to deal with those hypercall macros.
DECLARE_HYPERCALL_BUFFER_SHADOWwill define a user pointer "dirty_bitmap" and a shadow buffer, althoughxc_hypercall_buffer_free_pagestakes "dirty_bitmap" as an augument, but it is also a MACRO, without "if (dirty_bitmap)", the compiler will report "dirty_bitmap" unused error...
Quoted 3 lines
Ah, in which case you would be better using
xc__hypercall_buffer_free_pages()and not creating the local shadow in the first place.
I thought we'd better use those MACROs which described in the comments... If it is OK to use xc__hypercall_buffer_free_pages(), I will fix it in the next version.
Quoted 4 lines
~Andrew
.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH Remus v2 02/10] tools/libxc: introduce setup() and cleanup() on save
Quoted 80 lines · Hongyang Yang
Quoted 78 lines · Andrew Cooper
Quoted 76 lines · Hongyang Yang
Quoted 60 lines
In general, a good change, but some comments...
Quoted 56 lines
--- tools/libxc/xc_sr_save.c | 72 +++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 28 deletions(-)tools/libxc/xc_sr_save.c +20
-8@@ -607,13 +607,10 @@ static int send_domain_memory_nonlive(struct xc_sr_context *ctx)return rc; } -/* -* Save a domain. -*/ -static int save (struct xc_sr_context *ctx,uint16_t guest_type) +static int setup (struct xc_sr_context *ctx) {xc_interface *xch = ctx->xch; -int rc, saved_rc =0 , saved_errno =0 ; +int rc; DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, (&ctx->save.dirty_bitmap_hbuf));@@ -632,13 +629,51 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) goto err; } -IPRINTF ("Saving domain %d, type %s" , - ctx->domid,dhdr_type_to_str (guest_type)); - rc = ctx->save.ops.setup (ctx);if ( rc ) goto err; + rc =0 ; + + err: +return rc; + +} + +static void cleanup (struct xc_sr_context *ctx) +{ +xc_interface *xch = ctx->xch; + DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, + (&ctx->save.dirty_bitmap_hbuf)); + +xc_shadow_control (xch, ctx->domid,XEN_DOMCTL_SHADOW_OP_OFF , +NULL ,0 ,NULL ,0 ,NULL ); + +if ( ctx->save.ops.cleanup (ctx) ) +PERROR ("Failed to clean up" );Quoted 8 lines
tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type)
Quoted 5 lines
tools/libxc/xc_sr_save.c +4
-0+ +if ( dirty_bitmap ) +xc_hypercall_buffer_free_pages (xch, dirty_bitmap, +NRPAGES (bitmap_size (ctx->save.p2m_size)));
xc_hypercall_buffer_free_pages()if fine dealing with NULL, just likefree()is. You can drop the conditional.Actually this is another trick that I need to deal with those hypercall macros.
DECLARE_HYPERCALL_BUFFER_SHADOWwill define a user pointer "dirty_bitmap" and a shadow buffer, althoughxc_hypercall_buffer_free_pagestakes "dirty_bitmap" as an augument, but it is also a MACRO, without "if (dirty_bitmap)", the compiler will report "dirty_bitmap" unused error...
Quoted 7 lines
Quoted 3 lines
Ah, in which case you would be better using
xc__hypercall_buffer_free_pages()and not creating the local shadow in the first place.I thought we'd better use those MACROs which described in the comments... If it is OK to use
xc__hypercall_buffer_free_pages(), I will fix it in the next version.
If anything I think I'd prefer for the if to move inside the xc_hypercall_buffer_free_pages macro.
Ian.
Re: [PATCH Remus v2 02/10] tools/libxc: introduce setup() and cleanup() on save
Quoted 12 lines · Ian Campbell
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Actually this is another trick that I need to deal with those hypercall macros.
DECLARE_HYPERCALL_BUFFER_SHADOWwill define a user pointer "dirty_bitmap" and a shadow buffer, althoughxc_hypercall_buffer_free_pagestakes "dirty_bitmap" as an augument, but it is also a MACRO, without "if (dirty_bitmap)", the compiler will report "dirty_bitmap" unused error...Ah, in which case you would be better using
xc__hypercall_buffer_free_pages()and not creating the local shadow in the first place.
Quoted 6 lines
Quoted 3 lines
I thought we'd better use those MACROs which described in the comments... If it is OK to use
xc__hypercall_buffer_free_pages(), I will fix it in the next version.If anything I think I'd prefer for the if to move inside the
xc_hypercall_buffer_free_pagesmacro.
Or if you want to use the "raw" xc__hypercall_buffer variant you should be consistent and do the same on allocation.
Ian.
Re: [PATCH Remus v2 02/10] tools/libxc: introduce setup() and cleanup() on save
Quoted 17 lines · Ian Campbell
Quoted 16 lines · Ian Campbell
Quoted 15 lines
Quoted 11 lines
Quoted 7 lines
Actually this is another trick that I need to deal with those hypercall macros.
DECLARE_HYPERCALL_BUFFER_SHADOWwill define a user pointer "dirty_bitmap" and a shadow buffer, althoughxc_hypercall_buffer_free_pagestakes "dirty_bitmap" as an augument, but it is also a MACRO, without "if (dirty_bitmap)", the compiler will report "dirty_bitmap" unused error...Ah, in which case you would be better using
xc__hypercall_buffer_free_pages()and not creating the local shadow in the first place.I thought we'd better use those MACROs which described in the comments... If it is OK to use
xc__hypercall_buffer_free_pages(), I will fix it in the next version.
Quoted 5 lines
Quoted 2 lines
If anything I think I'd prefer for the if to move inside the
xc_hypercall_buffer_free_pagesmacro.Or if you want to use the "raw"
xc__hypercall_buffervariant you should be consistent and do the same on allocation.
I think I will add a patch that move the if inside the xc_hypercall_buffer_free_pages macro.
Quoted 6 lines
Ian.
.
Signature · 2 lines
Thanks, Yang.
PATCH v2 3/10 tools/libxc: rename send_some_pages to send_dirty_pages
In reply to Yang Hongyangrename send_some_pages to send_dirty_pages, no functional change.
--- tools/libxc/xc_sr_save.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/libxc/xc_sr_save.c +3 -3
@@ -379,7 +379,7 @@ static int send_all_pages(struct xc_sr_context *ctx)* * Bitmap is bounded by p2m_size. */ -static int send_some_pages (struct xc_sr_context *ctx, +static int send_dirty_pages (struct xc_sr_context *ctx,unsigned long *bitmap,unsigned long entries) {
@@ -515,7 +515,7 @@ static int send_domain_memory_live(struct xc_sr_context *ctx)if ( rc ) goto out; - rc =send_some_pages (ctx, dirty_bitmap, stats.dirty_count); + rc =send_dirty_pages (ctx, dirty_bitmap, stats.dirty_count);if ( rc ) goto out; }
@@ -540,7 +540,7 @@ static int send_domain_memory_live(struct xc_sr_context *ctx)bitmap_or (dirty_bitmap, ctx->save.deferred_pages, ctx->save.p2m_size); - rc =send_some_pages (ctx, dirty_bitmap, + rc =send_dirty_pages (ctx, dirty_bitmap, stats.dirty_count + ctx->save.nr_deferred_pages);if ( rc ) goto out;
Signature · 1 line
1.9.1
Re: [PATCH Remus v2 03/10] tools/libxc: rename send_some_pages to send_dirty_pages
Quoted 12 lines · Yang Hongyang
rename
send_some_pagestosend_dirty_pages, no functional change.Signed-off-by Yang Hongyang <[email protected]>--- tools/libxc/xc_sr_save.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)tools/libxc/xc_sr_save.c +0
-0
tools/libxc/xc_sr_save.c static int send_all_pages(struct xc_sr_context *ctx) · line 384
Quoted 7 lines
tools/libxc/xc_sr_save.c +1
-1@@ -379,7 +379,7 @@ static int send_all_pages(struct xc_sr_context *ctx)* * Bitmap is bounded by p2m_size. */ -static int send_some_pages (struct xc_sr_context *ctx, +static int send_dirty_pages (struct xc_sr_context *ctx,unsigned long *bitmap,unsigned long entries)
Please change the parameter alignment, so the end code is properly aligned.
Also, you can drop the *bitmap parameter, as it will always be the bitmap found in ctx. This will simplify some of your later patches.
~Andrew
Quoted 19 lines
tools/libxc/xc_sr_save.c +2
-2{@@ -515,7 +515,7 @@ static int send_domain_memory_live(struct xc_sr_context *ctx)if ( rc ) goto out; - rc =send_some_pages (ctx, dirty_bitmap, stats.dirty_count); + rc =send_dirty_pages (ctx, dirty_bitmap, stats.dirty_count);if ( rc ) goto out; }@@ -540,7 +540,7 @@ static int send_domain_memory_live(struct xc_sr_context *ctx)bitmap_or (dirty_bitmap, ctx->save.deferred_pages, ctx->save.p2m_size); - rc =send_some_pages (ctx, dirty_bitmap, + rc =send_dirty_pages (ctx, dirty_bitmap, stats.dirty_count + ctx->save.nr_deferred_pages);if ( rc ) goto out;
Re: [PATCH Remus v2 03/10] tools/libxc: rename send_some_pages to send_dirty_pages
Quoted 23 lines · Andrew Cooper
Quoted 12 lines · Yang Hongyang
rename
send_some_pagestosend_dirty_pages, no functional change.Signed-off-by Yang Hongyang <[email protected]>--- tools/libxc/xc_sr_save.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)tools/libxc/xc_sr_save.c +0
-0tools/libxc/xc_sr_save.c static int send_all_pages(struct xc_sr_context *ctx) · line 384
Quoted 7 lines
tools/libxc/xc_sr_save.c +1
-1@@ -379,7 +379,7 @@ static int send_all_pages(struct xc_sr_context *ctx)* * Bitmap is bounded by p2m_size. */ -static int send_some_pages (struct xc_sr_context *ctx, +static int send_dirty_pages (struct xc_sr_context *ctx,unsigned long *bitmap,unsigned long entries)Please change the parameter alignment, so the end code is properly aligned.
Quoted 2 lines
Also, you can drop the *bitmap parameter, as it will always be the bitmap found in ctx. This will simplify some of your later patches.
ok, thank you!
Quoted 25 lines
~Andrew
Quoted 11 lines
tools/libxc/xc_sr_save.c +1
-1{@@ -515,7 +515,7 @@ static int send_domain_memory_live(struct xc_sr_context *ctx)if ( rc ) goto out; - rc =send_some_pages (ctx, dirty_bitmap, stats.dirty_count); + rc =send_dirty_pages (ctx, dirty_bitmap, stats.dirty_count);if ( rc ) goto out; }tools/libxc/xc_sr_save.c static int send_domain_memory_live(struct xc_sr_context *ctx) · line 546
Quoted 8 lines
tools/libxc/xc_sr_save.c +1
-1@@ -540,7 +540,7 @@ static int send_domain_memory_live(struct xc_sr_context *ctx)bitmap_or (dirty_bitmap, ctx->save.deferred_pages, ctx->save.p2m_size); - rc =send_some_pages (ctx, dirty_bitmap, + rc =send_dirty_pages (ctx, dirty_bitmap, stats.dirty_count + ctx->save.nr_deferred_pages);if ( rc ) goto out;.
Signature · 2 lines
Thanks, Yang.
PATCH v2 4/10 tools/libxc: introduce DECLARE_HYPERCALL_BUFFER_USER_POINTER
In reply to Yang HongyangDefine a user pointer that can access the hypercall buffer data Useful when you only need to access the hypercall buffer data
--- tools/libxc/include/xenctrl.h | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/libxc/include/xenctrl.h +8 -0
@@ -296,6 +296,14 @@ typedef struct xc_hypercall_buffer xc_hypercall_buffer_t; }/* +* Define a user pointer that can access the hypercall buffer data +* +* Useful when you only need to access the hypercall buffer data +*/ +#define DECLARE_HYPERCALL_BUFFER_USER_POINTER (_type, _name, _hbuf) \ + _type *_name = _hbuf->hbuf; + +/* * Declare the necessary data structure to allow a hypercall buffer * passed as an argument to a function to be used in the normal way. */
Signature · 1 line
1.9.1
Re: [PATCH Remus v2 04/10] tools/libxc: introduce DECLARE_HYPERCALL_BUFFER_USER_POINTER
Quoted 13 lines · Yang Hongyang
Define a user pointer that can access the hypercall buffer data Useful when you only need to access the hypercall buffer data
Signed-off-by Yang Hongyang <[email protected]>--- tools/libxc/include/xenctrl.h | 8 ++++++++ 1 file changed, 8 insertions(+)tools/libxc/include/xenctrl.h +0
-0
tools/libxc/include/xenctrl.h typedef struct xc_hypercall_buffer xc_hypercall_buffer_t; · line 304
Quoted 9 lines
tools/libxc/include/xenctrl.h +6
-0@@ -296,6 +296,14 @@ typedef struct xc_hypercall_buffer xc_hypercall_buffer_t; }/* +* Define a user pointer that can access the hypercall buffer data +* +* Useful when you only need to access the hypercall buffer data +*/ +#define DECLARE_HYPERCALL_BUFFER_USER_POINTER (_type, _name, _hbuf) \ + _type *_name = _hbuf->hbuf;
There are some bracketing issues here. Please refer to my fixup patch which I will post as soon as I can.
~Andrew
Quoted 5 lines
tools/libxc/include/xenctrl.h +2
-0+ +/* * Declare the necessary data structure to allow a hypercall buffer * passed as an argument to a function to be used in the normal way. */
Re: [PATCH Remus v2 04/10] tools/libxc: introduce DECLARE_HYPERCALL_BUFFER_USER_POINTER
Quoted 16 lines · Andrew Cooper
Quoted 15 lines · Yang Hongyang
Define a user pointer that can access the hypercall buffer data Useful when you only need to access the hypercall buffer data
Signed-off-by Yang Hongyang <[email protected]>--- tools/libxc/include/xenctrl.h | 8 ++++++++ 1 file changed, 8 insertions(+)tools/libxc/include/xenctrl.h +0
-0@@ -296,6 +296,14 @@ typedef struct xc_hypercall_buffer xc_hypercall_buffer_t; }
Quoted 10 lines
tools/libxc/include/xenctrl.h typedef struct xc_hypercall_buffer xc_hypercall_buffer_t; · line 304
Quoted 7 lines
tools/libxc/include/xenctrl.h +6
-0/* +* Define a user pointer that can access the hypercall buffer data +* +* Useful when you only need to access the hypercall buffer data +*/ +#define DECLARE_HYPERCALL_BUFFER_USER_POINTER (_type, _name, _hbuf) \ + _type *_name = _hbuf->hbuf;There are some bracketing issues here. Please refer to my fixup patch which I will post as soon as I can.
I've seen those patches, will review them, thank you.
Quoted 11 lines
~Andrew
tools/libxc/include/xenctrl.h typedef struct xc_hypercall_buffer xc_hypercall_buffer_t; · line 309
Quoted 5 lines
tools/libxc/include/xenctrl.h +2
-0+ +/* * Declare the necessary data structure to allow a hypercall buffer * passed as an argument to a function to be used in the normal way. */ .
Signature · 2 lines
Thanks, Yang.
Re: [PATCH Remus v2 04/10] tools/libxc: introduce DECLARE_HYPERCALL_BUFFER_USER_POINTER
In reply to Yang HongyangQuoted 2 lines · Yang Hongyang
Define a user pointer that can access the hypercall buffer data Useful when you only need to access the hypercall buffer data
Can you expand on this please, I think the context is a hypercall buffer passed as an argument or as a member of a struct. Please describe why DECLARE_HYPERCALL_BUFFER_ARGUMENT and/or DECLARE_HYPERCALL_BUFFER_SHADOW are not usable here.
Ian.
Re: [PATCH Remus v2 04/10] tools/libxc: introduce DECLARE_HYPERCALL_BUFFER_USER_POINTER
Quoted 8 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang
Define a user pointer that can access the hypercall buffer data Useful when you only need to access the hypercall buffer data
Can you expand on this please, I think the context is a hypercall buffer passed as an argument or as a member of a struct. Please describe why
DECLARE_HYPERCALL_BUFFER_ARGUMENTand/orDECLARE_HYPERCALL_BUFFER_SHADOWare not usable here.
There are cases that we only need to use the hypercall buffer data, and do not use the xc_hypercall_buffer_t struct. DECLARE_HYPERCALL_BUFFER_ARGUMENT will only define a xc_hypercall_buffer_t, while DECLARE_HYPERCALL_BUFFER_SHADOW do define a user pointer that can allow us to access the hypercall buffer data but it also define a xc_hypercall_buffer_t that we don't use, the compiler will report arg unused error.
The cases for example:
In send_all_pages(), we only need to use the haypercall buffer data which is a dirty bitmap, we set the dirty bitmap to all dirty and call send_dirty_pages, we will not use the xc_hypercall_buffer_t and hypercall to retrive the dirty bitmap.
In send_some_pages(), we will also only need to use the dirty_bitmap. the retrive dirty bitmap hypercall are done by the caller.
Quoted 6 lines
Ian.
.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH Remus v2 04/10] tools/libxc: introduce DECLARE_HYPERCALL_BUFFER_USER_POINTER
Quoted 20 lines · Yang Hongyang
Quoted 8 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang
Define a user pointer that can access the hypercall buffer data Useful when you only need to access the hypercall buffer data
Can you expand on this please, I think the context is a hypercall buffer passed as an argument or as a member of a struct. Please describe why
DECLARE_HYPERCALL_BUFFER_ARGUMENTand/orDECLARE_HYPERCALL_BUFFER_SHADOWare not usable here.There are cases that we only need to use the hypercall buffer data, and do not use the
xc_hypercall_buffer_tstruct.
DECLARE_HYPERCALL_BUFFER_ARGUMENTwill only define axc_hypercall_buffer_t, whileDECLARE_HYPERCALL_BUFFER_SHADOWdo define a user pointer that can allow us to access the hypercall buffer data but it also define axc_hypercall_buffer_tthat we don't use, the compiler will report arg unused error.
Quoted 7 lines
The cases for example:
Insend_all_pages(), we only need to use the haypercall buffer data which is a dirty bitmap, we set the dirty bitmap to all dirty and callsend_dirty_pages, we will not use thexc_hypercall_buffer_tand hypercall to retrive the dirty bitmap.
Insend_some_pages(), we will also only need to use thedirty_bitmap. the retrive dirty bitmap hypercall are done by the caller.
Thanks. Please include the bulk of this description in the commit message.
However, perhaps we should just mark the xc_hypercall_buffer_t as potentially unused, by tagging it with __attribute__((unused)), in some or all of the DECLARE_HYPERCALL_* variants. Then I think you could use DECLARE_HYPERCALL_BUFFER_SHADOW as is?
My argument here would be that the xc_hypercall_buffer_t created here is a hidden part of the internal hcall buf infrastructure and should be transparent to the user's code. The user's code only interacts with it via the magic macros which take the "user pointer" name, not the mangled xc_hypercall_buffer_t's name.
I'm wary of creating too many accessors macros, or of creating too many back doors around the attempts to steer code away from using regular memory to pass to hypercalls.
Ian.
Re: [PATCH Remus v2 04/10] tools/libxc: introduce DECLARE_HYPERCALL_BUFFER_USER_POINTER
Quoted 29 lines · Ian Campbell
Quoted 20 lines · Yang Hongyang
Quoted 8 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang
Define a user pointer that can access the hypercall buffer data Useful when you only need to access the hypercall buffer data
Can you expand on this please, I think the context is a hypercall buffer passed as an argument or as a member of a struct. Please describe why
DECLARE_HYPERCALL_BUFFER_ARGUMENTand/orDECLARE_HYPERCALL_BUFFER_SHADOWare not usable here.There are cases that we only need to use the hypercall buffer data, and do not use the
xc_hypercall_buffer_tstruct.
DECLARE_HYPERCALL_BUFFER_ARGUMENTwill only define axc_hypercall_buffer_t, whileDECLARE_HYPERCALL_BUFFER_SHADOWdo define a user pointer that can allow us to access the hypercall buffer data but it also define axc_hypercall_buffer_tthat we don't use, the compiler will report arg unused error.Quoted 7 lines
The cases for example:
Insend_all_pages(), we only need to use the haypercall buffer data which is a dirty bitmap, we set the dirty bitmap to all dirty and callsend_dirty_pages, we will not use thexc_hypercall_buffer_tand hypercall to retrive the dirty bitmap.
Insend_some_pages(), we will also only need to use thedirty_bitmap. the retrive dirty bitmap hypercall are done by the caller.
Quoted 7 lines
Thanks. Please include the bulk of this description in the commit message.
However, perhaps we should just mark the
xc_hypercall_buffer_tas potentially unused, by tagging it with __attribute__((unused)), in some or all of the DECLARE_HYPERCALL_* variants. Then I think you could useDECLARE_HYPERCALL_BUFFER_SHADOWas is?
If __attribute__((unused)) won't cause other problems here, I also prefer to add this to DECLARE_HYPERCALL_BUFFER_SHADOW instead of create another macro, I think only DECLARE_HYPERCALL_BUFFER_SHADOW may need to set this attribute because this is a shadow, we might not use the xc_hypercall_buffer_t which already allocated.
Quoted 15 lines
My argument here would be that the
xc_hypercall_buffer_tcreated here is a hidden part of the internal hcall buf infrastructure and should be transparent to the user's code. The user's code only interacts with it via the magic macros which take the "user pointer" name, not the mangled xc_hypercall_buffer_t's name.I'm wary of creating too many accessors macros, or of creating too many back doors around the attempts to steer code away from using regular memory to pass to hypercalls.
Ian.
.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH Remus v2 04/10] tools/libxc: introduce DECLARE_HYPERCALL_BUFFER_USER_POINTER
Quoted 39 lines · Yang Hongyang
Quoted 29 lines · Ian Campbell
Quoted 20 lines · Yang Hongyang
Quoted 8 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang
Define a user pointer that can access the hypercall buffer data Useful when you only need to access the hypercall buffer data
Can you expand on this please, I think the context is a hypercall buffer passed as an argument or as a member of a struct. Please describe why
DECLARE_HYPERCALL_BUFFER_ARGUMENTand/orDECLARE_HYPERCALL_BUFFER_SHADOWare not usable here.There are cases that we only need to use the hypercall buffer data, and do not use the
xc_hypercall_buffer_tstruct.
DECLARE_HYPERCALL_BUFFER_ARGUMENTwill only define axc_hypercall_buffer_t, whileDECLARE_HYPERCALL_BUFFER_SHADOWdo define a user pointer that can allow us to access the hypercall buffer data but it also define axc_hypercall_buffer_tthat we don't use, the compiler will report arg unused error.Quoted 7 lines
The cases for example:
Insend_all_pages(), we only need to use the haypercall buffer data which is a dirty bitmap, we set the dirty bitmap to all dirty and callsend_dirty_pages, we will not use thexc_hypercall_buffer_tand hypercall to retrive the dirty bitmap.
Insend_some_pages(), we will also only need to use thedirty_bitmap. the retrive dirty bitmap hypercall are done by the caller.Quoted 7 lines
Thanks. Please include the bulk of this description in the commit message.
However, perhaps we should just mark the
xc_hypercall_buffer_tas potentially unused, by tagging it with __attribute__((unused)), in some or all of the DECLARE_HYPERCALL_* variants. Then I think you could useDECLARE_HYPERCALL_BUFFER_SHADOWas is?
Quoted 5 lines
If __attribute__((unused)) won't cause other problems here, I also prefer to add this to
DECLARE_HYPERCALL_BUFFER_SHADOWinstead of create another macro, I think onlyDECLARE_HYPERCALL_BUFFER_SHADOWmay need to set this attribute because this is a shadow, we might not use thexc_hypercall_buffer_twhich already allocated.
We can certainly start from there and consider other such additions as the need arises.
Ian.
Re: [PATCH Remus v2 04/10] tools/libxc: introduce DECLARE_HYPERCALL_BUFFER_USER_POINTER
Quoted 40 lines · Ian Campbell
Quoted 39 lines · Yang Hongyang
Quoted 36 lines · Ian Campbell
Quoted 20 lines · Yang Hongyang
Quoted 8 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang
Define a user pointer that can access the hypercall buffer data Useful when you only need to access the hypercall buffer data
Can you expand on this please, I think the context is a hypercall buffer passed as an argument or as a member of a struct. Please describe why
DECLARE_HYPERCALL_BUFFER_ARGUMENTand/orDECLARE_HYPERCALL_BUFFER_SHADOWare not usable here.There are cases that we only need to use the hypercall buffer data, and do not use the
xc_hypercall_buffer_tstruct.
DECLARE_HYPERCALL_BUFFER_ARGUMENTwill only define axc_hypercall_buffer_t, whileDECLARE_HYPERCALL_BUFFER_SHADOWdo define a user pointer that can allow us to access the hypercall buffer data but it also define axc_hypercall_buffer_tthat we don't use, the compiler will report arg unused error.Quoted 7 lines
The cases for example:
Insend_all_pages(), we only need to use the haypercall buffer data which is a dirty bitmap, we set the dirty bitmap to all dirty and callsend_dirty_pages, we will not use thexc_hypercall_buffer_tand hypercall to retrive the dirty bitmap.
Insend_some_pages(), we will also only need to use thedirty_bitmap. the retrive dirty bitmap hypercall are done by the caller.Thanks. Please include the bulk of this description in the commit message.
However, perhaps we should just mark the
xc_hypercall_buffer_tas potentially unused, by tagging it with __attribute__((unused)), in some or all of the DECLARE_HYPERCALL_* variants. Then I think you could useDECLARE_HYPERCALL_BUFFER_SHADOWas is?
Quoted 8 lines
Quoted 5 lines
If __attribute__((unused)) won't cause other problems here, I also prefer to add this to
DECLARE_HYPERCALL_BUFFER_SHADOWinstead of create another macro, I think onlyDECLARE_HYPERCALL_BUFFER_SHADOWmay need to set this attribute because this is a shadow, we might not use thexc_hypercall_buffer_twhich already allocated.We can certainly start from there and consider other such additions as the need arises.
OK, thanks, will do in the next version.
Quoted 5 lines
Ian.
.
Signature · 2 lines
Thanks, Yang.
PATCH v2 5/10 tools/libxc: reuse send_dirty_pages() in send_all_pages()
In reply to Yang Hongyangintroduce bitmap_set() to set the entire bitmap.
in send_all_pages(), set the entire bitmap and call send_dirty_pages().
--- tools/libxc/xc_bitops.h | 5 +++++ tools/libxc/xc_sr_save.c | 44 ++++++++++++++------------------------------ 2 files changed, 19 insertions(+), 30 deletions(-)
tools/libxc/xc_bitops.h +5 -0
@@ -26,6 +26,11 @@ static inline unsigned long *bitmap_alloc(int nr_bits)return calloc (1 ,bitmap_size (nr_bits)); } +static inline void bitmap_set (unsigned long *addr,int nr_bits) +{ +memset (addr,0xff ,bitmap_size (nr_bits)); +} +static inline void bitmap_clear (unsigned long *addr,int nr_bits) {memset (addr,0 ,bitmap_size (nr_bits));
tools/libxc/xc_sr_save.c +14 -30
56 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH Remus v2 05/10] tools/libxc: reuse send_dirty_pages() in send_all_pages()
Quoted 4 lines · Yang Hongyang
introduce
bitmap_set()to set the entire bitmap.
insend_all_pages(), set the entire bitmap and callsend_dirty_pages().Signed-off-by Yang Hongyang <[email protected]>
the expected change due to cleanup in previous patches)
Quoted 83 lines
--- tools/libxc/xc_bitops.h | 5 +++++ tools/libxc/xc_sr_save.c | 44 ++++++++++++++------------------------------ 2 files changed, 19 insertions(+), 30 deletions(-)tools/libxc/xc_bitops.h +5
-0@@ -26,6 +26,11 @@ static inline unsigned long *bitmap_alloc(int nr_bits)return calloc (1 ,bitmap_size (nr_bits)); } +static inline void bitmap_set (unsigned long *addr,int nr_bits) +{ +memset (addr,0xff ,bitmap_size (nr_bits)); +} +static inline void bitmap_clear (unsigned long *addr,int nr_bits) {memset (addr,0 ,bitmap_size (nr_bits));tools/libxc/xc_sr_save.c +14
-30@@ -344,36 +344,6 @@ static int suspend_domain(struct xc_sr_context *ctx) }/* -* Send all pages in the guests p2m. Used as the first iteration of the live -* migration loop, and for a non-live save. -*/ -static int send_all_pages (struct xc_sr_context *ctx) -{ -xc_interface *xch = ctx->xch; -xen_pfn_t p; -int rc; - -for ( p =0 ; p < ctx->save.p2m_size; ++p ) - { - rc =add_to_batch (ctx, p); -if ( rc ) -return rc; - -/* Update progress every 4MB worth of memory sent. */ -if ( (p & ((1U << (22 -12 )) -1 )) ==0 ) -xc_report_progress_step (xch, p, ctx->save.p2m_size); - } - - rc =flush_batch (ctx); -if ( rc ) -return rc; - -xc_report_progress_step (xch, ctx->save.p2m_size, - ctx->save.p2m_size); -return 0 ; -} - -/* * Send a subset of pages in the guests p2m, according to the provided bitmap. * Used for each subsequent iteration of the live migration loop. * @@ -415,6 +385,20 @@ static int send_dirty_pages(struct xc_sr_context *ctx,return 0 ; } +/* +* Send all pages in the guests p2m. Used as the first iteration of the live +* migration loop, and for a non-live save. +*/ +static int send_all_pages (struct xc_sr_context *ctx) +{ + DECLARE_HYPERCALL_BUFFER_USER_POINTER(unsigned long, dirty_bitmap, + (&ctx->save.dirty_bitmap_hbuf)); + +bitmap_set (dirty_bitmap, ctx->save.p2m_size); + +return send_dirty_pages (ctx, dirty_bitmap, ctx->save.p2m_size); +} +static int enable_logdirty (struct xc_sr_context *ctx) {xc_interface *xch = ctx->xch;
PATCH v2 6/10 tools/libxc: introduce process_record()
In reply to Yang HongyangMove record handle codes into a function process_record(). It will be used multiple times by Remus.
No functional change.
--- tools/libxc/xc_sr_restore.c | 77 +++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 34 deletions(-)
tools/libxc/xc_sr_restore.c +43 -34
@@ -468,6 +468,48 @@ static int handle_page_data(struct xc_sr_context *ctx, struct xc_sr_record *rec)return rc; } +static int process_record (struct xc_sr_context *ctx,struct xc_sr_record *rec) +{ +xc_interface *xch = ctx->xch; +int rc =0 ; + +switch ( rec->type ) + { +case REC_TYPE_END : +break ; + +case REC_TYPE_PAGE_DATA : + rc =handle_page_data (ctx, rec); +break ; + +case REC_TYPE_VERIFY : +DPRINTF ("Verify mode enabled" ); + ctx->restore.verify = true; +break ; + +default : + rc = ctx->restore.ops.process_record (ctx, rec); +break ; + } + +free (rec->data); + +if ( rc ==RECORD_NOT_PROCESSED ) + { +if ( rec->type &REC_TYPE_OPTIONAL ) +DPRINTF ("Ignoring optional record %#x (%s)" , + rec->type,rec_type_to_str (rec->type)); +else + { +ERROR ("Mandatory record %#x (%s) not handled" , + rec->type,rec_type_to_str (rec->type)); + rc =-1 ; + } + } + +return rc; +} +/* * Restore a domain. */
@@ -498,40 +540,7 @@ static int restore(struct xc_sr_context *ctx)if ( rc ) goto err; -switch ( rec.type ) - { -case REC_TYPE_END : -break ; - -case REC_TYPE_PAGE_DATA : - rc =handle_page_data (ctx, &rec); -break ; - -case REC_TYPE_VERIFY : -DPRINTF ("Verify mode enabled" ); - ctx->restore.verify = true; -break ; - -default : - rc = ctx->restore.ops.process_record (ctx, &rec); -break ; - } - -free (rec.data); - -if ( rc ==RECORD_NOT_PROCESSED ) - { -if ( rec.type &REC_TYPE_OPTIONAL ) -DPRINTF ("Ignoring optional record %#x (%s)" , - rec.type,rec_type_to_str (rec.type)); -else - { -ERROR ("Mandatory record %#x (%s) not handled" , - rec.type,rec_type_to_str (rec.type)); - rc =-1 ; - } - } - + rc =process_record (ctx, &rec);if ( rc ) goto err;
Signature · 1 line
1.9.1
PATCH v2 7/10 tools/libxc: split read/handle qemu info
In reply to Yang HongyangSplit read/handle qemu info. The receiving of qemu info should be done while we receive the migration stream, handle_qemu will be called when the stream complete. Otherwise, it will break Remus because read_record() won't read qemu info and stream_complete will be called at failover.
--- tools/libxc/xc_sr_common.h | 5 +++++ tools/libxc/xc_sr_restore.c | 12 ++++++++++++ tools/libxc/xc_sr_restore_x86_hvm.c | 28 +++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-)
tools/libxc/xc_sr_common.h +5 -0
@@ -280,6 +280,11 @@ struct xc_sr_context/* HVM context blob. */ void *context;size_t contextsz; + +#ifdef XG_LIBXL_HVM_COMPAT +uint32_t qlen; +void *qbuf; +#endif } restore; }; } x86_hvm;
tools/libxc/xc_sr_restore.c +12 -0
@@ -510,6 +510,9 @@ static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec)return rc; } +#ifdef XG_LIBXL_HVM_COMPAT +extern int read_qemu (struct xc_sr_context *ctx); +#endif /* * Restore a domain. */
@@ -546,6 +549,15 @@ static int restore(struct xc_sr_context *ctx) }while ( rec.type !=REC_TYPE_END ); +#ifdef XG_LIBXL_HVM_COMPAT +if ( ctx->dominfo.hvm ) + { + rc =read_qemu (ctx); +if ( rc ) + goto err; + } +#endif + rc = ctx->restore.ops.stream_complete (ctx);if ( rc ) goto err;
tools/libxc/xc_sr_restore_x86_hvm.c +25 -3
@@ -94,14 +94,14 @@ static int handle_hvm_params(struct xc_sr_context *ctx, }#ifdef XG_LIBXL_HVM_COMPAT -static int handle_qemu (struct xc_sr_context *ctx) +int read_qemu (struct xc_sr_context *ctx); +int read_qemu (struct xc_sr_context *ctx) {xc_interface *xch = ctx->xch; -char qemusig[21 ], path[256 ]; +char qemusig[21 ];uint32_t qlen;void *qbuf =NULL ;int rc =-1 ; -FILE *fp =NULL ;if (read_exact (ctx->fd, qemusig,sizeof (qemusig)) ) {
@@ -137,6 +137,28 @@ static int handle_qemu(struct xc_sr_context *ctx) goto out; } +/* With Remus, this could be read many times */ +if ( ctx->x86_hvm.restore.qbuf ) +free (ctx->x86_hvm.restore.qbuf); + ctx->x86_hvm.restore.qbuf = qbuf; + ctx->x86_hvm.restore.qlen = qlen; + rc =0 ; + +out: +if (rc) +free (qbuf); +return rc; +} + +static int handle_qemu (struct xc_sr_context *ctx) +{ +xc_interface *xch = ctx->xch; +char path[256 ]; +uint32_t qlen = ctx->x86_hvm.restore.qlen; +void *qbuf = ctx->x86_hvm.restore.qbuf; +int rc =-1 ; +FILE *fp =NULL ; +sprintf (path,XC_DEVICE_MODEL_RESTORE_FILE ".%u" , ctx->domid); fp =fopen (path,"wb" );if ( !fp )
Signature · 1 line
1.9.1
PATCH v2 8/10 tools/libxc: implement Remus checkpointed save
In reply to Yang HongyangWith Remus, the save flow should be:
live migration->{ periodically save(checkpointed save) }
--- tools/libxc/include/xenguest.h | 1 + tools/libxc/xc_sr_common.h | 6 ++++ tools/libxc/xc_sr_save.c | 74 +++++++++++++++++++++++++++++------------- tools/libxl/libxl_dom.c | 1 + 4 files changed, 59 insertions(+), 23 deletions(-)
tools/libxc/include/xenguest.h +1 -0
@@ -30,6 +30,7 @@#define XCFLAGS_HVM (1 << 2)#define XCFLAGS_STDVGA (1 << 3)#define XCFLAGS_CHECKPOINT_COMPRESS (1 << 4) +#define XCFLAGS_CHECKPOINTED (1 << 5)#define X86_64_B_SIZE 64#define X86_32_B_SIZE 32
tools/libxc/xc_sr_common.h +6 -0
@@ -172,6 +172,12 @@ struct xc_sr_context/* Further debugging information in the stream. */ bool debug; +/* +* Whether it is a checkpointed save, we'll enter checkpointed +* save after live migration under Remus. +*/ +bool checkpointed; +/* Parameters for tweaking live migration. */ unsigned max_iterations;unsigned dirty_threshold;
tools/libxc/xc_sr_save.c +51 -23
104 lines not on this page · raw message
tools/libxl/libxl_dom.c +1 -0
@@ -2003,6 +2003,7 @@ void libxl__domain_suspend(libxl__egc *egc, libxl__domain_suspend_state *dss)if (r_info !=NULL ) { dss->interval = r_info->interval; + dss->xcflags |=XCFLAGS_CHECKPOINTED ;if (libxl_defbool_val (r_info->compression)) dss->xcflags |=XCFLAGS_CHECKPOINT_COMPRESS ; }
Signature · 1 line
1.9.1
PATCH v2 9/10 tools/libxc: implement Remus checkpointed restore
In reply to Yang HongyangWith Remus, the restore flow should be:
the first full migration stream -> { periodically restore stream } on failover:
stream_complete()
--- tools/libxc/xc_sr_common.h | 3 ++ tools/libxc/xc_sr_restore.c | 108 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 104 insertions(+), 7 deletions(-)
tools/libxc/xc_sr_common.h +3 -0
@@ -196,6 +196,9 @@ struct xc_sr_contextstruct xc_sr_restore_ops ops;struct restore_callbacks *callbacks; +/* Whether it is a checkpointed stream */ +bool checkpointed; +/* From Image Header. */ uint32_t format_version;
tools/libxc/xc_sr_restore.c +101 -7
151 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 10/10 tools/libxc: X86_PV_INFO can be sent multiple times under Remus
In reply to Yang HongyangX86_PV_INFO can be sent multiple times under Remus
--- tools/libxc/xc_sr_restore_x86_pv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxc/xc_sr_restore_x86_pv.c +1 -1
@@ -590,7 +590,7 @@ static int handle_x86_pv_info(struct xc_sr_context *ctx,xc_interface *xch = ctx->xch;struct xc_sr_rec_x86_pv_info *info = rec->data; -if ( ctx->x86_pv.restore.seen_pv_info ) +if ( ctx->x86_pv.restore.seen_pv_info && !ctx->restore.checkpointed ) {ERROR ("Already received X86_PV_INFO record" );return -1 ;
Signature · 1 line
1.9.1
Quoted 9 lines · Yang Hongyang
This patchset implement the Remus support for Migration v2 but without memory compressing.
The series can be found on github:
https://github.com/macrosheep/xen/tree/Remus-newmig-v2PATCH 1-7: Some refactor and prepare work.
PATCH 8-9: The main Remus loop implement.
PATCH 10: Fix for Remus.
I have reviewed the other half of the series now, and have some design to discuss. (I was hoping to get this email sent in reply to v1, but never mind). This largely concerns patch 7 and onwards.
Migration v2 has substantially more structure than legacy did. Once issue so far is that your series relies on using more than one END record, which is not supported in the spec. (Of course - the spec is fine to be extended in forward-compatible ways.)
To fix the qemu layering issues I need to have some explicit negotiation between libxc and libxl about sharing ownership of the input fd. This is going to require a new record in the format, and I currently drafting a patch or two which should help in this regard.
My view for the eventual stream looks something like this (time going downwards):
libxc writes: libxl writes:
Image Header
Domain Headerstart_of_stream()start_of_checkpoint()
<memory>end_of_checkpoint()
Checkpoint record
ctx->save.callbacks->checkpoint()
libxl qemu record
...
libxl end-of-checkpoint record
ctx->save.callbacks->checkpoint() returnsstart_of_checkpoint()
<memory>end_of_checkpoint()
Checkpoint record
etc...
This will eventually allow both libxc and libxl to send checkpoint data (and by the looks of it, remove the need for postcopy()). With this libxc/remus work it is fine to use XG_LIBXL_HVM_COMPAT to cover the current qemu situation, but I would prefer not to be also retrofitting libxc checkpoint records when doing the libxl/migv2 work.
Does this look plausible in for Remus (and eventually COLO) support?
~Andrew
Quoted 11 lines · Andrew Cooper
Quoted 9 lines · Yang Hongyang
This patchset implement the Remus support for Migration v2 but without memory compressing.
The series can be found on github:
https://github.com/macrosheep/xen/tree/Remus-newmig-v2PATCH 1-7: Some refactor and prepare work.
PATCH 8-9: The main Remus loop implement.
PATCH 10: Fix for Remus.
Quoted 8 lines
I have reviewed the other half of the series now, and have some design to discuss. (I was hoping to get this email sent in reply to v1, but never mind). This largely concerns patch 7 and onwards.
Migration v2 has substantially more structure than legacy did. Once issue so far is that your series relies on using more than one END record, which is not supported in the spec. (Of course - the spec is fine to be extended in forward-compatible ways.)
I use END record as a info that indicate the end of the stream. I saw that you add a checkpoint record in your v2 series of Remus related patches, I can use that record to indicate the end of the checkpointed stream, but I think the record better to be called as end-of-checkpoint?
Quoted 9 lines
To fix the qemu layering issues I need to have some explicit negotiation between libxc and libxl about sharing ownership of the input fd. This is going to require a new record in the format, and I currently drafting a patch or two which should help in this regard.
My view for the eventual stream looks something like this (time going downwards):
Quoted 6 lines
libxc writes: libxl writes:
Image Header
Domain Headerstart_of_stream()start_of_checkpoint()
<live memory>
ctx->save.callbacks->suspend()
this callback suspend the primary guest and then calls Remus devices postsuspend callbacks to buffer the network pkts etc.
<last iter of memory>
Quoted 2 lines
end_of_checkpoint()
Checkpoint record
ctx->save.callbacks->postcopy()
this callback should not be omitted, it do some necessary work before resume primary (such as call Remus devices preresume callbacks to ensure the disk data is consistent) and then resume the primary guest. I think this callback should be renamed to ctx->save.callbacks->resume().
Quoted 2 lines
ctx->save.callbacks->checkpoint()
libxl qemu record
Maybe we should add another callback to send qemu record instead of using checkpoint callback. We can call it ctx->save.callbacks->save_qemu() Then in checkpoint callback, we only call remus devices commit callbacks( which will release the network buffer etc...) then decide whether we need to do another checkpoint or quit checkpointed stream.
With Remus, checkpoint callback only wait for 200ms(can be specified by -i) then return.
With COLO, checkpoint callback will ask COLO proxy if we need to do a checkpoint, will return when COLO proxy module indicate a checkpoint is needed.
Quoted 4 lines
... libxl end-of-checkpoint record ctx->save.callbacks->checkpoint() returns
start_of_checkpoint()
ctx->save.callbacks->suspend()
Quoted 5 lines
<memory>
end_of_checkpoint()
Checkpoint record
etc...
Quoted 7 lines
This will eventually allow both libxc and libxl to send checkpoint data (and by the looks of it, remove the need for
postcopy()). With this libxc/remus work it is fine to useXG_LIBXL_HVM_COMPATto cover the current qemu situation, but I would prefer not to be also retrofitting libxc checkpoint records when doing the libxl/migv2 work.Does this look plausible in for Remus (and eventually COLO) support?
With comments above, I would suggest the save flow as below:
libxc writes: libxl writes:
live migration:
Image Header
Domain Headerstart_of_stream()start_of_checkpoint()
<live memory>ctx->save.callbacks->suspend()
<last iter memory>end_of_checkpoint()
if ( checkpointd )
End of Checkpoint record
/*If resotre side receives this record, input fd should be handed to libxl*/
else
goto end
loop of checkpointed stream:ctx->save.callbacks->resume()ctx->save.callbacks->save_qemu()
libxl qemu record
...
libxl end-of-checkpoint record
/*If resotre side receives this record, input fd should be handed to libxc*/ ctx->save.callbacks->save_qemu() returns ctx->save.callbacks->checkpoint()start_of_checkpoint()ctx->save.callbacks->suspend()
<memory>end_of_checkpoint()
End of Checkpoint record
goto 'loop of checkpointed stream'
end:
END record
/*If resotre side receives this record, input fd should be handed to libxl*/
In order to keep it simple, we can keep the current ctx->save.callbacks->checkpoint() as it is, which do the save_qemu thing, call Remus devices commit callbacks and then decide whether we need a checkpoint. We
can also combine the ctx->save.callbacks->resume() withctx->save.callbacks->checkpoint(), with only one checkpoint() callback, we do
the following things:
- Call Remus devices preresume callbacks
- Resume the primary
- Save qemu records
- Call Remus devices commit callbacks
- Decide whether we need a checkpoint
Overall, there are 3 options for the save flow:
1. keep the current callbacks, rename postcopy() to resume()
2. split the checkpoint() callback to save_qemu() and checkpoint()
3. combine the current postcopy() and checkpoint() Which one do you think is the best?
Quoted 4 lines
~Andrew
.
Signature · 2 lines
Thanks, Yang.
Quoted 16 lines · Hongyang Yang
Quoted 15 lines · Andrew Cooper
Quoted 9 lines · Yang Hongyang
This patchset implement the Remus support for Migration v2 but without memory compressing.
The series can be found on github:
https://github.com/macrosheep/xen/tree/Remus-newmig-v2PATCH 1-7: Some refactor and prepare work.
PATCH 8-9: The main Remus loop implement.
PATCH 10: Fix for Remus.I have reviewed the other half of the series now, and have some design to discuss. (I was hoping to get this email sent in reply to v1, but never mind). This largely concerns patch 7 and onwards.
Quoted 6 lines
Quoted 4 lines
Migration v2 has substantially more structure than legacy did. Once issue so far is that your series relies on using more than one END record, which is not supported in the spec. (Of course - the spec is fine to be extended in forward-compatible ways.)
I use END record as a info that indicate the end of the stream.
I suspected this, but is not a backwards compatible use of the migration v2 stream. There must only be a single END record, and it must be the very last record the save side produces.
Quoted 5 lines
I saw
that you add a checkpoint record in your v2 series of Remus related patches,
I can use that record to indicate the end of the checkpointed stream, but I think the record better to be called as end-of-checkpoint?
It is the logical end of the libxc bits of a checkpoint, but not of the (soon to exist) libxl bits.
Quoted 17 lines
Quoted 10 lines
To fix the qemu layering issues I need to have some explicit negotiation between libxc and libxl about sharing ownership of the input fd. This is going to require a new record in the format, and I currently drafting a patch or two which should help in this regard.
My view for the eventual stream looks something like this (time going downwards):
Quoted 6 lines
libxc writes: libxl writes:
Image Header
Domain Headerstart_of_stream()start_of_checkpoint()
Quoted 5 lines
<live memory>
ctx->save.callbacks->suspend()
this callback suspend the primary guest and then calls Remus devices postsuspend callbacks to buffer the network pkts etc.
Sorry yes - I omitted this call in the example for brevity, but was not intending to omit it from the code.
Quoted 6 lines
<last iter of memory>
Quoted 2 lines
end_of_checkpoint()
Checkpoint record
Quoted 7 lines
ctx->save.callbacks->postcopy()
this callback should not be omitted, it do some necessary work before resume
primary (such as call Remus devices preresume callbacks to ensure the disk
data is consistent) and then resume the primary guest. I think this callback should be renamed toctx->save.callbacks->resume().
That looks to be a useful cleanup (and answers one of my questions of what exactly postcopy was)
Quoted 7 lines
Quoted 3 lines
ctx->save.callbacks->checkpoint()
libxl qemu recordMaybe we should add another callback to send qemu record instead of using checkpoint callback. We can call it
ctx->save.callbacks->save_qemu()
This is another layering violation. libxc should not prescribe what libxl might or might not do. One example we are experimenting with in XenServer at the moment is support for multiple emulators attached to a single domain, which would necessitate two LIBXL_EMULATOR records to be sent per checkpoint. libxl might also want to send an updated json blob or such.
Quoted 10 lines
Then in checkpoint callback, we only call remus devices commit callbacks( which will release the network buffer etc...) then decide whether we need to
do another checkpoint or quit checkpointed stream.
With Remus, checkpoint callback only wait for 200ms(can be specified by -i)
then return.
With COLO, checkpoint callback will ask COLO proxy if we need to do a checkpoint, will return when COLO proxy module indicate a checkpoint is needed.
That sounds like COLO wants a should_checkpoint() callback which separates the decision to make a checkpoint from the logic of implementing a checkpoint.
Quoted 79 lines
Quoted 5 lines
... libxl end-of-checkpoint record ctx->save.callbacks->checkpoint() returns
start_of_checkpoint()
ctx->save.callbacks->suspend()Quoted 5 lines
<memory>
end_of_checkpoint()
Checkpoint record
etc...Quoted 7 lines
This will eventually allow both libxc and libxl to send checkpoint data (and by the looks of it, remove the need for
postcopy()). With this libxc/remus work it is fine to useXG_LIBXL_HVM_COMPATto cover the current qemu situation, but I would prefer not to be also retrofitting libxc checkpoint records when doing the libxl/migv2 work.Does this look plausible in for Remus (and eventually COLO) support?
With comments above, I would suggest the save flow as below:
libxc writes: libxl writes:
live migration:
Image Header
Domain Headerstart_of_stream()start_of_checkpoint()
<live memory>ctx->save.callbacks->suspend()
<last iter memory>end_of_checkpoint()
if ( checkpointd )
End of Checkpoint record
/*If resotre side receives this record, input fd should be handed to
libxl*/
else
goto endloop of checkpointed stream:
ctx->save.callbacks->resume()ctx->save.callbacks->save_qemu()
libxl qemu record
...
libxl end-of-checkpoint record
/*If resotre side receives this record, input fd should be handed to libxc*/ctx->save.callbacks->save_qemu()returnsctx->save.callbacks->checkpoint()start_of_checkpoint()ctx->save.callbacks->suspend()
<memory>end_of_checkpoint()
End of Checkpoint record
goto 'loop of checkpointed stream'end:
END record
/*If resotre side receives this record, input fd should be handed to libxl*/In order to keep it simple, we can keep the current
ctx->save.callbacks->checkpoint()as it is, which do thesave_qemuthing, call
Remus devices commit callbacks and then decide whether we need a checkpoint. We
can also combine thectx->save.callbacks->resume()withctx->save.callbacks->checkpoint(), with only onecheckpoint()callback, we do
the following things:
- Call Remus devices preresume callbacks
- Resume the primary
- Save qemu records
- Call Remus devices commit callbacks
- Decide whether we need a checkpoint
Quoted 5 lines
Overall, there are 3 options for the save flow:
1. keep the current callbacks, renamepostcopy()toresume()
2. split thecheckpoint()callback tosave_qemu()andcheckpoint()
3. combine the currentpostcopy()andcheckpoint()Which one do you think is the best?
I have a 4th alternative in mind, but would like your feedback from my comments in this email first.
~Andrew
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Hongyang Yang
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Yang Hongyang
This patchset implement the Remus support for Migration v2 but without memory compressing.
[...]
Quoted 26 lines
Quoted 7 lines
<last iter of memory>
Quoted 2 lines
end_of_checkpoint()
Checkpoint recordQuoted 7 lines
ctx->save.callbacks->postcopy()
this callback should not be omitted, it do some necessary work before resume
primary (such as call Remus devices preresume callbacks to ensure the disk
data is consistent) and then resume the primary guest. I think this callback should be renamed toctx->save.callbacks->resume().That looks to be a useful cleanup (and answers one of my questions of what exactly postcopy was)
Quoted 7 lines
Quoted 3 lines
ctx->save.callbacks->checkpoint()
libxl qemu recordMaybe we should add another callback to send qemu record instead of using checkpoint callback. We can call it
ctx->save.callbacks->save_qemu()
Quoted 6 lines
This is another layering violation. libxc should not prescribe what libxl might or might not do. One example we are experimenting with in XenServer at the moment is support for multiple emulators attached to a single domain, which would necessitate two
LIBXL_EMULATORrecords to be sent per checkpoint. libxl might also want to send an updated json blob or such.
Ok, so we'd better not introduce save_qemu callback.
Quoted 12 lines
Quoted 11 lines
Then in checkpoint callback, we only call remus devices commit callbacks( which will release the network buffer etc...) then decide whether we need to
do another checkpoint or quit checkpointed stream.
With Remus, checkpoint callback only wait for 200ms(can be specified by -i)
then return.
With COLO, checkpoint callback will ask COLO proxy if we need to do a checkpoint, will return when COLO proxy module indicate a checkpoint is needed.
Quoted 3 lines
That sounds like COLO wants a
should_checkpoint()callback which separates the decision to make a checkpoint from the logic of implementing a checkpoint.
We use checkpoint callback to do should_checkpoint() thing currently. libxc will check the return value of checkpoint callback.
Quoted 80 lines
Quoted 80 lines
Quoted 6 lines
... libxl end-of-checkpoint record ctx->save.callbacks->checkpoint() returns
start_of_checkpoint()
ctx->save.callbacks->suspend()Quoted 5 lines
<memory>
end_of_checkpoint()
Checkpoint record
etc...Quoted 7 lines
This will eventually allow both libxc and libxl to send checkpoint data (and by the looks of it, remove the need for
postcopy()). With this libxc/remus work it is fine to useXG_LIBXL_HVM_COMPATto cover the current qemu situation, but I would prefer not to be also retrofitting libxc checkpoint records when doing the libxl/migv2 work.Does this look plausible in for Remus (and eventually COLO) support?
With comments above, I would suggest the save flow as below:
libxc writes: libxl writes:
live migration:
Image Header
Domain Headerstart_of_stream()start_of_checkpoint()
<live memory>ctx->save.callbacks->suspend()
<last iter memory>end_of_checkpoint()
if ( checkpointd )
End of Checkpoint record
/*If resotre side receives this record, input fd should be handed to
libxl*/
else
goto endloop of checkpointed stream:
ctx->save.callbacks->resume()ctx->save.callbacks->save_qemu()
libxl qemu record
...
libxl end-of-checkpoint record
/*If resotre side receives this record, input fd should be handed to libxc*/ctx->save.callbacks->save_qemu()returnsctx->save.callbacks->checkpoint()start_of_checkpoint()ctx->save.callbacks->suspend()
<memory>end_of_checkpoint()
End of Checkpoint record
goto 'loop of checkpointed stream'end:
END record
/*If resotre side receives this record, input fd should be handed to libxl*/In order to keep it simple, we can keep the current
ctx->save.callbacks->checkpoint()as it is, which do thesave_qemuthing, call
Remus devices commit callbacks and then decide whether we need a checkpoint. We
can also combine thectx->save.callbacks->resume()withctx->save.callbacks->checkpoint(), with only onecheckpoint()callback, we do
the following things:
- Call Remus devices preresume callbacks
- Resume the primary
- Save qemu records
- Call Remus devices commit callbacks
- Decide whether we need a checkpoint
Quoted 8 lines
Quoted 5 lines
Overall, there are 3 options for the save flow:
1. keep the current callbacks, renamepostcopy()toresume()
2. split thecheckpoint()callback tosave_qemu()andcheckpoint()
3. combine the currentpostcopy()andcheckpoint()Which one do you think is the best?I have a 4th alternative in mind, but would like your feedback from my comments in this email first.
So what's the 4th alternative?
Quoted 4 lines
~Andrew
.
Signature · 2 lines
Thanks, Yang.
Quoted 57 lines · Hongyang Yang
Quoted 6 lines · Andrew Cooper
Quoted 5 lines · Hongyang Yang
Quoted 4 lines · Andrew Cooper
Quoted 3 lines · Yang Hongyang
This patchset implement the Remus support for Migration v2 but without
memory compressing.[...]
Quoted 26 lines
Quoted 7 lines
<last iter of memory>
Quoted 2 lines
end_of_checkpoint()
Checkpoint recordQuoted 7 lines
ctx->save.callbacks->postcopy()
this callback should not be omitted, it do some necessary work before resume
primary (such as call Remus devices preresume callbacks to ensure the disk
data is consistent) and then resume the primary guest. I think this callback should be renamed toctx->save.callbacks->resume().That looks to be a useful cleanup (and answers one of my questions of what exactly postcopy was)
Quoted 7 lines
Quoted 3 lines
ctx->save.callbacks->checkpoint()
libxl qemu recordMaybe we should add another callback to send qemu record instead of using checkpoint callback. We can call it
ctx->save.callbacks->save_qemu()Quoted 6 lines
This is another layering violation. libxc should not prescribe what libxl might or might not do. One example we are experimenting with in XenServer at the moment is support for multiple emulators attached to a single domain, which would necessitate two
LIBXL_EMULATORrecords to be sent per checkpoint. libxl might also want to send an updated json blob or such.Ok, so we'd better not introduce
save_qemucallback.Quoted 13 lines
Quoted 12 lines
Then in checkpoint callback, we only call remus devices commit callbacks(
which will release the network buffer etc...) then decide whether we need to
do another checkpoint or quit checkpointed stream.
With Remus, checkpoint callback only wait for 200ms(can be specified by -i)
then return.
With COLO, checkpoint callback will ask COLO proxy if we need to do a checkpoint, will return when COLO proxy module indicate a checkpoint is needed.
Quoted 6 lines
Quoted 3 lines
That sounds like COLO wants a
should_checkpoint()callback which separates the decision to make a checkpoint from the logic of implementing a checkpoint.We use checkpoint callback to do
should_checkpoint()thing currently. libxc will check the return value of checkpoint callback.
But that causes a chicken & egg problem.
I am planning to use a CHECKPOINT record to synchronise the transfer of ownership of the FD between libxc and libxl. Therefore, a CHECKPOINT record must be in the stream ahead of the checkpoint() callback, as libxl will then write/read some records in itself.
As a result, the checkpoint() callback itself can't be used to gate whether a CHECKPOINT record is written by libxc.
Quoted 88 lines
Quoted 88 lines
Quoted 87 lines
Quoted 7 lines
... libxl end-of-checkpoint record ctx->save.callbacks->checkpoint() returns
start_of_checkpoint()
ctx->save.callbacks->suspend()Quoted 5 lines
<memory>
end_of_checkpoint()
Checkpoint record
etc...Quoted 8 lines
This will eventually allow both libxc and libxl to send checkpoint data
(and by the looks of it, remove the need forpostcopy()). With this libxc/remus work it is fine to useXG_LIBXL_HVM_COMPATto cover the current qemu situation, but I would prefer not to be also retrofitting libxc checkpoint records when doing the libxl/migv2 work.Does this look plausible in for Remus (and eventually COLO) support?
With comments above, I would suggest the save flow as below:
libxc writes: libxl writes:
live migration:
Image Header
Domain Headerstart_of_stream()start_of_checkpoint()
<live memory>ctx->save.callbacks->suspend()
<last iter memory>end_of_checkpoint()
if ( checkpointd )
End of Checkpoint record
/*If resotre side receives this record, input fd should be handed to
libxl*/
else
goto endloop of checkpointed stream:
ctx->save.callbacks->resume()ctx->save.callbacks->save_qemu()
libxl qemu record
...
libxl end-of-checkpoint record
/*If resotre side receives this record, input fd should be handed to libxc*/ctx->save.callbacks->save_qemu()returnsctx->save.callbacks->checkpoint()start_of_checkpoint()ctx->save.callbacks->suspend()
<memory>end_of_checkpoint()
End of Checkpoint record
goto 'loop of checkpointed stream'end:
END record
/*If resotre side receives this record, input fd should be handed to libxl*/In order to keep it simple, we can keep the current
ctx->save.callbacks->checkpoint()as it is, which do thesave_qemuthing, call
Remus devices commit callbacks and then decide whether we need a checkpoint. We
can also combine thectx->save.callbacks->resume()withctx->save.callbacks->checkpoint(), with only onecheckpoint()callback, we do
the following things:
- Call Remus devices preresume callbacks
- Resume the primary
- Save qemu records
- Call Remus devices commit callbacks
- Decide whether we need a checkpointOverall, there are 3 options for the save flow:
1. keep the current callbacks, renamepostcopy()toresume()
2. split thecheckpoint()callback tosave_qemu()andcheckpoint()
3. combine the currentpostcopy()andcheckpoint()Which one do you think is the best?
Quoted 4 lines
Quoted 2 lines
I have a 4th alternative in mind, but would like your feedback from my comments in this email first.
So what's the 4th alternative?
I have some corrections to my patch series based on David's feedback, and your comments. After that, it should hopefully be far easier to describe.
~Andrew
Quoted 65 lines · Andrew Cooper
Quoted 57 lines · Hongyang Yang
Quoted 6 lines · Andrew Cooper
Quoted 5 lines · Hongyang Yang
Quoted 4 lines · Andrew Cooper
Quoted 3 lines · Yang Hongyang
This patchset implement the Remus support for Migration v2 but without
memory compressing.[...]
Quoted 26 lines
Quoted 7 lines
<last iter of memory>
Quoted 2 lines
end_of_checkpoint()
Checkpoint recordQuoted 7 lines
ctx->save.callbacks->postcopy()
this callback should not be omitted, it do some necessary work before resume
primary (such as call Remus devices preresume callbacks to ensure the disk
data is consistent) and then resume the primary guest. I think this callback should be renamed toctx->save.callbacks->resume().That looks to be a useful cleanup (and answers one of my questions of what exactly postcopy was)
Quoted 7 lines
Quoted 3 lines
ctx->save.callbacks->checkpoint()
libxl qemu recordMaybe we should add another callback to send qemu record instead of using checkpoint callback. We can call it
ctx->save.callbacks->save_qemu()Quoted 6 lines
This is another layering violation. libxc should not prescribe what libxl might or might not do. One example we are experimenting with in XenServer at the moment is support for multiple emulators attached to a single domain, which would necessitate two
LIBXL_EMULATORrecords to be sent per checkpoint. libxl might also want to send an updated json blob or such.Ok, so we'd better not introduce
save_qemucallback.Quoted 13 lines
Quoted 12 lines
Then in checkpoint callback, we only call remus devices commit callbacks(
which will release the network buffer etc...) then decide whether we need to
do another checkpoint or quit checkpointed stream.
With Remus, checkpoint callback only wait for 200ms(can be specified by -i)
then return.
With COLO, checkpoint callback will ask COLO proxy if we need to do a checkpoint, will return when COLO proxy module indicate a checkpoint is needed.Quoted 6 lines
Quoted 3 lines
That sounds like COLO wants a
should_checkpoint()callback which separates the decision to make a checkpoint from the logic of implementing a checkpoint.We use checkpoint callback to do
should_checkpoint()thing currently. libxc will check the return value of checkpoint callback.
Quoted 6 lines
But that causes a chicken & egg problem.
I am planning to use a CHECKPOINT record to synchronise the transfer of ownership of the FD between libxc and libxl. Therefore, a CHECKPOINT record must be in the stream ahead of the
checkpoint()callback, as libxl will then write/read some records in itself.
The record name CHECKPOINT seems do not match the thing what you are planning to do, In this case I think END-OF-CHECKPOINT which represent the END of libxc side checkpoint is better, when libxc side checkpoint end, libxc should transfer the ownership of FD to libxl and let libxl to handle the following stream. libxl side can also use END-OF-CHECKPOINT as a sign to hand the ownership of the FD to libxc.
Quoted 3 lines
As a result, the
checkpoint()callback itself can't be used to gate whether a CHECKPOINT record is written by libxc.
I was wondering how you will do the FD transfer job?
Quoted 89 lines
Quoted 89 lines
Quoted 89 lines
Quoted 88 lines
Quoted 8 lines
... libxl end-of-checkpoint record ctx->save.callbacks->checkpoint() returns
start_of_checkpoint()
ctx->save.callbacks->suspend()Quoted 5 lines
<memory>
end_of_checkpoint()
Checkpoint record
etc...Quoted 8 lines
This will eventually allow both libxc and libxl to send checkpoint data
(and by the looks of it, remove the need forpostcopy()). With this libxc/remus work it is fine to useXG_LIBXL_HVM_COMPATto cover the current qemu situation, but I would prefer not to be also retrofitting libxc checkpoint records when doing the libxl/migv2 work.Does this look plausible in for Remus (and eventually COLO) support?
With comments above, I would suggest the save flow as below:
libxc writes: libxl writes:
live migration:
Image Header
Domain Headerstart_of_stream()start_of_checkpoint()
<live memory>ctx->save.callbacks->suspend()
<last iter memory>end_of_checkpoint()
if ( checkpointd )
End of Checkpoint record
/*If resotre side receives this record, input fd should be handed to
libxl*/
else
goto endloop of checkpointed stream:
ctx->save.callbacks->resume()ctx->save.callbacks->save_qemu()
libxl qemu record
...
libxl end-of-checkpoint record
/*If resotre side receives this record, input fd should be handed to libxc*/ctx->save.callbacks->save_qemu()returnsctx->save.callbacks->checkpoint()start_of_checkpoint()ctx->save.callbacks->suspend()
<memory>end_of_checkpoint()
End of Checkpoint record
goto 'loop of checkpointed stream'end:
END record
/*If resotre side receives this record, input fd should be handed to libxl*/In order to keep it simple, we can keep the current
ctx->save.callbacks->checkpoint()as it is, which do thesave_qemuthing, call
Remus devices commit callbacks and then decide whether we need a checkpoint. We
can also combine thectx->save.callbacks->resume()withctx->save.callbacks->checkpoint(), with only onecheckpoint()callback, we do
the following things:
- Call Remus devices preresume callbacks
- Resume the primary
- Save qemu records
- Call Remus devices commit callbacks
- Decide whether we need a checkpointOverall, there are 3 options for the save flow:
1. keep the current callbacks, renamepostcopy()toresume()
2. split thecheckpoint()callback tosave_qemu()andcheckpoint()
3. combine the currentpostcopy()andcheckpoint()Which one do you think is the best?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I have a 4th alternative in mind, but would like your feedback from my comments in this email first.
So what's the 4th alternative?
I have some corrections to my patch series based on David's feedback, and your comments. After that, it should hopefully be far easier to describe.
OK, I've addressed all comments on my series and wait for your series to continue :-)
Quoted 4 lines
~Andrew
.
Signature · 2 lines
Thanks, Yang.
Quoted 15 lines · Yang Hongyang
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
That sounds like COLO wants a
should_checkpoint()callback which separates the decision to make a checkpoint from the logic of implementing a checkpoint.We use checkpoint callback to do
should_checkpoint()thing currently. libxc will check the return value of checkpoint callback.Quoted 6 lines
But that causes a chicken & egg problem.
I am planning to use a CHECKPOINT record to synchronise the transfer of ownership of the FD between libxc and libxl. Therefore, a CHECKPOINT record must be in the stream ahead of the
checkpoint()callback, as libxl will then write/read some records in itself.
Quoted 7 lines
The record name CHECKPOINT seems do not match the thing what you are planning to do, In this case I think END-OF-CHECKPOINT which represent the
END of libxc side checkpoint is better, when libxc side checkpoint end, libxc should transfer the ownership of FD to libxl and let libxl to handle the following stream. libxl side can also use END-OF-CHECKPOINT as a sign to hand the ownership of the FD to libxc.
END_OF_CHECKPOINT implies the presence of START_OF_CHECKPOINT. The current spec for CHECKPOINT is more of a sentinal value between checkpoints of data.
Quoted 6 lines
Quoted 4 lines
As a result, the
checkpoint()callback itself can't be used to gate whether a CHECKPOINT record is written by libxc.I was wondering how you will do the FD transfer job?
The FD needs to be readable/writable in both the libxl and libxl-save-helper processes. The CHECKPOINT record simply signals a transfer of ownership.
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I have a 4th alternative in mind, but would like your feedback from my comments in this email first.
So what's the 4th alternative?
I have some corrections to my patch series based on David's feedback, and your comments. After that, it should hopefully be far easier to describe.
OK, I've addressed all comments on my series and wait for your series to continue :-)
Sent. Sorry for the delay (I also have some XenServer issues I am working on atm).
~Andrew
Quoted 48 lines · Andrew Cooper
Quoted 15 lines · Yang Hongyang
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
That sounds like COLO wants a
should_checkpoint()callback which separates the decision to make a checkpoint from the logic of implementing a checkpoint.We use checkpoint callback to do
should_checkpoint()thing currently. libxc will check the return value of checkpoint callback.Quoted 6 lines
But that causes a chicken & egg problem.
I am planning to use a CHECKPOINT record to synchronise the transfer of ownership of the FD between libxc and libxl. Therefore, a CHECKPOINT record must be in the stream ahead of the
checkpoint()callback, as libxl will then write/read some records in itself.Quoted 7 lines
The record name CHECKPOINT seems do not match the thing what you are planning to do, In this case I think END-OF-CHECKPOINT which represent the
END of libxc side checkpoint is better, when libxc side checkpoint end, libxc should transfer the ownership of FD to libxl and let libxl to handle the following stream. libxl side can also use END-OF-CHECKPOINT as a sign to hand the ownership of the FD to libxc.
END_OF_CHECKPOINTimplies the presence ofSTART_OF_CHECKPOINT. The current spec for CHECKPOINT is more of a sentinal value between checkpoints of data.Quoted 6 lines
Quoted 4 lines
As a result, the
checkpoint()callback itself can't be used to gate whether a CHECKPOINT record is written by libxc.I was wondering how you will do the FD transfer job?
The FD needs to be readable/writable in both the libxl and libxl-save-helper processes. The CHECKPOINT record simply signals a transfer of ownership.
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I have a 4th alternative in mind, but would like your feedback from my comments in this email first.
So what's the 4th alternative?
I have some corrections to my patch series based on David's feedback, and your comments. After that, it should hopefully be far easier to describe.
Quoted 5 lines
Quoted 2 lines
OK, I've addressed all comments on my series and wait for your series to continue :-)
Sent. Sorry for the delay (I also have some XenServer issues I am working on atm).
Never mind, and thank you very much for the quick turnaround! The design looks more clear now, It really helps me a lot!
Quoted 4 lines
~Andrew
.
Signature · 2 lines
Thanks, Yang.