WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 27 of 30] libxl: remove XS transaction from public AP

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 27 of 30] libxl: remove XS transaction from public API
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 21 Mar 2011 14:44:50 +0000
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Mon, 21 Mar 2011 08:12:34 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1300718663@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1300718506 0
# Node ID 8789166a014f43bf66ec4b2af51a4771fb56a5d5
# Parent  0346391ed12e485c4fd1727eb5d4d7a88ac13542
libxl: remove XS transaction from public API.

All external users pass 0 anyway so make the version of
libxl_domain_rename which takes a transaction internal and provide an
external facing function which does not expose a transaction.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 0346391ed12e -r 8789166a014f tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Mar 21 14:41:46 2011 +0000
+++ b/tools/libxl/libxl.c       Mon Mar 21 14:41:46 2011 +0000
@@ -116,11 +116,11 @@ void libxl_key_value_list_destroy(libxl_
 
/******************************************************************************/
 
 
-int libxl_domain_rename(libxl_ctx *ctx, uint32_t domid,
-                        const char *old_name, const char *new_name,
-                        xs_transaction_t trans)
+int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
+                         const char *old_name, const char *new_name,
+                         xs_transaction_t trans)
 {
-    libxl__gc gc = LIBXL_INIT_GC(ctx);
+    libxl_ctx *ctx = libxl__gc_owner(gc);
     char *dom_path = 0;
     const char *name_path;
     char *got_old_name;
@@ -128,10 +128,10 @@ int libxl_domain_rename(libxl_ctx *ctx, 
     xs_transaction_t our_trans = 0;
     int rc;
 
-    dom_path = libxl__xs_get_dompath(&gc, domid);
+    dom_path = libxl__xs_get_dompath(gc, domid);
     if (!dom_path) goto x_nomem;
 
-    name_path= libxl__sprintf(&gc, "%s/name", dom_path);
+    name_path= libxl__sprintf(gc, "%s/name", dom_path);
     if (!name_path) goto x_nomem;
 
  retry_transaction:
@@ -211,11 +211,20 @@ int libxl_domain_rename(libxl_ctx *ctx, 
     rc = 0;
  x_rc:
     if (our_trans) xs_transaction_end(ctx->xsh, our_trans, 1);
-    libxl__free_all(&gc);
     return rc;
 
  x_fail:  rc = ERROR_FAIL;  goto x_rc;
  x_nomem: rc = ERROR_NOMEM; goto x_rc;
+}
+
+int libxl_domain_rename(libxl_ctx *ctx, uint32_t domid,
+                        const char *old_name, const char *new_name)
+{
+    libxl__gc gc = LIBXL_INIT_GC(ctx);
+    int rc;
+    rc = libxl__domain_rename(&gc, domid, old_name, new_name, XBT_NULL);
+    libxl__free_all(&gc);
+    return rc;
 }
 
 int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid)
@@ -303,7 +312,7 @@ int libxl_domain_preserve(libxl_ctx *ctx
     xs_set_permissions(ctx->xsh, t, vm_path, roperm, ARRAY_SIZE(roperm));
 
     xs_write(ctx->xsh, t, libxl__sprintf(&gc, "%s/vm", dom_path), vm_path, 
strlen(vm_path));
-    rc = libxl_domain_rename(ctx, domid, info->name, preserved_name, t);
+    rc = libxl__domain_rename(&gc, domid, info->name, preserved_name, t);
     if (rc) {
         libxl__free_all(&gc);
         return rc;
diff -r 0346391ed12e -r 8789166a014f tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Mon Mar 21 14:41:46 2011 +0000
+++ b/tools/libxl/libxl.h       Mon Mar 21 14:41:46 2011 +0000
@@ -376,8 +376,8 @@ int libxl_event_get_disk_eject_info(libx
 int libxl_event_get_disk_eject_info(libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, libxl_device_disk *disk);
 
 int libxl_domain_rename(libxl_ctx *ctx, uint32_t domid,
-                        const char *old_name, const char *new_name,
-                        xs_transaction_t trans);
+                        const char *old_name, const char *new_name);
+
   /* if old_name is NULL, any old name is OK; otherwise we check
    * transactionally that the domain has the old old name; if
    * trans is not 0 we use caller's transaction and caller must do retries */
diff -r 0346391ed12e -r 8789166a014f tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c        Mon Mar 21 14:41:46 2011 +0000
+++ b/tools/libxl/libxl_create.c        Mon Mar 21 14:41:46 2011 +0000
@@ -354,7 +354,7 @@ retry_transaction:
     xs_set_permissions(ctx->xsh, t, vm_path, roperm, ARRAY_SIZE(roperm));
 
     xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/vm", dom_path), vm_path, 
strlen(vm_path));
-    rc = libxl_domain_rename(ctx, *domid, 0, info->name, t);
+    rc = libxl__domain_rename(gc, *domid, 0, info->name, t);
     if (rc)
         goto out;
 
diff -r 0346391ed12e -r 8789166a014f tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Mon Mar 21 14:41:46 2011 +0000
+++ b/tools/libxl/libxl_internal.h      Mon Mar 21 14:41:46 2011 +0000
@@ -170,6 +170,10 @@ _hidden int libxl__build_pv(libxl__gc *g
              libxl_domain_build_info *info, libxl_domain_build_state *state);
 _hidden int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
               libxl_domain_build_info *info, libxl_domain_build_state *state);
+
+_hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
+                                 const char *old_name, const char *new_name,
+                                 xs_transaction_t trans);
 
 _hidden int libxl__domain_restore_common(libxl__gc *gc, uint32_t domid,
                    libxl_domain_build_info *info, libxl_domain_build_state 
*state, int fd);
diff -r 0346391ed12e -r 8789166a014f tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Mon Mar 21 14:41:46 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Mon Mar 21 14:41:46 2011 +0000
@@ -2638,8 +2638,7 @@ static void migrate_domain(const char *d
     if (common_domname) {
         if (asprintf(&away_domname, "%s--migratedaway", common_domname) < 0)
             goto failed_resume;
-        rc = libxl_domain_rename(&ctx, domid,
-                                 common_domname, away_domname, 0);
+        rc = libxl_domain_rename(&ctx, domid, common_domname, away_domname);
         if (rc) goto failed_resume;
     }
 
@@ -2679,8 +2678,7 @@ static void migrate_domain(const char *d
         fprintf(stderr, "migration sender: Trying to resume at our end.\n");
 
         if (common_domname) {
-            libxl_domain_rename(&ctx, domid,
-                                away_domname, common_domname, 0);
+            libxl_domain_rename(&ctx, domid, away_domname, common_domname);
         }
         rc = libxl_domain_resume(&ctx, domid);
         if (!rc) fprintf(stderr, "migration sender: Resumed OK.\n");
@@ -2779,8 +2777,7 @@ static void migrate_receive(int debug, i
     fprintf(stderr, "migration target: Got permission, starting domain.\n");
 
     if (migration_domname) {
-        rc = libxl_domain_rename(&ctx, domid,
-                                 migration_domname, common_domname, 0);
+        rc = libxl_domain_rename(&ctx, domid, migration_domname, 
common_domname);
         if (rc) goto perhaps_destroy_notify_rc;
     }
 
@@ -4059,7 +4056,7 @@ int main_rename(int argc, char **argv)
     find_domain(dom);
     new_name = argv[optind];
 
-    if (libxl_domain_rename(&ctx, domid, common_domname, new_name, 0)) {
+    if (libxl_domain_rename(&ctx, domid, common_domname, new_name)) {
         fprintf(stderr, "Can't rename domain '%s'.\n", dom);
         return 1;
     }
diff -r 0346391ed12e -r 8789166a014f tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Mon Mar 21 14:41:46 2011 +0000
+++ b/tools/python/xen/lowlevel/xl/xl.c Mon Mar 21 14:41:46 2011 +0000
@@ -1,6 +1,6 @@
 /******************************************************************************
  * xl.c
- * 
+ *
  * Copyright (c) 2010 Citrix Ltd.
  * Author: Gianni Tedesco
  *
@@ -481,7 +481,7 @@ static PyObject *pyxl_domain_rename(XlOb
     int domid;
     if ( !PyArg_ParseTuple(args, "is|s", &domid, &new_name, &old_name) )
         return NULL;
-    if ( libxl_domain_rename(&self->ctx, domid, old_name, new_name, 0) ) {
+    if ( libxl_domain_rename(&self->ctx, domid, old_name, new_name) ) {
         PyErr_SetString(xl_error_obj, "cannot rename domain");
         return NULL;
     }

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

<Prev in Thread] Current Thread [Next in Thread>