[PATCH 11/11] tools/xl: add support for xenstore quota setting via domain config

Juergen Gross posted 11 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH 11/11] tools/xl: add support for xenstore quota setting via domain config
Posted by Juergen Gross 1 month, 1 week ago
Add a new "xenstore-quota" domain config parameter for setting the
Xenstore quota of a new domain via a list of <quota>=<val> items.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 docs/man/xl.cfg.5.pod.in | 13 +++++++++++++
 tools/xl/xl_parse.c      | 23 ++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index 27c455210b..3aac0bc4fb 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -748,6 +748,19 @@ via the B<xl info -x> command in dom0.
 The default value is B<0xffffffff>, meaning that all possible Xenstore
 features are visible by the guest.
 
+=item B<xenstore_quota=[ QUOTA_SPEC, QUOTA_SPEC, ...]>
+
+Specifies Xenstore quota values of the domain, overriding the default
+values of Xenstore.
+
+Each B<QUOTA_SPEC> is a B<quota-name>=B<value> specification. The supported
+B<quota-name> identifiers can be obtained by the B<xl xenstore-quota-get -g>
+command. B<value> is a non-negative integer.
+
+As per-domain Xenstore quota are an optional Xenstore feature, the
+B<xenstore_quota> config parameter may not be supported by all Xenstore
+implementations.
+
 =back
 
 =head2 Devices
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 934ad4eeef..06a5b60736 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -1351,7 +1351,7 @@ void parse_config_data(const char *config_source,
     XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms,
                    *usbctrls, *usbdevs, *p9devs, *vdispls, *pvcallsifs_devs;
     XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs,
-                   *mca_caps, *smbios, *llc_colors;
+                   *mca_caps, *smbios, *llc_colors, *xs_quota;
     int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_caps;
     int num_smbios;
     int pci_power_mgmt = 0;
@@ -1360,6 +1360,7 @@ void parse_config_data(const char *config_source,
     int pci_seize = 0;
     int i, e;
     int num_llc_colors;
+    int num_xs_quota;
     char *kernel_basename;
 
     libxl_domain_create_info *c_info = &d_config->c_info;
@@ -1467,6 +1468,26 @@ void parse_config_data(const char *config_source,
     if (!xlu_cfg_get_long (config, "xenstore_feature_mask", &l, 0))
         b_info->xenstore_feature_mask = l;
 
+    if (!xlu_cfg_get_list(config, "xenstore_quota", &xs_quota, &num_xs_quota, 0)) {
+        b_info->xenstore_quota.num_quota = num_xs_quota;
+        b_info->xenstore_quota.quota = calloc(num_xs_quota, sizeof(* b_info->xenstore_quota.quota));
+        if (b_info->xenstore_quota.quota == NULL) {
+            fprintf(stderr, "unable to allocate memory for xenstore_quota\n");
+            exit(-1);
+        }
+
+        for (i = 0; i < num_xs_quota; i++) {
+           buf = xlu_cfg_get_listitem(xs_quota, i);
+           if (!buf) {
+                fprintf(stderr,
+                        "xl: Can't get element %d in Xenstore quota list\n", i);
+                exit(1);
+            }
+            if (parse_xsquota_item(buf, b_info->xenstore_quota.quota + i))
+                exit(1);
+        }
+    }
+
     libxl_domain_build_info_init_type(b_info, c_info->type);
 
     if (b_info->type == LIBXL_DOMAIN_TYPE_PVH) {
-- 
2.53.0
Re: [PATCH 11/11] tools/xl: add support for xenstore quota setting via domain config
Posted by Anthony PERARD 3 weeks, 3 days ago
On Thu, Mar 05, 2026 at 02:52:08PM +0100, Juergen Gross wrote:
> Add a new "xenstore-quota" domain config parameter for setting the

You mean `xenstore_quota` ^ here.

> Xenstore quota of a new domain via a list of <quota>=<val> items.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
> diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
> index 934ad4eeef..06a5b60736 100644
> --- a/tools/xl/xl_parse.c
> +++ b/tools/xl/xl_parse.c
> @@ -1467,6 +1468,26 @@ void parse_config_data(const char *config_source,
>      if (!xlu_cfg_get_long (config, "xenstore_feature_mask", &l, 0))
>          b_info->xenstore_feature_mask = l;
>  
> +    if (!xlu_cfg_get_list(config, "xenstore_quota", &xs_quota, &num_xs_quota, 0)) {
> +        b_info->xenstore_quota.num_quota = num_xs_quota;
> +        b_info->xenstore_quota.quota = calloc(num_xs_quota, sizeof(* b_info->xenstore_quota.quota));

You can call xcalloc() instead, and then not need to check for
allocation failure.

And with the two changes: Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>

Thanks,


--
Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
Re: [PATCH 11/11] tools/xl: add support for xenstore quota setting via domain config
Posted by Jürgen Groß 3 weeks, 3 days ago
On 19.03.26 14:06, Anthony PERARD wrote:
> On Thu, Mar 05, 2026 at 02:52:08PM +0100, Juergen Gross wrote:
>> Add a new "xenstore-quota" domain config parameter for setting the
> 
> You mean `xenstore_quota` ^ here.
> 
>> Xenstore quota of a new domain via a list of <quota>=<val> items.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
>> index 934ad4eeef..06a5b60736 100644
>> --- a/tools/xl/xl_parse.c
>> +++ b/tools/xl/xl_parse.c
>> @@ -1467,6 +1468,26 @@ void parse_config_data(const char *config_source,
>>       if (!xlu_cfg_get_long (config, "xenstore_feature_mask", &l, 0))
>>           b_info->xenstore_feature_mask = l;
>>   
>> +    if (!xlu_cfg_get_list(config, "xenstore_quota", &xs_quota, &num_xs_quota, 0)) {
>> +        b_info->xenstore_quota.num_quota = num_xs_quota;
>> +        b_info->xenstore_quota.quota = calloc(num_xs_quota, sizeof(* b_info->xenstore_quota.quota));
> 
> You can call xcalloc() instead, and then not need to check for
> allocation failure.
> 
> And with the two changes: Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>

Thanks,


Juergen