From: Ian Murray Subject: Re: [PATCH] xl save but leave domain paused Date: Wed, 3 Jul 2013 09:08:43 +0100 (BST) Message-ID: <1372838923.87269.YahooMailNeo@web171302.mail.ir2.yahoo.com> References: <1372808048-3412-1-git-send-email-murrayie@yahoo.co.uk> <51D36883.7080602@citrix.com> Reply-To: Ian Murray Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <51D36883.7080602@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: "Ian.Campbell@citrix.com" , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org >________________________________ > From: Andrew Cooper >To: Ian Murray = >Cc: Ian.Campbell@citrix.com; xen-devel@lists.xen.org = >Sent: Wednesday, 3 July 2013, 0:55 >Subject: Re: [Xen-devel] [PATCH] xl save but leave domain paused > = > Thanks for your feedback. >On 03/07/2013 00:34, Ian Murray wrote: >> New feature to allow xl save to leave a domain paused after its >> memory has been saved. This is to allow disk snapshots of domU >> to be taken that exactly correspond to the memory state at save time. >> Once the snapshot(s) have been taken or whatever, the domain can be >> unpaused in the usual manner. >> >> Usage: >>=A0=A0=A0xl save -p >> >> Signed-off-by: Ian Murray >> --- >>=A0 tools/libxl/xl_cmdimpl.c=A0 |=A0=A0=A016 ++++++++++++---- >>=A0 tools/libxl/xl_cmdtable.c |=A0 =A0 4 +++- >>=A0 2 files changed, 15 insertions(+), 5 deletions(-) >> >> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c >> index 8a478ba..670620b 100644 >> --- a/tools/libxl/xl_cmdimpl.c >> +++ b/tools/libxl/xl_cmdimpl.c >> @@ -3266,7 +3266,7 @@ static void save_domain_core_writeconfig(int fd, c= onst char *source, >>=A0 } >>=A0 = >>=A0 static int save_domain(uint32_t domid, const char *filename, int chec= kpoint, >> -=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *override_config_file) >> +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int leavepaused, const char *override_c= onfig_file) > >#include and use bool rather than int.=A0 Also, re-align the >second line arguments which was misaligned when the function was made stat= ic I used an int for consistency, as this was how the checkpoint was done. I c= an change it if you like, but it is going to be inconsistent with checkpoin= t. I could do checkpoint as well but that would be fixing code that isn't b= roken, which is a bit out of scope and makes the patch footprint bigger. As for the misalignment, is there a style guide or should I just look round= some more? I just re-used what was there, which wasn't helpful given it wa= s already broke. I don't want to copy any more OP's=A0 mis-alignment mistak= es. :) > >>=A0 { >>=A0 =A0 =A0 int fd; >>=A0 =A0 =A0 uint8_t *config_data; >> @@ -3293,8 +3293,12 @@ static int save_domain(uint32_t domid, const char= *filename, int checkpoint, >>=A0 =A0 =A0 if (rc < 0) >>=A0 =A0 =A0 =A0 =A0 fprintf(stderr, "Failed to save domain, resuming doma= in\n"); >>=A0 = >> -=A0 =A0 if (checkpoint || rc < 0) >> +=A0 =A0 if (leavepaused || checkpoint || rc < 0) { >> +=A0 =A0 =A0 =A0 if (leavepaused && !(rc < 0)) { >> +=A0 =A0 =A0 =A0 =A0 =A0 libxl_domain_pause(ctx, domid); >> +=A0 =A0 =A0 =A0 } >>=A0 =A0 =A0 =A0 =A0 libxl_domain_resume(ctx, domid, 1, 0); >> +=A0 =A0 } > >This logic is quite opaque.=A0 It would be clearer to have > >if (leavepaused && rc =3D=3D 0) >=A0 pause() >else if (checkpoint ... In itself, this isn't correct logic because the resume has to occur for bot= h checkpointing or pausing. You would end up with if (leavepaused && ...) { =A0=A0=A0 pause() =A0=A0=A0 resume() } else if (checkpoint && ...) { =A0=A0=A0 resume() = } Is this preferable? I tend to avoid repeating code if I can help it esp in = if statements, although perhaps it does read easier. I used the !(rc<0) because I didn't want to make assumptions about the poss= ible value of rc, given the rest of the code uses rc<0 > >>=A0 =A0 =A0 else >>=A0 =A0 =A0 =A0 =A0 libxl_domain_destroy(ctx, domid, 0); >>=A0 = >> @@ -3838,12 +3842,16 @@ int main_save(int argc, char **argv) >>=A0 =A0 =A0 const char *filename; >>=A0 =A0 =A0 const char *config_filename =3D NULL; >>=A0 =A0 =A0 int checkpoint =3D 0; >> +=A0 =A0 int leavepaused =3D 0; >>=A0 =A0 =A0 int opt; >>=A0 = >> -=A0 =A0 SWITCH_FOREACH_OPT(opt, "c", NULL, "save", 2) { >> +=A0 =A0 SWITCH_FOREACH_OPT(opt, "cp", NULL, "save", 2) { >>=A0 =A0 =A0 case 'c': >>=A0 =A0 =A0 =A0 =A0 checkpoint =3D 1; >>=A0 =A0 =A0 =A0 =A0 break; >> +=A0 =A0 case 'p': >> +=A0 =A0 =A0 =A0 leavepaused =3D 1; >> +=A0 =A0 =A0 =A0 break; >>=A0 =A0 =A0 } >>=A0 = >>=A0 =A0 =A0 if (argc-optind > 3) { >> @@ -3856,7 +3864,7 @@ int main_save(int argc, char **argv) >>=A0 =A0 =A0 if ( argc - optind >=3D 3 ) >>=A0 =A0 =A0 =A0 =A0 config_filename =3D argv[optind + 2]; >>=A0 = >> -=A0 =A0 save_domain(domid, filename, checkpoint, config_filename); >> +=A0 =A0 save_domain(domid, filename, checkpoint, leavepaused, config_fi= lename); >>=A0 =A0 =A0 return 0; >>=A0 } >>=A0 = >> diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c >> index 44b42b0..c429cea 100644 >> --- a/tools/libxl/xl_cmdtable.c >> +++ b/tools/libxl/xl_cmdtable.c >> @@ -142,7 +142,9 @@ struct cmd_spec cmd_table[] =3D { >>=A0 =A0 =A0 =A0 "Save a domain state to restore later", >>=A0 =A0 =A0 =A0 "[options] []", >>=A0 =A0 =A0 =A0 "-h=A0 Print this help.\n" >> -=A0 =A0 =A0 "-c=A0 Leave domain running after creating the snapshot." >> +=A0 =A0 =A0 "-c=A0 Leave domain running after creating the snapshot.\n" >> +=A0 =A0 =A0 "-p=A0 Leave domain paused after creating the snapshot." >> + > >Needless whitespace Sure. Slipped in by accident. > >>=A0 =A0 =A0 }, >>=A0 =A0 =A0 { "migrate", >>=A0 =A0 =A0 =A0 &main_migrate, 0, 1, > >Can you also patch the manpage, docs/man/xl.pod.1 to the same effect Yeah, I forgot about that. Thanks. Thanks again for your response. > >~Andrew > >_______________________________________________ >Xen-devel mailing list >Xen-devel@lists.xen.org >http://lists.xen.org/xen-devel > > >