[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 02/35] libxl: Make libxl_send_trigger async
.. because it makes QMP calls which are going to be async. Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- tools/libxl/libxl.h | 13 ++++++++++++- tools/libxl/libxl_domain.c | 12 ++++++++---- tools/xl/xl_misc.c | 4 ++-- tools/xl/xl_vmcontrol.c | 4 ++-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 10dfde3fd897..430123274964 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -1219,6 +1219,7 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src); * asynchronously. Those functions are: * libxl_domain_pause() * libxl_domain_unpause() + * libxl_send_trigger() */ #define LIBXL_HAVE_FN_USING_QMP_ASYNC 1 @@ -2380,7 +2381,17 @@ int libxl_vcpu_sched_params_set_all(libxl_ctx *ctx, uint32_t domid, const libxl_vcpu_sched_params *params); int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid, - libxl_trigger trigger, uint32_t vcpuid); + libxl_trigger trigger, uint32_t vcpuid, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300 +static inline int libxl_send_trigger_0x041200( + libxl_ctx *ctx, uint32_t domid, libxl_trigger trigger, uint32_t vcpuid) +{ + return libxl_send_trigger_0x041200(ctx, domid, trigger, vcpuid, NULL); +} +#define libxl_send_trigger libxl_send_trigger_0x041200 +#endif int libxl_send_sysrq(libxl_ctx *ctx, uint32_t domid, char sysrq); int libxl_send_debug_keys(libxl_ctx *ctx, char *keys); int libxl_set_parameters(libxl_ctx *ctx, char *params); diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 1c313005db51..86cddc05a944 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1470,10 +1470,11 @@ static int libxl__domain_s3_resume(libxl__gc *gc, int domid) } int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid, - libxl_trigger trigger, uint32_t vcpuid) + libxl_trigger trigger, uint32_t vcpuid, + const libxl_asyncop_how *ao_how) { + AO_CREATE(ctx, domid, ao_how); int rc; - GC_INIT(ctx); switch (trigger) { case LIBXL_TRIGGER_POWER: @@ -1509,10 +1510,13 @@ int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid, LOGED(ERROR, domid, "Send trigger '%s' failed", libxl_trigger_to_string(trigger)); rc = ERROR_FAIL; + goto out; } - GC_FREE; - return rc; + libxl__ao_complete(egc, ao, rc); + return AO_INPROGRESS; +out: + return AO_CREATE_FAIL(rc); } uint32_t libxl_vm_get_start_time(libxl_ctx *ctx, uint32_t domid) diff --git a/tools/xl/xl_misc.c b/tools/xl/xl_misc.c index dcf940a6d4a6..50c8436337c9 100644 --- a/tools/xl/xl_misc.c +++ b/tools/xl/xl_misc.c @@ -36,7 +36,7 @@ static void button_press(uint32_t domid, const char *b) exit(EXIT_FAILURE); } - libxl_send_trigger(ctx, domid, trigger, 0); + libxl_send_trigger(ctx, domid, trigger, 0, NULL); } int main_button_press(int argc, char **argv) @@ -106,7 +106,7 @@ int main_trigger(int argc, char **argv) } } - libxl_send_trigger(ctx, domid, trigger, vcpuid); + libxl_send_trigger(ctx, domid, trigger, vcpuid, NULL); return EXIT_SUCCESS; } diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 419bf780a4c2..3fc6f565748c 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -108,7 +108,7 @@ static void reboot_domain(uint32_t domid, libxl_evgen_domain_death **deathw, if (fallback_trigger) { fprintf(stderr, "PV control interface not available:" " sending ACPI reset button event.\n"); - rc = libxl_send_trigger(ctx, domid, LIBXL_TRIGGER_RESET, 0); + rc = libxl_send_trigger(ctx, domid, LIBXL_TRIGGER_RESET, 0, NULL); } else { fprintf(stderr, "PV control interface not available:" " external graceful reboot not possible.\n"); @@ -141,7 +141,7 @@ static void shutdown_domain(uint32_t domid, if (fallback_trigger) { fprintf(stderr, "PV control interface not available:" " sending ACPI power button event.\n"); - rc = libxl_send_trigger(ctx, domid, LIBXL_TRIGGER_POWER, 0); + rc = libxl_send_trigger(ctx, domid, LIBXL_TRIGGER_POWER, 0, NULL); } else { fprintf(stderr, "PV control interface not available:" " external graceful shutdown not possible.\n"); -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |