: Implement xl dump-core
PATCH 1/1 : Implement xl dump-core
Implements dump-core command which is similar to xm dump-core except that it requires an additional argument which is the target filename.
libxl.c | 7 +++++++ libxl.h | 2 ++ xl.h | 1 + xl_cmdimpl.c | 18 ++++++++++++++++++ xl_cmdtable.c | 5 +++++ 6 files changed, 35 insertions(+), 2 deletions(-)
tools/libxl/libxl.c +7 -0
@@ -523,6 +523,13 @@return 0 ; } +int libxl_domain_core_dump (struct libxl_ctx *ctx,uint32_t domid,const char *filename) +{ +if (xc_domain_dumpcore (ctx->xch, domid, filename) ) +return ERROR_FAIL ; +return 0 ; +} +int libxl_domain_unpause (struct libxl_ctx *ctx,uint32_t domid) {char *path;
tools/libxl/libxl.h +2 -0
@@ -395,6 +395,8 @@int libxl_domain_pause (struct libxl_ctx *ctx,uint32_t domid);int libxl_domain_unpause (struct libxl_ctx *ctx,uint32_t domid); +int libxl_domain_core_dump (struct libxl_ctx *ctx,uint32_t domid,const char *filename); +int libxl_domain_setmaxmem (struct libxl_ctx *ctx,uint32_t domid,uint32_t target_memkb);int libxl_set_memory_target (struct libxl_ctx *ctx,uint32_t domid,uint32_t target_memkb,int enforce);
tools/libxl/xl.h +1 -0
@@ -37,6 +37,7 @@int main_migrate_receive (int argc,char **argv);int main_save (int argc,char **argv);int main_migrate (int argc,char **argv); +int main_dump_core (int argc,char **argv);int main_pause (int argc,char **argv);int main_unpause (int argc,char **argv);int main_destroy (int argc,char **argv);
tools/libxl/xl_cmdimpl.c +18 -0
@@ -2262,6 +2262,14 @@exit (-ERROR_BADFAIL ); } +static void core_dump_domain (const char *domain_spec,const char *filename) +{ +int rc; +find_domain (domain_spec); + rc=libxl_domain_core_dump (&ctx, domid, filename); +if (rc) {fprintf (stderr,"core dump failed (rc=%d)\n." ,rc);exit (-1 ); } +} +static void migrate_receive (int debug,int daemonize) {int rc, rc2;
@@ -2531,6 +2539,16 @@exit (0 ); } +int main_dump_core (int argc,char **argv) +{ +if ( argc-optind <2 ) { +help ("dump-core" ); +exit (2 ); + } +core_dump_domain (argv[optind], argv[optind +1 ]); +exit (0 ); +} +int main_pause (int argc,char **argv) {int opt;
tools/libxl/xl_cmdtable.c +5 -0
@@ -102,6 +102,11 @@"-e Do not wait in the background (on <host>) for the death\n" " of the domain." }, + { "dump-core", + &main_dump_core, +"Core dump a domain" , +"<Domain> <filename>" + }, { "restore", &main_restore, "Restore a domain from a saved state",
Gianni Tedesco writes ("[Xen-devel] [PATCH]: Implement xl dump-core"):
Quoted 1 line
+int
libxl_domain_core_dump(struct libxl_ctx *ctx, uint32_t domid, const char *filename)
Not that there's anything wrong with your patch, but why do these calls (by which I mean to include the libxc call) take a filename rather than an fd ?
Ian.
Quoted 6 lines · Ian Jackson
Gianni Tedesco writes ("[Xen-devel] [PATCH]: Implement xl dump-core"):
Quoted 1 line
+int
libxl_domain_core_dump(struct libxl_ctx *ctx, uint32_t domid, const char *filename)Not that there's anything wrong with your patch, but why do these calls (by which I mean to include the libxc call) take a filename rather than an fd ?
It's a mystery to me too. Although in the core dump case there is a separate call, xc_domain_dumpcore_via_callback, which takes a callback function through which such functionality may be implemented.
Gianni