[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 04/35] libxl: Make libxl_retrieve_domain_configuration async



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

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 tools/libxl/libxl.h        | 12 +++++++++++-
 tools/libxl/libxl_domain.c | 14 +++++++-------
 tools/xl/xl_info.c         |  3 ++-
 tools/xl/xl_saverestore.c  |  3 ++-
 tools/xl/xl_vmcontrol.c    |  3 ++-
 5 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 224c9af1c6..96489a74ca 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1532,8 +1532,18 @@ void libxl_domain_config_dispose(libxl_domain_config 
*d_config);
  * works with DomU.
  */
 int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
-                                        libxl_domain_config *d_config)
+                                        libxl_domain_config *d_config,
+                                        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
 
 int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd,
                          int flags, /* LIBXL_SUSPEND_* */
diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
index 60c3f7a34b..f2d5c86427 100644
--- a/tools/libxl/libxl_domain.c
+++ b/tools/libxl/libxl_domain.c
@@ -1594,14 +1594,13 @@ static int libxl__update_avail_vcpus_xenstore(libxl__gc 
*gc, uint32_t domid,
 }
 
 int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
-                                        libxl_domain_config *d_config)
+                                        libxl_domain_config *d_config,
+                                        const libxl_asyncop_how *ao_how)
 {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
     int rc;
     libxl__domain_userdata_lock *lock = NULL;
 
-    CTX_LOCK;
-
     lock = libxl__lock_domain_userdata(gc, domid);
     if (!lock) {
         rc = ERROR_LOCK_FAIL;
@@ -1808,9 +1807,10 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, 
uint32_t domid,
 
 out:
     if (lock) libxl__unlock_domain_userdata(lock);
-    CTX_UNLOCK;
-    GC_FREE;
-    return rc;
+    if (rc)
+        return AO_CREATE_FAIL(rc);
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
 }
 
 /*
diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c
index 46d9c9f712..74a7884479 100644
--- a/tools/xl/xl_info.c
+++ b/tools/xl/xl_info.c
@@ -461,7 +461,8 @@ static void list_domains_details(const libxl_dominfo *info, 
int nb_domain)
 
     for (i = 0; i < nb_domain; i++) {
         libxl_domain_config_init(&d_config);
-        rc = libxl_retrieve_domain_configuration(ctx, info[i].domid, 
&d_config);
+        rc = libxl_retrieve_domain_configuration(ctx, info[i].domid,
+                                                 &d_config, NULL);
         if (rc)
             continue;
         if (default_output_format == OUTPUT_FORMAT_JSON)
diff --git a/tools/xl/xl_saverestore.c b/tools/xl/xl_saverestore.c
index 5c70e2e874..9be033fe65 100644
--- a/tools/xl/xl_saverestore.c
+++ b/tools/xl/xl_saverestore.c
@@ -56,7 +56,8 @@ void save_domain_core_begin(uint32_t domid,
                           &d_config);
         free(config_v);
     } else {
-        rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config);
+        rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config,
+                                                 NULL);
         if (rc) {
             fprintf(stderr, "unable to retrieve domain configuration\n");
             exit(EXIT_FAILURE);
diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c
index 3fc6f56574..eb6779a561 100644
--- a/tools/xl/xl_vmcontrol.c
+++ b/tools/xl/xl_vmcontrol.c
@@ -377,7 +377,8 @@ static void reload_domain_config(uint32_t domid,
     }
 
     libxl_domain_config_init(&d_config_new);
-    rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config_new);
+    rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config_new,
+                                             NULL);
     if (rc) {
         LOG("failed to retrieve guest configuration (rc=%d). "
             "reusing old configuration", rc);
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.