[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH V2 04/11] libxl, Introduce dm-version xenstore key.
On Mon, Oct 24, 2011 at 10:58, Ian Campbell <Ian.Campbell@xxxxxxxxxx> wrote: > On Thu, 2011-10-20 at 18:59 +0100, Anthony PERARD wrote: >> The all key is /libxl/$domid/dm-version. >> >> The /libxl/$domid dir is created with the domain and should be only >> accessible >> by the toolstack domain. >> >> This come with libxl__device_model_version_running helper function. >> >> Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> >> --- >> Âtools/libxl/libxl.c     Â|  Â2 ++ >> Âtools/libxl/libxl_create.c  |  28 ++++++++++++++++++++++++++++ >> Âtools/libxl/libxl_internal.c |  19 +++++++++++++++++++ >> Âtools/libxl/libxl_internal.h |  Â5 +++++ >> Â4 files changed, 54 insertions(+), 0 deletions(-) >> >> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c >> index 064fbc4..50b97c2 100644 >> --- a/tools/libxl/libxl.c >> +++ b/tools/libxl/libxl.c >> @@ -777,6 +777,8 @@ int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid, >> int force) >>   Âif (!xs_rm(ctx->xsh, XBT_NULL, dom_path)) >>     ÂLIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xs_rm failed for %s", >> dom_path); >> >> +  Âxs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(&gc, "/libxl/%d", domid)); >> + >>   Âlibxl__userdata_destroyall(&gc, domid); >> >>   Ârc = xc_domain_destroy(ctx->xch, domid); >> diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c >> index 68d0fc3..bed991c 100644 >> --- a/tools/libxl/libxl_create.c >> +++ b/tools/libxl/libxl_create.c >> @@ -322,6 +322,9 @@ int libxl__domain_make(libxl__gc *gc, >> libxl_domain_create_info *info, >>   Âxs_transaction_t t = 0; >>   Âxen_domain_handle_t handle; >> >> +  Âstruct xs_permissions libxlperm[1]; >> +  Âchar *libxl_path = NULL; >> + > > The variable declaration block has little sections of perms and *_path > -- you might as well include those there. libxlperm might be better > called noperm (assuming that really is it's meaning, xs's permission > scheme confuses the hell out of me). OK, I will change that. >>   Âassert(!libxl_domid_valid_guest(*domid)); >> >>   Âuuid_string = libxl__uuid2string(gc, info->uuid); >> @@ -368,6 +371,15 @@ int libxl__domain_make(libxl__gc *gc, >> libxl_domain_create_info *info, >>     Âgoto out; >>   Â} >> >> +  Âlibxl_path = libxl__sprintf(gc, "/libxl/%i", *domid); > > This is probably worthy of a little helper, similar to > libxl__xs_get_dom_path(). (/vm/blah ought to have one too but doesn't). I will do it. >> +  Âif (!libxl_path) { >> +    ÂLIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot allocate create paths"); >> +    Ârc = ERROR_FAIL; >> +    Âgoto out; >> +  Â} >> +  Âlibxlperm[0].id = 0; >> +  Âlibxlperm[0].perms = XS_PERM_NONE; >> + >>   Âroperm[0].id = 0; >>   Âroperm[0].perms = XS_PERM_NONE; >>   Âroperm[1].id = *domid; >> @@ -386,6 +398,10 @@ retry_transaction: >>   Â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, libxlperm, >> ARRAY_SIZE(libxlperm)); >> + >>   Â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) >> @@ -429,6 +445,16 @@ retry_transaction: >>   Âreturn rc; >> Â} >> >> +static int store_libxl_entry(libxl__gc *gc, uint32_t domid, >> +               libxl_device_model_info *dm_info) >> +{ >> +  Âchar *path = NULL; >> + >> +  Âpath = libxl__sprintf(gc, "/libxl/%i/dm-version", domid); >> +  Â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) >> @@ -485,6 +511,8 @@ static int do_domain_create(libxl__gc *gc, >> libxl_domain_config *d_config, >>     Â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) { >> diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c >> index 3993d8e..5d0a2d4 100644 >> --- a/tools/libxl/libxl_internal.c >> +++ b/tools/libxl/libxl_internal.c >> @@ -319,6 +319,25 @@ int libxl__fd_set_cloexec(int fd) >>   Â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__sprintf(gc, "/libxl/%d/dm-version", domid); >> +  Â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) { > > I think this should be a fatal error, if you've managed to read > something from this key and it isn't one of the expect values then > something bad has happened. Yes, I will change this to a fatal error. >> +    Âreturn LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; >> +  Â} >> +  Âreturn value; >> +} >> + >> Â/* >>  * Local variables: >>  * mode: C >> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h >> index 2e26ac6..5720b31 100644 >> --- a/tools/libxl/libxl_internal.h >> +++ b/tools/libxl/libxl_internal.h >> @@ -554,6 +554,11 @@ _hidden void libxl__json_object_free(libxl__gc *gc, >> libxl__json_object *obj); >> >> Â_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 >> >> Â/* -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |