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

[Xen-devel] [PATCH v2 03/35] libxl: Make libxl_set_vcpuonline 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        | 15 ++++++++++++++-
 tools/libxl/libxl_domain.c | 12 ++++++++----
 tools/xl/xl_cpupool.c      |  2 +-
 tools/xl/xl_vcpu.c         |  2 +-
 4 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 430123274964..fd69e92166b8 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1220,6 +1220,7 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const 
libxl_mac *src);
  *   libxl_domain_pause()
  *   libxl_domain_unpause()
  *   libxl_send_trigger()
+ *   libxl_set_vcpuonline()
  */
 #define LIBXL_HAVE_FN_USING_QMP_ASYNC 1
 
@@ -2318,7 +2319,19 @@ int libxl_domain_set_nodeaffinity(libxl_ctx *ctx, 
uint32_t domid,
                                   libxl_bitmap *nodemap);
 int libxl_domain_get_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
                                   libxl_bitmap *nodemap);
-int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpumap);
+int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid,
+                         libxl_bitmap *cpumap,
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
+static inline int libxl_set_vcpuonline_0x041200(libxl_ctx *ctx,
+                                                uint32_t domid,
+                                                libxl_bitmap *cpumap)
+{
+    return libxl_set_vcpuonline(ctx, domid, cpumap, NULL);
+}
+#define libxl_set_vcpuonline libxl_set_vcpuonline_0x041200
+#endif
 
 /* A return value less than 0 should be interpreted as a libxl_error, while a
  * return value greater than or equal to 0 should be interpreted as a
diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
index 86cddc05a944..60c3f7a34b4c 100644
--- a/tools/libxl/libxl_domain.c
+++ b/tools/libxl/libxl_domain.c
@@ -1386,9 +1386,11 @@ static int libxl__set_vcpuonline_qmp(libxl__gc *gc, 
uint32_t domid,
     return rc;
 }
 
-int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpumap)
+int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid,
+                         libxl_bitmap *cpumap,
+                         const libxl_asyncop_how *ao_how)
 {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
     int rc, maxcpus;
     libxl_dominfo info;
 
@@ -1439,8 +1441,10 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, 
libxl_bitmap *cpumap)
 
 out:
     libxl_dominfo_dispose(&info);
-    GC_FREE;
-    return rc;
+    if (rc)
+        return AO_CREATE_FAIL(rc);
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
 }
 
 static int libxl__domain_s3_resume(libxl__gc *gc, int domid)
diff --git a/tools/xl/xl_cpupool.c b/tools/xl/xl_cpupool.c
index 273811b66366..cffe87e0c7cc 100644
--- a/tools/xl/xl_cpupool.c
+++ b/tools/xl/xl_cpupool.c
@@ -546,7 +546,7 @@ int main_cpupoolnumasplit(int argc, char **argv)
         fprintf(stderr, "error on getting info for Domain-0\n");
         goto out;
     }
-    if (info.vcpu_online > n && libxl_set_vcpuonline(ctx, 0, &cpumap)) {
+    if (info.vcpu_online > n && libxl_set_vcpuonline(ctx, 0, &cpumap, NULL)) {
         fprintf(stderr, "error on removing vcpus for Domain-0\n");
         goto out;
     }
diff --git a/tools/xl/xl_vcpu.c b/tools/xl/xl_vcpu.c
index 329512eaaf79..9ff5354f749b 100644
--- a/tools/xl/xl_vcpu.c
+++ b/tools/xl/xl_vcpu.c
@@ -369,7 +369,7 @@ static int vcpuset(uint32_t domid, const char* nr_vcpus, 
int check_host)
     for (i = 0; i < max_vcpus; i++)
         libxl_bitmap_set(&cpumap, i);
 
-    rc = libxl_set_vcpuonline(ctx, domid, &cpumap);
+    rc = libxl_set_vcpuonline(ctx, domid, &cpumap, NULL);
     if (rc == ERROR_DOMAIN_NOTFOUND)
         fprintf(stderr, "Domain %u does not exist.\n", domid);
     else if (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®.