how handle domU checkpoints properly
During 'xl save -c|-p' the monitoring xl process will exit because it gets a LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN/LIBXL_SHUTDOWN_REASON_SUSPEND event.
While this is correct for plain 'xl save' usage, the result is that other events such a shutdown/reboot/etc are not handled anymore for the domU. In case of shutdown the domU must be destroyed manually.
Add a flag to indicate the domU should remain active. Continue the monitoring loop, make sure further events are received, wait until the shutdown state changes.
This is incomplete because repeated checkpoint or pause operations are not handled.
Any idea how to actually implemented 'xl save -p' and 'xl save -c'?
Thanks,
Olaf
--- tools/xl/Makefile | 3 ++- tools/xl/xl.h | 1 + tools/xl/xl_saverestore.c | 15 ++++++++++++ tools/xl/xl_vmcontrol.c | 48 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-)
tools/xl/Makefile +2 -1
@@ -26,6 +26,7 @@ XL_OBJS += xl_vmcontrol.o xl_saverestore.o xl_migrate.o XL_OBJS += xl_vdispl.o xl_vsnd.o xl_vkb.o $(XL_OBJS): CFLAGS += $(CFLAGS_libxentoollog) +$(XL_OBJS): CFLAGS += $(CFLAGS_libxenstore) $(XL_OBJS): CFLAGS += $(CFLAGS_XL) $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it.
@@ -38,7 +39,7 @@ $(XL_OBJS): _paths.h all: xl xl: $(XL_OBJS) - $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxenutil) $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -lyajl $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxenutil) $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) -lyajl $(APPEND_LDFLAGS) .PHONY: install install: all
tools/xl/xl.h +1 -0
@@ -300,6 +300,7 @@ typedef enum {DOMAIN_RESTART_SOFT_RESET ,/* Soft reset should be performed */ } domain_restart_type; +#define XL_SAVE_PAUSE_CHECKPOINT "xl-save-pc"extern void printf_info_sexp (int domid,libxl_domain_config *d_config,FILE *fh); extern void apply_global_affinity_masks(libxl_domain_type type, libxl_bitmap *vcpu_affinity_array,
tools/xl/xl_saverestore.c +15 -0
@@ -21,6 +21,7 @@#include <time.h> #include <unistd.h> +#include <xenstore.h> #include <libxl.h> #include <libxl_utils.h> #include <libxlutil.h>
@@ -127,6 +128,8 @@ static int save_domain(uint32_t domid, int preserve_domid, const char *filename, int checkpoint, int leavepaused, const char *override_config_file) { + struct xs_handle *xsh = NULL; +char path[80 ];int fd;uint8_t *config_data;int config_len;
@@ -144,12 +147,24 @@ static int save_domain(uint32_t domid, int preserve_domid,fprintf (stderr,"Failed to open temp file %s for writing\n" , filename);exit (EXIT_FAILURE ); } +if (leavepaused || checkpoint) + { +snprintf (path,sizeof (path),"/libxl/%u/" XL_SAVE_PAUSE_CHECKPOINT , domid); + xsh =xs_open (0 ); +if (xsh) +xs_write (xsh,XBT_NULL , path, leavepaused ?"p" :"c" ,1 ); + }save_domain_core_writeconfig (fd, filename, config_data, config_len);int rc =libxl_domain_suspend (ctx, domid, fd, &props,NULL );close (fd); +if (xsh) { +xs_rm (xsh,XBT_NULL , path); +xs_close (xsh); + } +if (rc <0 ) {fprintf (stderr,"Failed to save domain, resuming domain\n" );libxl_domain_resume (ctx, domid,1 ,0 );
tools/xl/xl_vmcontrol.c +48 -0
80 lines not on this page · raw message
Am Wed, 7 Jul 2021 15:34:27 +0200
schrieb Olaf Hering <[email protected]>:
Quoted 2 lines
This is incomplete because repeated checkpoint or pause operations are not handled.
Apparently they are, it is just not reported because there is no event when the domU resumes execution.
Olaf