Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:olh:xen-unstable
xen
xen.sr-LIBXL_HAVE_DOMAIN_SUSPEND_PROPS.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xen.sr-LIBXL_HAVE_DOMAIN_SUSPEND_PROPS.patch of Package xen
From: Olaf Hering <olaf@aepfle.de> Date: Thu, 7 Jan 2021 15:58:30 +0100 Subject: sr LIBXL_HAVE_DOMAIN_SUSPEND_PROPS tools: adjust libxl_domain_suspend to receive a struct props Upcoming changes will pass more knobs down to xc_domain_save. Adjust the libxl_domain_suspend API to allow easy adding of additional knobs. No change in behavior intented. Signed-off-by: Olaf Hering <olaf@aepfle.de> Acked-by: Christian Lindig <christian.lindig@citrix.com> --- tools/include/libxl.h | 26 ++++++++- tools/libs/light/libxl_domain.c | 7 ++- tools/xl/xl_migrate.c | 9 ++- tools/xl/xl_saverestore.c | 3 +- 4 files changed, 35 insertions(+), 10 deletions(-) --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -1757,30 +1757,50 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300 static inline int libxl_retrieve_domain_configuration_0x041200( libxl_ctx *ctx, uint32_t domid, libxl_domain_config *d_config) { return libxl_retrieve_domain_configuration(ctx, domid, d_config, NULL); } #define libxl_retrieve_domain_configuration \ libxl_retrieve_domain_configuration_0x041200 #endif +/* + * LIBXL_HAVE_DOMAIN_SUSPEND_PROPS indicates that the + * libxl_domain_suspend_props() function takes a props struct. + */ +#define LIBXL_HAVE_DOMAIN_SUSPEND_PROPS 1 + +typedef struct { + uint32_t flags; /* LIBXL_SUSPEND_* */ +} libxl_domain_suspend_props; +#define LIBXL_SUSPEND_DEBUG 1 +#define LIBXL_SUSPEND_LIVE 2 + int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, - int flags, /* LIBXL_SUSPEND_* */ + libxl_domain_suspend_props *props, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; -#define LIBXL_SUSPEND_DEBUG 1 -#define LIBXL_SUSPEND_LIVE 2 +#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041600 +static inline int libxl_domain_suspend_0x041500(libxl_ctx *ctx, uint32_t domid, + int fd, int flags, /* LIBXL_SUSPEND_* */ + const libxl_asyncop_how *ao_how) +{ + libxl_domain_suspend_props props = { .flags = flags, }; + return libxl_domain_suspend(ctx, domid, fd, &props, ao_how); +} +#define libxl_domain_suspend libxl_domain_suspend_0x041500 +#endif /* * Only suspend domain, do not save its state to file, do not destroy it. * Suspended domain can be resumed with libxl_domain_resume() */ int libxl_domain_suspend_only(libxl_ctx *ctx, uint32_t domid, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; /* @param suspend_cancel [from xenctrl.h:xc_domain_resume( @param fast )] * If this parameter is true, use co-operative resume. The guest * must support this. --- a/tools/libs/light/libxl_domain.c +++ b/tools/libs/light/libxl_domain.c @@ -497,47 +497,48 @@ static void domain_suspend_cb(libxl__egc *egc, { STATE_AO_GC(dss->ao); int flrc; flrc = libxl__fd_flags_restore(gc, dss->fd, dss->fdfl); /* If suspend has failed already then report that error not this one. */ if (flrc && !rc) rc = flrc; libxl__ao_complete(egc,ao,rc); } -int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags, +int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, + libxl_domain_suspend_props *props, const libxl_asyncop_how *ao_how) { AO_CREATE(ctx, domid, ao_how); int rc; libxl_domain_type type = libxl__domain_type(gc, domid); if (type == LIBXL_DOMAIN_TYPE_INVALID) { rc = ERROR_FAIL; goto out_err; } libxl__domain_save_state *dss; GCNEW(dss); dss->ao = ao; dss->callback = domain_suspend_cb; dss->domid = domid; dss->fd = fd; dss->type = type; - dss->live = flags & LIBXL_SUSPEND_LIVE; - dss->debug = flags & LIBXL_SUSPEND_DEBUG; + dss->live = props->flags & LIBXL_SUSPEND_LIVE; + dss->debug = props->flags & LIBXL_SUSPEND_DEBUG; dss->checkpointed_stream = LIBXL_CHECKPOINTED_STREAM_NONE; rc = libxl__fd_flags_modify_save(gc, dss->fd, ~(O_NONBLOCK|O_NDELAY), 0, &dss->fdfl); if (rc < 0) goto out_err; libxl__domain_save(egc, dss); return AO_INPROGRESS; out_err: return AO_CREATE_FAIL(rc); --- a/tools/xl/xl_migrate.c +++ b/tools/xl/xl_migrate.c @@ -177,45 +177,48 @@ static void migrate_do_preamble(int send_fd, int recv_fd, pid_t child, } static void migrate_domain(uint32_t domid, int preserve_domid, const char *rune, int debug, const char *override_config_file) { pid_t child = -1; int rc; int send_fd = -1, recv_fd = -1; char *away_domname; char rc_buf; uint8_t *config_data; - int config_len, flags = LIBXL_SUSPEND_LIVE; + int config_len; + libxl_domain_suspend_props props = { + .flags = LIBXL_SUSPEND_LIVE, + }; save_domain_core_begin(domid, preserve_domid, override_config_file, &config_data, &config_len); if (!config_len) { fprintf(stderr, "No config file stored for running domain and " "none supplied - cannot migrate.\n"); exit(EXIT_FAILURE); } child = create_migration_child(rune, &send_fd, &recv_fd); migrate_do_preamble(send_fd, recv_fd, child, config_data, config_len, rune); xtl_stdiostream_adjust_flags(logger, XTL_STDIOSTREAM_HIDE_PROGRESS, 0); if (debug) - flags |= LIBXL_SUSPEND_DEBUG; - rc = libxl_domain_suspend(ctx, domid, send_fd, flags, NULL); + props.flags |= LIBXL_SUSPEND_DEBUG; + rc = libxl_domain_suspend(ctx, domid, send_fd, &props, NULL); if (rc) { fprintf(stderr, "migration sender: libxl_domain_suspend failed" " (rc=%d)\n", rc); if (rc == ERROR_GUEST_TIMEDOUT) goto failed_suspend; else goto failed_resume; } //fprintf(stderr, "migration sender: Transfer complete.\n"); // Should only be printed when debugging as it's a bit messy with // progress indication. --- a/tools/xl/xl_saverestore.c +++ b/tools/xl/xl_saverestore.c @@ -121,41 +121,42 @@ void save_domain_core_writeconfig(int fd, const char *source, " 0x%"PRIx32"/0x%"PRIx32"/%"PRIu32")\n", source, hdr.mandatory_flags, hdr.optional_flags, hdr.optional_data_len); } static int save_domain(uint32_t domid, int preserve_domid, const char *filename, int checkpoint, int leavepaused, const char *override_config_file) { int fd; uint8_t *config_data; int config_len; + libxl_domain_suspend_props props = {}; save_domain_core_begin(domid, preserve_domid, override_config_file, &config_data, &config_len); if (!config_len) { fputs(" Savefile will not contain xl domain config\n", stderr); } fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644); if (fd < 0) { fprintf(stderr, "Failed to open temp file %s for writing\n", filename); exit(EXIT_FAILURE); } save_domain_core_writeconfig(fd, filename, config_data, config_len); - int rc = libxl_domain_suspend(ctx, domid, fd, 0, NULL); + int rc = libxl_domain_suspend(ctx, domid, fd, &props, NULL); close(fd); if (rc < 0) { fprintf(stderr, "Failed to save domain, resuming domain\n"); libxl_domain_resume(ctx, domid, 1, 0); } else if (leavepaused || checkpoint) { if (leavepaused) libxl_domain_pause(ctx, domid, NULL); libxl_domain_resume(ctx, domid, 1, 0); } else
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor