[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] libxl: Add "grant_usage" parameter for virtio disk devices


  • To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • From: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>
  • Date: Mon, 5 Feb 2024 16:52:16 +0000
  • Accept-language: en-US, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9hH4fDEl3SduQIsesqnjYXAGmusAaoKxOQK7fjzydhE=; b=ny452bJCAZZer+jwQcnuIZVXgf7c3YtaEwvdd1oAttfpXfNZJAass2TuIRYfb+Phq3cJz+ZHf33DyGaZ3+6/0pdFsXww6GZgcmfWgCMwq5+mbq0LCxJTGGpSv1r5a+vrwByJ5Qxai6y6EatmkyXkJAmGrU6voFGukAwRnpZ6YCVrSQOweNv6OZ058EMo57/6RLtWXBgKLpx8QN3fgPTDRDMKXsV4wr63Cyus7aKZORUQH1FLDmGTPmgd3I6r52qNsR6ubaV2sMPcsvDnljR8vQTI/vmyKdTepdOy6CAXuew9+x2TP/TFMiNgNfyGGN+mIY2H1wPOmYmGALcMWmXHxQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HZJ47ThzbMwGwcntNa7tFv2XcqQgiyASQ8/jfJxTRcbprxGOIG3cBnUQdE8peA6Qz2nENpzXroodqe97GMMXAVTrzq8WLivkScRkGNoI71x6YuZm0+NNR1zSctfly2Zoamv8iIqRLg4nx1dKQ7GhMmKUaHaY9oEqFgh2UqxTamok7mQecOpF0/lqrB7zM8ZuqoiAfBja9uPxVsqUPFw6gKii9buTxGv6v/Pb5MynY/fAqesqO9NgELImm1f0P1h9Tb9NLYhTqdNl3KsFKs7PCpaLg1dP/ETh53jF/3aJmvEFR6gR6w+3Deu8KNa1H+NJytiLrJsO8Dv4FMgVnAI3qg==
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Oleksandr Tyshchenko <olekstysh@xxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Nick Rosbrook <rosbrookn@xxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Viresh Kumar <viresh.kumar@xxxxxxxxxx>
  • Delivery-date: Mon, 05 Feb 2024 16:52:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHaVcWXJV0m8uwkbEKeSgAhd5N6SLD734GAgAAcRoA=
  • Thread-topic: [PATCH] libxl: Add "grant_usage" parameter for virtio disk devices


On 05.02.24 17:10, Anthony PERARD wrote:

Hello Anthony


