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

[Xen-devel] [PATCH V2 1/3] libxl_qmp: Use GC instead of CTX as parameter for _initialize.



This make things a bit easier.

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 tools/libxl/libxl_create.c   |    2 +-
 tools/libxl/libxl_internal.h |    4 ++--
 tools/libxl/libxl_qmp.c      |   27 ++++++++++++---------------
 3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index f28d814..9148b26 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -594,7 +594,7 @@ static int do_domain_create(libxl__gc *gc, 
libxl_domain_config *d_config,
     if (dm_starting) {
         if (d_config->b_info.device_model_version
             == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
-            libxl__qmp_initializations(ctx, domid);
+            libxl__qmp_initializations(gc, domid);
         }
         ret = libxl__confirm_device_model_startup(gc, &state, dm_starting);
         if (ret < 0) {
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 832cf35..972c818 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -991,7 +991,7 @@ typedef struct libxl__qmp_handler libxl__qmp_handler;
 /* Initialise and connect to the QMP socket.
  *   Return an handler or NULL if there is an error
  */
-_hidden libxl__qmp_handler *libxl__qmp_initialize(libxl_ctx *ctx,
+_hidden libxl__qmp_handler *libxl__qmp_initialize(libxl__gc *gc,
                                                   uint32_t domid);
 /* ask to QEMU the serial port information and store it in xenstore. */
 _hidden int libxl__qmp_query_serial(libxl__qmp_handler *qmp);
@@ -1007,7 +1007,7 @@ _hidden void libxl__qmp_close(libxl__qmp_handler *qmp);
 _hidden void libxl__qmp_cleanup(libxl__gc *gc, uint32_t domid);
 
 /* this helper calls qmp_initialize, query_serial and qmp_close */
-_hidden int libxl__qmp_initializations(libxl_ctx *ctx, uint32_t domid);
+_hidden int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid);
 
 /* from libxl_json */
 #include <yajl/yajl_gen.h>
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index e0642e3..ab34d1d 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -289,17 +289,17 @@ static int qmp_handle_response(libxl__qmp_handler *qmp,
  * Handler functions
  */
 
-static libxl__qmp_handler *qmp_init_handler(libxl_ctx *ctx, uint32_t domid)
+static libxl__qmp_handler *qmp_init_handler(libxl__gc *gc, uint32_t domid)
 {
     libxl__qmp_handler *qmp = NULL;
 
     qmp = calloc(1, sizeof (libxl__qmp_handler));
     if (qmp == NULL) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
+        LIBXL__LOG_ERRNO(libxl__gc_owner(gc), LIBXL__LOG_ERROR,
                          "Failed to allocate qmp_handler");
         return NULL;
     }
-    qmp->ctx = ctx;
+    qmp->ctx = libxl__gc_owner(gc);
     qmp->domid = domid;
     qmp->timeout = 5;
 
@@ -621,20 +621,18 @@ static void qmp_free_handler(libxl__qmp_handler *qmp)
  * API
  */
 
-libxl__qmp_handler *libxl__qmp_initialize(libxl_ctx *ctx, uint32_t domid)
+libxl__qmp_handler *libxl__qmp_initialize(libxl__gc *gc, uint32_t domid)
 {
     int ret = 0;
     libxl__qmp_handler *qmp = NULL;
     char *qmp_socket;
-    GC_INIT(ctx);
 
-    qmp = qmp_init_handler(ctx, domid);
+    qmp = qmp_init_handler(gc, domid);
 
     qmp_socket = libxl__sprintf(gc, "%s/qmp-libxl-%d",
                                 libxl_run_dir_path(), domid);
     if ((ret = qmp_open(qmp, qmp_socket, QMP_SOCKET_CONNECT_TIMEOUT)) < 0) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Connection error");
-        GC_FREE;
+        LIBXL__LOG_ERRNO(qmp->ctx, LIBXL__LOG_ERROR, "Connection error");
         qmp_free_handler(qmp);
         return NULL;
     }
@@ -648,9 +646,8 @@ libxl__qmp_handler *libxl__qmp_initialize(libxl_ctx *ctx, 
uint32_t domid)
         }
     }
 
-    GC_FREE;
     if (!qmp->connected) {
-        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Failed to connect to QMP");
+        LIBXL__LOG(qmp->ctx, LIBXL__LOG_ERROR, "Failed to connect to QMP");
         libxl__qmp_close(qmp);
         return NULL;
     }
@@ -744,7 +741,7 @@ int libxl__qmp_pci_add(libxl__gc *gc, int domid, 
libxl_device_pci *pcidev)
     char *hostaddr = NULL;
     int rc = 0;
 
-    qmp = libxl__qmp_initialize(libxl__gc_owner(gc), domid);
+    qmp = libxl__qmp_initialize(gc, domid);
     if (!qmp)
         return -1;
 
@@ -789,7 +786,7 @@ static int qmp_device_del(libxl__gc *gc, int domid, char 
*id)
     libxl_key_value_list args = NULL;
     int rc = 0;
 
-    qmp = libxl__qmp_initialize(libxl__gc_owner(gc), domid);
+    qmp = libxl__qmp_initialize(gc, domid);
     if (!qmp)
         return ERROR_FAIL;
 
@@ -850,7 +847,7 @@ int libxl__qmp_migrate(libxl__gc *gc, int domid, int fd)
     libxl_key_value_list args = NULL;
     int rc = 0;
 
-    qmp = libxl__qmp_initialize(libxl__gc_owner(gc), domid);
+    qmp = libxl__qmp_initialize(gc, domid);
     if (!qmp)
         return ERROR_FAIL;
 
@@ -880,12 +877,12 @@ out:
     return rc;
 }
 
-int libxl__qmp_initializations(libxl_ctx *ctx, uint32_t domid)
+int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid)
 {
     libxl__qmp_handler *qmp = NULL;
     int ret = 0;
 
-    qmp = libxl__qmp_initialize(ctx, domid);
+    qmp = libxl__qmp_initialize(gc, domid);
     if (!qmp)
         return -1;
     ret = libxl__qmp_query_serial(qmp);
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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