libxl: add a dummy ao_how to libxl_domain_core_dump
PATCH 1/1 libxl: add a dummy ao_how to libxl_domain_core_dump
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1334587303 -3600
# Node ID a20c43492fbff622aa9746404981628b498e0711 # Parent f95c8fe372d35fdf8937750e9271ea76ff991488
libxl: add a dummy ao_how to libxl_domain_core_dump
Although this function is not currently slow it may become so in the future (this also depends somewhat on the size of the guest). Therefore arrange for it to take an ao_how which it completes immediately. This will allow us to make it asynchronous in the future without breaking API compatibility.
---
Requires Ian Jackson's "libxl: Allow AO_GC and EGC_GC even if not used"
tools/libxl/libxl.c +10 -4
@@ -627,16 +627,22 @@ int libxl_domain_pause(libxl_ctx *ctx, u }int libxl_domain_core_dump (libxl_ctx *ctx,uint32_t domid, -const char *filename) +const char *filename, +const libxl_asyncop_how *ao_how) { -int ret; +AO_CREATE (ctx, domid, ao_how); +int ret, rc =0 ; + ret =xc_domain_dumpcore (ctx->xch, domid, filename);if (ret<0 ) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"core dumping domain %d to %s" , domid, filename); -return ERROR_FAIL ; + rc =ERROR_FAIL ; } -return 0 ; + +libxl__ao_complete (egc, ao, rc); + +return AO_INPROGRESS ; }int libxl_domain_unpause (libxl_ctx *ctx,uint32_t domid)
tools/libxl/libxl.h +3 -1
@@ -509,7 +509,9 @@ int libxl_domain_rename(libxl_ctx *ctx,int libxl_domain_pause (libxl_ctx *ctx,uint32_t domid);int libxl_domain_unpause (libxl_ctx *ctx,uint32_t domid); -int libxl_domain_core_dump (libxl_ctx *ctx,uint32_t domid,const char *filename); +int libxl_domain_core_dump (libxl_ctx *ctx,uint32_t domid, +const char *filename, +const libxl_asyncop_how *ao_how);int libxl_domain_setmaxmem (libxl_ctx *ctx,uint32_t domid,uint32_t target_memkb);int libxl_set_memory_target (libxl_ctx *ctx,uint32_t domid,int32_t target_memkb,int relative,int enforce);
tools/libxl/xl_cmdimpl.c +2 -2
@@ -1276,7 +1276,7 @@ static int handle_domain_death(libxl_ctxLOG ("failed to construct core dump path" ); }else {LOG ("dumping core to %s" , corefile); - rc=libxl_domain_core_dump (ctx, domid, corefile); + rc=libxl_domain_core_dump (ctx, domid, corefile,NULL );if (rc)LOG ("core dump failed (rc=%d)." , rc); }/* No point crying over spilled milk, continue on failure. */
@@ -2893,7 +2893,7 @@ static void core_dump_domain(const char {int rc;find_domain (domain_spec); - rc=libxl_domain_core_dump (ctx, domid, filename); + rc=libxl_domain_core_dump (ctx, domid, filename,NULL );if (rc) {fprintf (stderr,"core dump failed (rc=%d)\n" ,rc);exit (-1 ); } }
Ian Campbell writes ("[PATCH] libxl: add a dummy ao_how to libxl_domain_core_dump"):
Quoted 6 lines
libxl: add a dummy
ao_howtolibxl_domain_core_dumpAlthough this function is not currently slow it may become so in the future (this also depends somewhat on the size of the guest). Therefore arrange for it to take an
ao_howwhich it completes immediately. This will allow us to make it asynchronous in the future without breaking API compatibility.
...
tools/libxl/libxl.c int libxl_domain_pause(libxl_ctx *ctx, u · line 640
Quoted 6 lines
ret = xc_domain_dumpcore(ctx->xch, domid, filename); if (ret<0) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "core dumping domain %d to %s", domid, filename);tools/libxl/libxl.c +1
-1-return ERROR_FAIL ; + rc =ERROR_FAIL ;
While you're doing that, did you want to change it to use "goto out" ?
tools/libxl/libxl.c int libxl_domain_pause(libxl_ctx *ctx, u · line 645
Quoted 6 lines
}tools/libxl/libxl.c +4
-1-return 0 ; + +libxl__ao_complete (egc, ao, rc); + +return AO_INPROGRESS ;
Ian.
Quoted 8 lines · Ian Jackson
Ian Campbell writes ("[PATCH] libxl: add a dummy
ao_howtolibxl_domain_core_dump"):Quoted 6 lines
libxl: add a dummy
ao_howtolibxl_domain_core_dumpAlthough this function is not currently slow it may become so in the future (this also depends somewhat on the size of the guest). Therefore arrange for it to take an
ao_howwhich it completes immediately. This will allow us to make it asynchronous in the future without breaking API compatibility....
Quoted 8 lines
tools/libxl/libxl.c int libxl_domain_pause(libxl_ctx *ctx, u · line 640
Quoted 6 lines
ret = xc_domain_dumpcore(ctx->xch, domid, filename); if (ret<0) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "core dumping domain %d to %s", domid, filename);tools/libxl/libxl.c +1
-1-return ERROR_FAIL ; + rc =ERROR_FAIL ;While you're doing that, did you want to change it to use "goto out" ?
wouldn't the "out:" be immediately after this immediately following closing brace?
Quoted 8 lines
tools/libxl/libxl.c int libxl_domain_pause(libxl_ctx *ctx, u · line 645
Quoted 6 lines
}tools/libxl/libxl.c +4
-1-return 0 ; + +libxl__ao_complete (egc, ao, rc); + +return AO_INPROGRESS ;Ian.
Ian Campbell writes ("Re: [PATCH] libxl: add a dummy ao_how to libxl_domain_core_dump"):
Quoted 10 lines · Ian Jackson
Quoted 6 lines
Ian Campbell writes ("[PATCH] libxl: add a dummy
ao_howtolibxl_domain_core_dump"):tools/libxl/libxl.c int libxl_domain_pause(libxl_ctx *ctx, u · line 640
Quoted 3 lines
libxl: add a dummy
ao_howtolibxl_domain_core_dumptools/libxl/libxl.c +1
-1-return ERROR_FAIL ; + rc =ERROR_FAIL ;While you're doing that, did you want to change it to use "goto out" ?
wouldn't the "out:" be immediately after this immediately following closing brace?
I think it would look like this:
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ rc =
ERROR_FAIL;
goto out;
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
}(quoted diff) +1
-1- return 0; +
rc = 0;
out:Quoted 3 lines
Quoted 3 lines
tools/libxl/libxl.c int libxl_domain_pause(libxl_ctx *ctx, u · line 645
Quoted 3 lines
tools/libxl/libxl.c +3
-0+libxl__ao_complete (egc, ao, rc); + +return AO_INPROGRESS ;
And removing the initialisation of rc at the top of the function.
This pattern is the usual one when we have an operation which should fail, and stop executing, when any sub-operations fail.
Setting rc=0 at the top and setting it to ERROR_FAIL as we go, without an error exit, is what we do if we want to blunder on after errors (eg the remove files patch).
Ian.
Quoted 7 lines · Ian Jackson
Ian Campbell writes ("Re: [PATCH] libxl: add a dummy
ao_howtolibxl_domain_core_dump"):Quoted 6 lines · Ian Jackson
Quoted 5 lines
Ian Campbell writes ("[PATCH] libxl: add a dummy
ao_howtolibxl_domain_core_dump"):Quoted 3 lines
libxl: add a dummy
ao_howtolibxl_domain_core_dump(quoted diff) +1
-1- return ERROR_FAIL; + rc = ERROR_FAIL;
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
While you're doing that, did you want to change it to use "goto out" ?
wouldn't the "out:" be immediately after this immediately following closing brace?
I think it would look like this:
Make sense.
8<--------------------------------
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1334595420 -3600
# Node ID 8d92d1f34921c8675d85c74aa36e319c9451f68f # Parent f95c8fe372d35fdf8937750e9271ea76ff991488
libxl: add a dummy ao_how to libxl_domain_core_dump
Although this function is not currently slow it may become so in the future (this also depends somewhat on the size of the guest). Therefore arrange for it to take an ao_how which it completes immediately. This will allow us to make it asynchronous in the future without breaking API compatibility.
---
Requires Ian Jackson's "libxl: Allow AO_GC and EGC_GC even if not used"
tools/libxl/libxl.c +14 -4
@@ -627,16 +627,26 @@ int libxl_domain_pause(libxl_ctx *ctx, u }int libxl_domain_core_dump (libxl_ctx *ctx,uint32_t domid, -const char *filename) +const char *filename, +const libxl_asyncop_how *ao_how) { -int ret; +AO_CREATE (ctx, domid, ao_how); +int ret, rc; + ret =xc_domain_dumpcore (ctx->xch, domid, filename);if (ret<0 ) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"core dumping domain %d to %s" , domid, filename); -return ERROR_FAIL ; + rc =ERROR_FAIL ; + goto out; } -return 0 ; + + rc =0 ; +out: + +libxl__ao_complete (egc, ao, rc); + +return AO_INPROGRESS ; }int libxl_domain_unpause (libxl_ctx *ctx,uint32_t domid)
tools/libxl/libxl.h +3 -1
@@ -509,7 +509,9 @@ int libxl_domain_rename(libxl_ctx *ctx,int libxl_domain_pause (libxl_ctx *ctx,uint32_t domid);int libxl_domain_unpause (libxl_ctx *ctx,uint32_t domid); -int libxl_domain_core_dump (libxl_ctx *ctx,uint32_t domid,const char *filename); +int libxl_domain_core_dump (libxl_ctx *ctx,uint32_t domid, +const char *filename, +const libxl_asyncop_how *ao_how);int libxl_domain_setmaxmem (libxl_ctx *ctx,uint32_t domid,uint32_t target_memkb);int libxl_set_memory_target (libxl_ctx *ctx,uint32_t domid,int32_t target_memkb,int relative,int enforce);
tools/libxl/xl_cmdimpl.c +2 -2
@@ -1276,7 +1276,7 @@ static int handle_domain_death(libxl_ctxLOG ("failed to construct core dump path" ); }else {LOG ("dumping core to %s" , corefile); - rc=libxl_domain_core_dump (ctx, domid, corefile); + rc=libxl_domain_core_dump (ctx, domid, corefile,NULL );if (rc)LOG ("core dump failed (rc=%d)." , rc); }/* No point crying over spilled milk, continue on failure. */
@@ -2893,7 +2893,7 @@ static void core_dump_domain(const char {int rc;find_domain (domain_spec); - rc=libxl_domain_core_dump (ctx, domid, filename); + rc=libxl_domain_core_dump (ctx, domid, filename,NULL );if (rc) {fprintf (stderr,"core dump failed (rc=%d)\n" ,rc);exit (-1 ); } }
Ian Campbell writes ("Re: [Xen-devel] [PATCH] libxl: add a dummy ao_how to libxl_domain_core_dump"):
Quoted 1 line
libxl: add a dummy
ao_howtolibxl_domain_core_dump
Unfortunately this depends on my __attribute__((unused)) patch which isn't in tree yet...
Ian.
Quoted 5 lines · Ian Jackson
Ian Campbell writes ("Re: [Xen-devel] [PATCH] libxl: add a dummy
ao_howtolibxl_domain_core_dump"):Quoted 1 line
libxl: add a dummy
ao_howtolibxl_domain_core_dumpUnfortunately this depends on my __attribute__((unused)) patch which isn't in tree yet...
Right, I said just below the commit message:
Quoted 2 lines
Requires Ian Jackson's "libxl: Allow
AO_GCandEGC_GCeven if not used"
;-)
Ian Jackson
Acked-byIan Campbell writes ("Re: [Xen-devel] [PATCH] libxl: add a dummy ao_how to libxl_domain_core_dump"):
Quoted 1 line
libxl: add a dummy
ao_howtolibxl_domain_core_dump
I have added this to my child process handling series. It will go in with the rest of those.
Ian.