WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH V2 04/11] libxl, Introduce dm-version xenstore ke

To: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH V2 04/11] libxl, Introduce dm-version xenstore key.
From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Date: Mon, 24 Oct 2011 16:22:55 +0100
Cc: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Mon, 24 Oct 2011 08:24:09 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=/bqX89ASBnTnqqJQCH/6hH0gNqiubCtIgPEft4gxMVw=; b=YknxvbRZ5MK2I9ifIDlEHozeIBbaFyJNW3E8MJ8ll7hRY+IT9NkNTpfVMWYVmiPX1j +1GwG9sR/4nWo3MJyc1yZzZc8vwOnh5JSmKivhPK1QOjFNpdEkSYE9wausPO/hfKSbRq rV3pdOndfEjCUU6ea0PVn+zaeCoFKSjx6heUE=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1319450320.3385.176.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1319133573-25891-1-git-send-email-anthony.perard@xxxxxxxxxx> <1319133573-25891-5-git-send-email-anthony.perard@xxxxxxxxxx> <1319450320.3385.176.camel@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>