xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 27 of 30] libxl: remove XS transaction from public API
Date: Mon, 21 Mar 2011 14:44:50 +0000	[thread overview]
Message-ID: <8789166a014f43bf66ec.1300718690@localhost.localdomain> (raw)
In-Reply-To: <patchbomb.1300718663@localhost.localdomain>

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# 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@citrix.com>

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;
     }

  parent reply	other threads:[~2011-03-21 14:44 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-21 14:44 [PATCH 00 of 30] tools: shave build yaks Ian Campbell
2011-03-21 14:44 ` [PATCH 01 of 30] libxc: remove dependency on xenstore headers Ian Campbell
2011-03-21 14:44 ` [PATCH 02 of 30] tools: libxc: drop rpm.spec Ian Campbell
2011-03-21 14:44 ` [PATCH 03 of 30] tools: vnet: Remove Ian Campbell
2011-03-21 14:44 ` [PATCH 04 of 30] tools: Drop use of $(INCLUDES) Ian Campbell
2011-03-21 14:44 ` [PATCH 05 of 30] tools: vtpm: Use $(BINDIR) rather than a privately defined variable Ian Campbell
2011-03-21 14:44 ` [PATCH 06 of 30] tools: remove unnecessary uses of -L Ian Campbell
2011-03-21 14:44 ` [PATCH 07 of 30] tools: remove unnecessary uses of -I Ian Campbell
2011-03-21 14:44 ` [PATCH 08 of 30] tools: Drop XEN_XC variable Ian Campbell
2011-03-21 14:44 ` [PATCH 09 of 30] tools: blktap2: copy xenstore/hashtable.h into blktap2 Ian Campbell
2011-03-21 18:03   ` Ian Jackson
2011-03-21 20:47     ` Shriram Rajagopalan
2011-03-21 21:56       ` Ian Campbell
2011-03-21 22:17         ` Shriram Rajagopalan
2011-03-24 10:29     ` Ian Campbell
2011-03-24 17:35       ` Shriram Rajagopalan
2011-03-29  8:19         ` Ian Campbell
2011-03-31 17:17       ` Ian Jackson
2011-03-21 14:44 ` [PATCH 10 of 30] tools: consistently use $(CFLAGS_xeninclude) instead of open coding Ian Campbell
2011-03-21 14:44 ` [PATCH 11 of 30] tools: consistently use $({CFLAGS, LDLIBS}_libxenctrl) " Ian Campbell
2011-03-21 14:44 ` [PATCH 12 of 30] tools: consistently use $({CFLAGS, LDLIBS}_libxenstore) " Ian Campbell
2011-03-21 14:44 ` [PATCH 13 of 30] tools: consistently use $({CFLAGS, LDLIBS}_libxenlight) " Ian Campbell
2011-03-21 14:44 ` [PATCH 14 of 30] tools: xenstat: install and use shared library Ian Campbell
2011-03-21 14:44 ` [PATCH 15 of 30] tools: Drop $(X11_LDPATH) from build Ian Campbell
2011-03-21 14:44 ` [PATCH 16 of 30] tools: allow Makefiles to define CFLAGS_foo.o Ian Campbell
2011-03-21 14:44 ` [PATCH 17 of 30] tools: ocaml: link xl bindings against libxl Ian Campbell
2011-03-21 14:44 ` [PATCH 18 of 30] tools: ocaml: link evtchn bindings against libxenctrl Ian Campbell
2011-03-21 14:44 ` [PATCH 19 of 30] tools: users of libxl currently need to see libxc and libxenstore headers Ian Campbell
2011-03-21 14:44 ` [PATCH 20 of 30] tools: ocaml: push CFLAGS usage down into the specific bindings Ian Campbell
2011-03-21 14:44 ` [PATCH 21 of 30] tools: flask: Remove BASECFLAGS, just use CFLAGS Ian Campbell
2011-03-21 14:44 ` [PATCH 22 of 30] tools: flask: remove $(LOADLIBES) Ian Campbell
2011-03-21 14:44 ` [PATCH 23 of 30] tools: provide generic rules for compiling .S files Ian Campbell
2011-03-21 14:44 ` [PATCH 24 of 30] tools: Remove $(CFLAGS) from links lines Ian Campbell
2011-03-21 14:44 ` [PATCH 25 of 30] libxl: move libxl_doimid_valid_guest out of line Ian Campbell
2011-03-21 14:44 ` [PATCH 26 of 30] libxl: drop protype for libxl_ctx_set_log Ian Campbell
2011-03-21 14:44 ` Ian Campbell [this message]
2011-03-21 14:44 ` [PATCH 28 of 30] libxl: do not expose libxenctrl/libxenstore headers via libxl.h Ian Campbell
2011-03-21 14:44 ` [PATCH 29 of 30] tools: drop further uses of -Wp, -MD, .$(@F).d to generate dependencies Ian Campbell
2011-03-21 14:44 ` [PATCH 30 of 30] tools: remove pattern matched linking rules Ian Campbell
2011-03-21 18:15 ` [PATCH 00 of 30] tools: shave build yaks Ian Jackson
2011-03-23 16:15 ` Olaf Hering
2011-03-23 16:57   ` Ian Campbell

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=8789166a014f43bf66ec.1300718690@localhost.localdomain \
    --to=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).