> On Fri, Feb 02, 2024 at 12:49:03PM +0200, Oleksandr Tyshchenko wrote:
>> diff --git a/tools/libs/util/libxlu_disk_l.l 
>> b/tools/libs/util/libxlu_disk_l.l
>> index 6d53c093a3..f37dd443bd 100644
>> --- a/tools/libs/util/libxlu_disk_l.l
>> +++ b/tools/libs/util/libxlu_disk_l.l
>> @@ -220,6 +220,9 @@ hidden-disk=[^,]*,?      { STRIP(','); 
>> SAVESTRING("hidden-disk", hidden_disk, FROMEQU
>>   trusted,?          { libxl_defbool_set(&DPC->disk->trusted, true); }
>>   untrusted,?                { libxl_defbool_set(&DPC->disk->trusted, 
>> false); }
>>   
>> +grant_usage=1,?             { libxl_defbool_set(&DPC->disk->grant_usage, 
>> true); }
>> +grant_usage=0,?             { libxl_defbool_set(&DPC->disk->grant_usage, 
>> false); }
> 
> For other boolean type for the disk, we have "trusted/untrusted",
> "discard/no-discard", "direct-io-save/", but you are adding
> "grant_usage=1/grant_usage=0". Is that fine? But I guess having the new
> option spelled "grant_usage" might be better, so it match the other
> virtio devices and the implementation. 


Yes, I noticed that how booleans are described for the disk. I decided 
to use the same representation of this option as it was already used for 
virtio=[...]. But I would be ok with other variants ...


But maybe
> "use-grant/no-use-grant" might be ok?

   ... like that, but preferably with leaving libxl_device_disk's field 
named "grant_usage" (if no objection).


> 
> In any case, the implementation need to match the documentation, and
> vice versa. See below.


Sure.


> 
>> diff --git a/docs/man/xl-disk-configuration.5.pod.in 
>> b/docs/man/xl-disk-configuration.5.pod.in
>> index bc945cc517..3c035456d5 100644
>> --- a/docs/man/xl-disk-configuration.5.pod.in
>> +++ b/docs/man/xl-disk-configuration.5.pod.in
>> @@ -404,6 +404,31 @@ Virtio frontend driver (virtio-blk) to be used. Please 
>> note, the virtual
>> +=item B<grant_usage=BOOLEAN>
>>
>> +=over 4
>> +
>> +=item Description
>> +
>> +Specifies the usage of Xen grants for accessing guest memory. Only 
>> applicable
>> +to specification "virtio".
>> +
>> +=item Supported values
>> +
>> +If this option is B<true>, the Xen grants are always enabled.
>> +If this option is B<false>, the Xen grants are always disabled.
> 
> Unfortunately, this is wrong, the implementation in the patch only
> support two values: 1 / 0, nothing else, and trying to write "true" or
> "false" would lead to an error. (Well actually it's "grant_usage=1" or
> "grant_usage=0", there's nothing that cut that string at the '='.)


You are right, only 1 / 0 can be set unlike for virtio=[...] which seems 
happy with false/true.


> 
> Also, do we really need the extra verbal description of each value here?
> Is simply having the following would be enough?
> 
>      =item Supported values
> 
>      1, 0
> 
> The description in "Description" section would hopefully be enough.


I think, this makes sense.

So, shall I leave "grant_usage=1/grant_usage=0" or use proposed option 
"use-grant/no-use-grant"?


> 
>> +=item Mandatory
>> +
>> +No
>> +
>> +=item Default value
>> +
>> +If this option is missing, then the default grant setting will be used,
>> +i.e. enable grants if backend-domid != 0.
>> +
>> +=back
>> +
>> diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c
>> index ea3623dd6f..f39f427091 100644
>> --- a/tools/libs/light/libxl_disk.c
>> +++ b/tools/libs/light/libxl_disk.c
>> @@ -181,6 +181,9 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, 
>> uint32_t domid,
>>               return ERROR_INVAL;
>>           }
>>           disk->transport = LIBXL_DISK_TRANSPORT_MMIO;
>> +
>> +        libxl_defbool_setdefault(&disk->grant_usage,
>> +                                 disk->backend_domid != 
>> LIBXL_TOOLSTACK_DOMID);
>>       }
>>   
>>       if (hotplug && disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) 
>> {
>> @@ -429,6 +432,8 @@ static void device_disk_add(libxl__egc *egc, uint32_t 
>> domid,
>>               flexarray_append(back, 
>> libxl__device_disk_string_of_transport(disk->transport));
>>               flexarray_append_pair(back, "base", GCSPRINTF("%"PRIu64, 
>> disk->base));
>>               flexarray_append_pair(back, "irq", GCSPRINTF("%u", disk->irq));
>> +            flexarray_append_pair(back, "grant_usage",
>> +                                  libxl_defbool_val(disk->grant_usage) ? 
>> "1" : "0");
>>           }
>>   
>>           flexarray_append(front, "backend-id");
>> @@ -623,6 +628,14 @@ static int libxl__disk_from_xenstore(libxl__gc *gc, 
>> const char *libxl_path,
>>               goto cleanup;
>>           }
>>           disk->irq = strtoul(tmp, NULL, 10);
>> +
>> +        tmp = libxl__xs_read(gc, XBT_NULL,
>> +                             GCSPRINTF("%s/grant_usage", libxl_path));
>> +        if (!tmp) {
>> +            LOG(ERROR, "Missing xenstore node %s/grant_usage", libxl_path);
>> +            goto cleanup;
> 
> I wonder if it's such a good idea to make this node mandatory. Could we
> just apply the default value if the path is missing? I don't think the
> value is going to be used anyway because I don't think from_xenstore() is
> used during guest creation, and it looks like "grant_usage" is only
> useful during guest creation. Also, the "grant_usage" node isn't
> mandatory in "libxl_virtio.c", so no need to do something different
> for disk.

I agree with your analysis, no need to raise an error if missing, let's 
apply a default value which is the result of "disk->backend_domid != 
LIBXL_TOOLSTACK_DOMID".


> 
>> +        }
>> +        libxl_defbool_set(&disk->grant_usage, strtoul(tmp, NULL, 0));
>>       }
>>   
>>       disk->vdev = xs_read(ctx->xsh, XBT_NULL,
> 
> Thanks,
> 

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.