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>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
Ian Campbell committed 2011-03-23 15:55:13 +00:00
1 parent 381c919a7c
commit 026bb0b5c0
6 files changed
+30 -20

No files matched your search

+17 -8
View File
@@ -116,11 +116,11 @@ void libxl_key_value_list_destroy(libxl_key_value_list *pkvl)
/******************************************************************************/
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, uint32_t domid,
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,13 +211,22 @@ int libxl_domain_rename(libxl_ctx *ctx, uint32_t domid,
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)
{
libxl__gc gc = LIBXL_INIT_GC(ctx);
@@ -303,7 +312,7 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
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;
+2 -2
View File
@@ -376,8 +376,8 @@ int libxl_event_get_domain_death_info(libxl_ctx *ctx, uint32_t domid, libxl_even
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 */
+1 -1
View File
@@ -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;
+4
View File
@@ -171,6 +171,10 @@ _hidden int libxl__build_pv(libxl__gc *gc, uint32_t domid,
_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);
_hidden int libxl__domain_suspend_common(libxl__gc *gc, uint32_t domid, int fd, int hvm, int live, int debug);
+4 -7
View File
@@ -2638,8 +2638,7 @@ static void migrate_domain(const char *domain_spec, const char *rune,
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 *domain_spec, const char *rune,
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, int daemonize)
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;
}
+2 -2
View File
@@ -1,6 +1,6 @@
/******************************************************************************
* xl.c
*
*
* Copyright (c) 2010 Citrix Ltd.
* Author: Gianni Tedesco
*
@@ -481,7 +481,7 @@ static PyObject *pyxl_domain_rename(XlObject *self, PyObject *args)
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;
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.