All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Wei Liu <wl@xen.org>
Subject: [Xen-devel] [PATCH v2 02/35] libxl: Make libxl_send_trigger async
Date: Thu, 19 Sep 2019 18:16:22 +0100	[thread overview]
Message-ID: <20190919171656.899649-3-anthony.perard@citrix.com> (raw)
In-Reply-To: <20190919171656.899649-1-anthony.perard@citrix.com>

.. because it makes QMP calls which are going to be async.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-09-19 17:17 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 17:16 [Xen-devel] [PATCH v2 00/35] libxl refactoring to use ev_qmp (with API changes) Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 01/35] libxl: Make libxl_domain_unpause async Anthony PERARD
2019-09-19 17:16 ` Anthony PERARD [this message]
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 03/35] libxl: Make libxl_set_vcpuonline async Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 04/35] libxl: Make libxl_retrieve_domain_configuration async Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 05/35] libxl: Make libxl_qemu_monitor_command async Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 06/35] libxl: Use ev_qmp for switch_qemu_xen_logdirty Anthony PERARD
2019-09-19 19:14   ` Ian Jackson
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 07/35] libxl: Move "qmp_initializations" to libxl_dm Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 08/35] libxl: Replace libxl__qmp_initializations by ev_qmp calls Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 09/35] libxl: Deprecate libxl__domain_{unpause, resume} Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 10/35] libxl: Re-introduce libxl__domain_resume Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 11/35] libxl_domain: Convert libxl_domain_resume to use libxl__domain_resume Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 12/35] libxl: Re-introduce libxl__domain_unpause Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 13/35] libxl_dm: Update libxl__spawn_stub_dm to use libxl__domain_unpause Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 14/35] libxl_domain: Convert libxl_domain_unpause " Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 15/35] libxl: Inline do_usbdev_add into libxl__device_usbdev_add Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 16/35] libxl: Inline do_usbdev_remove into libxl__device_usbdev_remove Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 17/35] libxl: Add libxl__ev_qmp to libxl__ao_device Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 18/35] libxl: Add device_{config, type} " Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 19/35] libxl_usb: Make libxl__device_usbctrl_add uses ev_qmp Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 20/35] libxl_usb: Make libxl__initiate_device_usbctrl_remove " Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 21/35] libxl_usb: Make libxl__device_usbdev_add " Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 22/35] libxl: Use aodev for libxl__device_usbdev_remove Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 23/35] libxl: libxl__initiate_device_usbdev_remove now use ev_qmp Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 24/35] libxl: Remove libxl__qmp_run_command_flexarray Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 25/35] libxl_pci: Coding style of do_pci_add Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 26/35] libxl_pci: Only check if qemu-dm is running in qemu-trad case Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 27/35] libxl_pci: Use libxl__ao_device with libxl__device_pci_add Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 28/35] libxl_pci: Use ev_qmp in do_pci_add Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 29/35] libxl_pci: Use libxl__ao_device with pci_remove Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 30/35] libxl_pci: Use ev_qmp for pci_remove Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 31/35] libxl: Use ev_qmp for libxl_send_trigger Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 32/35] libxl: Use ev_qmp in libxl_set_vcpuonline Anthony PERARD
2019-09-19 19:17   ` [Xen-devel] [PATCH v2 00/35] libxl refactoring to use ev_qmp (with API changes) [and 1 more messages] Ian Jackson
2019-09-20  9:48     ` Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 33/35] libxl: libxl_retrieve_domain_configuration now uses ev_qmp Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 34/35] libxl: libxl_qemu_monitor_command " Anthony PERARD
2019-09-19 17:16 ` [Xen-devel] [PATCH v2 35/35] libxl_pci: Extract common part of *qemu_trad_watch_state_cb Anthony PERARD
2019-09-19 19:18   ` Ian Jackson
2019-09-19 19:19 ` [Xen-devel] [PATCH v2 00/35] libxl refactoring to use ev_qmp (with API changes) Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190919171656.899649-3-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.