char *rw_paths[] = { "control/shutdown", "device", "device/suspend/event-channel" , "data"};
char *ro_paths[] = { "cpu", "memory", "device", "error", "drivers",
"control", "attr", "messages" };
- char *dom_path, *vm_path;
+ char *dom_path, *vm_path, *libxl_path;
struct xs_permissions roperm[2];
struct xs_permissions rwperm[1];
+ struct xs_permissions noperm[1];
xs_transaction_t t = 0;
xen_domain_handle_t handle;
+
assert(!libxl_domid_valid_guest(*domid));
uuid_string = libxl__uuid2string(gc, info->uuid);
goto out;
}
+ libxl_path = libxl__xs_libxl_path(gc, *domid);
+ if (!libxl_path) {
+ rc = ERROR_FAIL;
+ goto out;
+ }
+ noperm[0].id = 0;
+ noperm[0].perms = XS_PERM_NONE;
+
roperm[0].id = 0;
roperm[0].perms = XS_PERM_NONE;
roperm[1].id = *domid;
xs_mkdir(ctx->xsh, t, vm_path);
xs_set_permissions(ctx->xsh, t, vm_path, roperm, ARRAY_SIZE(roperm));
+ xs_rm(ctx->xsh, t, libxl_path);
+ xs_mkdir(ctx->xsh, t, libxl_path);
+ xs_set_permissions(ctx->xsh, t, libxl_path, noperm, ARRAY_SIZE(noperm));
+
xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/vm", dom_path), vm_path, strlen(vm_path));
rc = libxl__domain_rename(gc, *domid, 0, info->name, t);
if (rc)
return rc;
}
+static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
+ libxl_device_model_info *dm_info)
+{
+ char *path = NULL;
+
+ path = libxl__xs_libxl_path(gc, domid);
+ path = libxl__sprintf(gc, "%s/dm-version", path);
+ return libxl__xs_write(gc, XBT_NULL, path, libxl__strdup(gc,
+ libxl_device_model_version_to_string(dm_info->device_model_version)));
+}
+
static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
libxl_console_ready cb, void *priv,
uint32_t *domid_out, int restore_fd)
goto error_out;
}
+ store_libxl_entry(gc, domid, dm_info);
+
for (i = 0; i < d_config->num_disks; i++) {
ret = libxl_device_disk_add(ctx, domid, &d_config->disks[i]);
if (ret) {
return fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
}
+libxl_device_model_version libxl__device_model_version_running(libxl__gc *gc,
+ uint32_t domid)
+{
+ char *path = NULL;
+ char *dm_version = NULL;
+ libxl_device_model_version value;
+
+ path = libxl__xs_libxl_path(gc, domid);
+ path = libxl__sprintf(gc, "%s/dm-version", path);
+ dm_version = libxl__xs_read(gc, XBT_NULL, path);
+ if (!dm_version) {
+ return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+ }
+
+ if (libxl_device_model_version_from_string(dm_version, &value) < 0) {
+ libxl_ctx *ctx = libxl__gc_owner(gc);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+ "fatal: %s contain a wrong value (%s)", path, dm_version);
+ return -1;
+ }
+ return value;
+}
+
/*
* Local variables:
* mode: C
char *path, unsigned int *nb);
/* On error: returns NULL, sets errno (no logging) */
+_hidden char *libxl__xs_libxl_path(libxl__gc *gc, uint32_t domid);
+
/* from xl_dom */
_hidden libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid);
_hidden int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid);
_hidden libxl__json_object *libxl__json_parse(libxl__gc *gc, const char *s);
+ /* Based on /local/domain/$domid/dm-version xenstore key
+ * default is qemu xen traditional */
+_hidden libxl_device_model_version
+libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);
+
#endif
/*