aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl.c
diff options
context:
space:
mode:
authorGianni Tedesco <gianni.tedesco@citrix.com>2011-01-11 18:29:43 +0000
committerGianni Tedesco <gianni.tedesco@citrix.com>2011-01-11 18:29:43 +0000
commit760b359388cf4bc948ff6cbf96ab5f629ac45fe5 (patch)
treedd94f75650657c37a6a521560505eda6588576b4 /tools/libxl/libxl.c
parent64bc47d9a1055404b8c91467d6484ad3434bdde0 (diff)
downloadxen-760b359388cf4bc948ff6cbf96ab5f629ac45fe5.tar.gz
xen-760b359388cf4bc948ff6cbf96ab5f629ac45fe5.tar.bz2
xen-760b359388cf4bc948ff6cbf96ab5f629ac45fe5.zip
libxl: Introduce libxl_domain_create_new() and libxl_domain_create_restore()
These functions are introduced as the new way to create domains with libxl they prevent the callers from need to know about low-level implementation details such as: - libxl_domain_make() - libxl_domain_build() - libxl_domain_restore() - when to attach the console - how to start the device model Above mentioned functions and all API's for the device model, which are now redundant, have been made internal to libxl and no longer accessible. The ocaml binding for libxl has not been properly updated to reflect the changes, wrappers for the old functions have been removed but the code to wrap the new functions has not been added. Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl.c')
-rw-r--r--tools/libxl/libxl.c243
1 files changed, 0 insertions, 243 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index e4e6b54472..08d1bcb6e4 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -104,114 +104,6 @@ void libxl_key_value_list_destroy(libxl_key_value_list *pkvl)
/******************************************************************************/
-int libxl_domain_make(libxl_ctx *ctx, libxl_domain_create_info *info,
- uint32_t *domid)
-{
- libxl__gc gc = LIBXL_INIT_GC(ctx);
- int flags, ret, i, rc;
- char *uuid_string;
- char *rw_paths[] = { "device", "device/suspend/event-channel" , "data"};
- char *ro_paths[] = { "cpu", "memory", "device", "error", "drivers",
- "control", "attr", "messages" };
- char *dom_path, *vm_path;
- struct xs_permissions roperm[2];
- struct xs_permissions rwperm[1];
- xs_transaction_t t;
- xen_domain_handle_t handle;
-
- uuid_string = libxl__uuid2string(&gc, info->uuid);
- if (!uuid_string) {
- libxl__free_all(&gc);
- return ERROR_NOMEM;
- }
-
- flags = info->hvm ? XEN_DOMCTL_CDF_hvm_guest : 0;
- flags |= info->hap ? XEN_DOMCTL_CDF_hap : 0;
- flags |= info->oos ? 0 : XEN_DOMCTL_CDF_oos_off;
- *domid = -1;
-
- /* Ultimately, handle is an array of 16 uint8_t, same as uuid */
- libxl_uuid_copy((libxl_uuid *)handle, &info->uuid);
-
- ret = xc_domain_create(ctx->xch, info->ssidref, handle, flags, domid);
- if (ret < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "domain creation fail");
- libxl__free_all(&gc);
- return ERROR_FAIL;
- }
-
- ret = xc_cpupool_movedomain(ctx->xch, info->poolid, *domid);
- if (ret < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "domain move fail");
- libxl__free_all(&gc);
- return ERROR_FAIL;
- }
-
- dom_path = libxl__xs_get_dompath(&gc, *domid);
- if (!dom_path) {
- libxl__free_all(&gc);
- return ERROR_FAIL;
- }
-
- vm_path = libxl__sprintf(&gc, "/vm/%s", uuid_string);
- if (!vm_path) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot allocate create paths");
- libxl__free_all(&gc);
- return ERROR_FAIL;
- }
-
- roperm[0].id = 0;
- roperm[0].perms = XS_PERM_NONE;
- roperm[1].id = *domid;
- roperm[1].perms = XS_PERM_READ;
- rwperm[0].id = *domid;
- rwperm[0].perms = XS_PERM_NONE;
-
-retry_transaction:
- t = xs_transaction_start(ctx->xsh);
- xs_rm(ctx->xsh, t, dom_path);
- xs_mkdir(ctx->xsh, t, dom_path);
- xs_set_permissions(ctx->xsh, t, dom_path, roperm, ARRAY_SIZE(roperm));
-
- xs_rm(ctx->xsh, t, vm_path);
- xs_mkdir(ctx->xsh, t, vm_path);
- 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);
- if (rc) {
- libxl__free_all(&gc);
- return rc;
- }
-
- for (i = 0; i < ARRAY_SIZE(rw_paths); i++) {
- char *path = libxl__sprintf(&gc, "%s/%s", dom_path, rw_paths[i]);
- xs_mkdir(ctx->xsh, t, path);
- xs_set_permissions(ctx->xsh, t, path, rwperm, ARRAY_SIZE(rwperm));
- }
- for (i = 0; i < ARRAY_SIZE(ro_paths); i++) {
- char *path = libxl__sprintf(&gc, "%s/%s", dom_path, ro_paths[i]);
- xs_mkdir(ctx->xsh, t, path);
- xs_set_permissions(ctx->xsh, t, path, roperm, ARRAY_SIZE(roperm));
- }
-
- xs_write(ctx->xsh, t, libxl__sprintf(&gc, "%s/uuid", vm_path), uuid_string, strlen(uuid_string));
- xs_write(ctx->xsh, t, libxl__sprintf(&gc, "%s/name", vm_path), info->name, strlen(info->name));
- if (info->poolname)
- xs_write(ctx->xsh, t, libxl__sprintf(&gc, "%s/pool_name", vm_path), info->poolname, strlen(info->poolname));
-
- libxl__xs_writev(&gc, t, dom_path, info->xsdata);
- libxl__xs_writev(&gc, t, libxl__sprintf(&gc, "%s/platform", dom_path), info->platformdata);
-
- xs_write(ctx->xsh, t, libxl__sprintf(&gc, "%s/control/platform-feature-multiprocessor-suspend", dom_path), "1", 1);
-
- if (!xs_transaction_end(ctx->xsh, t, 0))
- if (errno == EAGAIN)
- goto retry_transaction;
-
- libxl__free_all(&gc);
- return 0;
-}
int libxl_domain_rename(libxl_ctx *ctx, uint32_t domid,
const char *old_name, const char *new_name,
@@ -293,141 +185,6 @@ int libxl_domain_rename(libxl_ctx *ctx, uint32_t domid,
x_nomem: rc = ERROR_NOMEM; goto x_rc;
}
-int libxl_domain_build(libxl_ctx *ctx, libxl_domain_build_info *info, uint32_t domid, libxl_domain_build_state *state)
-{
- libxl__gc gc = LIBXL_INIT_GC(ctx);
- char **vments = NULL, **localents = NULL;
- struct timeval start_time;
- int i, ret;
-
- ret = libxl__build_pre(ctx, domid, info, state);
- if (ret)
- goto out;
-
- gettimeofday(&start_time, NULL);
-
- if (info->hvm) {
- ret = libxl__build_hvm(ctx, domid, info, state);
- if (ret)
- goto out;
-
- vments = libxl__calloc(&gc, 7, sizeof(char *));
- vments[0] = "rtc/timeoffset";
- vments[1] = (info->u.hvm.timeoffset) ? info->u.hvm.timeoffset : "";
- vments[2] = "image/ostype";
- vments[3] = "hvm";
- vments[4] = "start_time";
- vments[5] = libxl__sprintf(&gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
- } else {
- ret = libxl__build_pv(ctx, domid, info, state);
- if (ret)
- goto out;
-
- vments = libxl__calloc(&gc, 11, sizeof(char *));
- i = 0;
- vments[i++] = "image/ostype";
- vments[i++] = "linux";
- vments[i++] = "image/kernel";
- vments[i++] = (char*) info->kernel.path;
- vments[i++] = "start_time";
- vments[i++] = libxl__sprintf(&gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
- if (info->u.pv.ramdisk.path) {
- vments[i++] = "image/ramdisk";
- vments[i++] = (char*) info->u.pv.ramdisk.path;
- }
- if (info->u.pv.cmdline) {
- vments[i++] = "image/cmdline";
- vments[i++] = (char*) info->u.pv.cmdline;
- }
- }
- ret = libxl__build_post(ctx, domid, info, state, vments, localents);
-out:
- libxl__file_reference_unmap(&info->kernel);
- if (!info->hvm)
- libxl__file_reference_unmap(&info->u.pv.ramdisk);
-
- libxl__free_all(&gc);
- return ret;
-}
-
-int libxl_domain_restore(libxl_ctx *ctx, libxl_domain_build_info *info,
- uint32_t domid, int fd, libxl_domain_build_state *state,
- libxl_device_model_info *dm_info)
-{
- libxl__gc gc = LIBXL_INIT_GC(ctx);
- char **vments = NULL, **localents = NULL;
- struct timeval start_time;
- int i, ret, esave, flags;
-
- ret = libxl__build_pre(ctx, domid, info, state);
- if (ret)
- goto out;
-
- ret = libxl__domain_restore_common(ctx, domid, info, state, fd);
- if (ret)
- goto out;
-
- gettimeofday(&start_time, NULL);
-
- if (info->hvm) {
- vments = libxl__calloc(&gc, 7, sizeof(char *));
- vments[0] = "rtc/timeoffset";
- vments[1] = (info->u.hvm.timeoffset) ? info->u.hvm.timeoffset : "";
- vments[2] = "image/ostype";
- vments[3] = "hvm";
- vments[4] = "start_time";
- vments[5] = libxl__sprintf(&gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
- } else {
- vments = libxl__calloc(&gc, 11, sizeof(char *));
- i = 0;
- vments[i++] = "image/ostype";
- vments[i++] = "linux";
- vments[i++] = "image/kernel";
- vments[i++] = (char*) info->kernel.path;
- vments[i++] = "start_time";
- vments[i++] = libxl__sprintf(&gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
- if (info->u.pv.ramdisk.path) {
- vments[i++] = "image/ramdisk";
- vments[i++] = (char*) info->u.pv.ramdisk.path;
- }
- if (info->u.pv.cmdline) {
- vments[i++] = "image/cmdline";
- vments[i++] = (char*) info->u.pv.cmdline;
- }
- }
- ret = libxl__build_post(ctx, domid, info, state, vments, localents);
- if (ret)
- goto out;
-
- dm_info->saved_state = NULL;
- if (info->hvm) {
- ret = asprintf(&dm_info->saved_state,
- "/var/lib/xen/qemu-save.%d", domid);
- ret = (ret < 0) ? ERROR_FAIL : 0;
- }
-
-out:
- libxl__file_reference_unmap(&info->kernel);
- if (!info->hvm)
- libxl__file_reference_unmap(&info->u.pv.ramdisk);
-
- esave = errno;
-
- flags = fcntl(fd, F_GETFL);
- if (flags == -1) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to get flags on restore fd");
- } else {
- flags &= ~O_NONBLOCK;
- if (fcntl(fd, F_SETFL, flags) == -1)
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to put restore fd"
- " back to blocking mode");
- }
-
- errno = esave;
- libxl__free_all(&gc);
- return ret;
-}
-
int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid)
{
libxl__gc gc = LIBXL_INIT_GC(ctx);