/******************************************************************************/
-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;
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:
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);
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;
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 */
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;
_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);
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;
}
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");
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;
}
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;
}
/******************************************************************************
* xl.c
- *
+ *
* Copyright (c) 2010 Citrix Ltd.
* Author: Gianni Tedesco
*
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;
}