From nobody Mon Apr 13 03:42:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1772719099353611.6820343149838; Thu, 5 Mar 2026 05:58:19 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1246748.1545868 (Exim 4.92) (envelope-from ) id 1vy9DK-0004t4-Hw; Thu, 05 Mar 2026 13:58:06 +0000 Received: by outflank-mailman (output) from mailman id 1246748.1545868; Thu, 05 Mar 2026 13:58:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vy9DK-0004rp-Cg; Thu, 05 Mar 2026 13:58:06 +0000 Received: by outflank-mailman (input) for mailman id 1246748; Thu, 05 Mar 2026 13:58:04 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vy98U-00008m-Nz for xen-devel@lists.xenproject.org; Thu, 05 Mar 2026 13:53:06 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a217b1b9-189a-11f1-9ccf-f158ae23cfc8; Thu, 05 Mar 2026 14:53:05 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C4B155BDE2; Thu, 5 Mar 2026 13:53:04 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A8D5B3EA68; Thu, 5 Mar 2026 13:53:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Dg0lKMCKqWkmTwAAD6G6ig (envelope-from ); Thu, 05 Mar 2026 13:53:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a217b1b9-189a-11f1-9ccf-f158ae23cfc8 Authentication-Results: smtp-out2.suse.de; none From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Anthony PERARD Subject: [PATCH 10/11] tools/xl: add xl commands for xenstore quota operations Date: Thu, 5 Mar 2026 14:52:07 +0100 Message-ID: <20260305135208.2208663-11-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260305135208.2208663-1-jgross@suse.com> References: <20260305135208.2208663-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: C4B155BDE2 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-ZM-MESSAGEID: 1772719099675154100 Content-Type: text/plain; charset="utf-8" Add "xl xenstore-quota-get" and "xl xenstore-quota-set" commands for retrieving and setting global and per-domain Xenstore quota. Signed-off-by: Juergen Gross --- tools/xl/Makefile | 1 + tools/xl/xl.h | 2 + tools/xl/xl_cmdtable.c | 10 +++++ tools/xl/xl_parse.c | 25 ++++++++++++ tools/xl/xl_parse.h | 1 + tools/xl/xl_xsquota.c | 88 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 127 insertions(+) create mode 100644 tools/xl/xl_xsquota.c diff --git a/tools/xl/Makefile b/tools/xl/Makefile index 973ff0e1a2..e4eed8be13 100644 --- a/tools/xl/Makefile +++ b/tools/xl/Makefile @@ -24,6 +24,7 @@ XL_OBJS +=3D xl_sched.o xl_pci.o xl_vcpu.o xl_cdrom.o xl_= mem.o XL_OBJS +=3D xl_info.o xl_console.o xl_misc.o XL_OBJS +=3D xl_vmcontrol.o xl_saverestore.o xl_migrate.o XL_OBJS +=3D xl_vdispl.o xl_vsnd.o xl_vkb.o +XL_OBJS +=3D xl_xsquota.o =20 $(XL_OBJS): CFLAGS +=3D $(CFLAGS_libxentoollog) $(XL_OBJS): CFLAGS +=3D $(CFLAGS_XL) diff --git a/tools/xl/xl.h b/tools/xl/xl.h index 9000df00de..0efc07a6ba 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -217,6 +217,8 @@ int main_psr_mba_set(int argc, char **argv); int main_psr_mba_show(int argc, char **argv); #endif int main_qemu_monitor_command(int argc, char **argv); +int main_xsquota_get(int argc, char **argv); +int main_xsquota_set(int argc, char **argv); =20 void help(const char *command); =20 diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 06a0039718..3de12b12ae 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -649,6 +649,16 @@ const struct cmd_spec cmd_table[] =3D { "-h print this help\n" }, #endif + { "xenstore-quota-get", + &main_xsquota_get, 0, 0, + "List global or domain specific Xenstore quota data", + "|-g", + }, + { "xenstore-quota-set", + &main_xsquota_set, 0, 1, + "Set global or domain specific Xenstore quota data", + "|-g =3D...", + }, }; =20 const int cmdtable_len =3D ARRAY_SIZE(cmd_table); diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 1a2ea8b5d5..934ad4eeef 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1314,6 +1314,31 @@ out: return ret; } =20 +int parse_xsquota_item(const char *buf, struct libxl_xs_quota_item *item) +{ + const char *eq; + char *endptr; + + eq =3D strchr(buf, '=3D'); + if (!eq) { + fprintf(stderr, "Quota specification \"%s\" lacks \"=3D\".\n", buf= ); + return ERROR_INVAL; + } + errno =3D 0; + item->name =3D strndup(buf, eq - buf); + if (!item->name) + return ERROR_NOMEM; + item->val =3D strtoul(eq + 1, &endptr, 0); + if (errno || !eq[1] || *endptr) { + fprintf(stderr, + "Quota specification \"%s\" uses illegal value \"%s\".\n", + buf, eq); + return ERROR_INVAL; + } + + return 0; +} + void parse_config_data(const char *config_source, const char *config_data, int config_len, diff --git a/tools/xl/xl_parse.h b/tools/xl/xl_parse.h index fe0d586cdd..57bb43a067 100644 --- a/tools/xl/xl_parse.h +++ b/tools/xl/xl_parse.h @@ -36,6 +36,7 @@ int parse_nic_config(libxl_device_nic *nic, XLU_Config **= config, char *token); int parse_vdispl_config(libxl_device_vdispl *vdispl, char *token); int parse_vsnd_item(libxl_device_vsnd *vsnd, const char *spec); int parse_vkb_config(libxl_device_vkb *vkb, char *token); +int parse_xsquota_item(const char *buf, struct libxl_xs_quota_item *item); =20 int match_option_size(const char *prefix, size_t len, char *arg, char **argopt); diff --git a/tools/xl/xl_xsquota.c b/tools/xl/xl_xsquota.c new file mode 100644 index 0000000000..eaf19feac8 --- /dev/null +++ b/tools/xl/xl_xsquota.c @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: LGPL-2.1-only */ + +#include +#include +#include +#include + +#include "xl.h" +#include "xl_utils.h" +#include "xl_parse.h" + +int main_xsquota_get(int argc, char **argv) +{ + libxl_xs_quota_set q; + unsigned int i; + int rc; + + if (argc !=3D 2) { + fprintf(stderr, "Domain or \"-g\" must be specified.\n"); + return EXIT_FAILURE; + } + + if (!strcmp(argv[1], "-g")) { + rc =3D libxl_xsquota_global_get(ctx, &q); + } else { + uint32_t domid =3D find_domain(argv[1]); + + rc =3D libxl_xsquota_domain_get(ctx, domid, &q); + } + + if (rc) { + fprintf(stderr, "Quota could not be obtained.\n"); + return EXIT_FAILURE; + } + + printf("Quota name Quota value\n"); + printf("--------------------------------\n"); + for (i =3D 0; i < q.num_quota; i++) + printf("%-20s %8u\n", q.quota[i].name, q.quota[i].val); + + libxl_xs_quota_set_dispose(&q); + + return EXIT_SUCCESS; +} + +int main_xsquota_set(int argc, char **argv) +{ + unsigned int i; + libxl_xs_quota_set q; + int rc =3D EXIT_FAILURE; + + if (argc < 3) { + fprintf(stderr, "Not enough parameters.\n"); + return EXIT_FAILURE; + } + + q.num_quota =3D argc - 2; + q.quota =3D calloc(q.num_quota, sizeof(*q.quota)); + if (!q.quota) { + fprintf(stderr, "Memory allocation failure!\n"); + goto err; + } + + for (i =3D 2; i < argc; i++) { + if (parse_xsquota_item(argv[i], q.quota + i - 2)) + goto err; + } + + if (!strcmp(argv[1], "-g")) { + rc =3D libxl_xsquota_global_set(ctx, &q); + } else { + uint32_t domid =3D find_domain(argv[1]); + + rc =3D libxl_xsquota_domain_set(ctx, domid, &q); + } + + if (rc) { + fprintf(stderr, "Quota could not be set.\n"); + rc =3D EXIT_FAILURE; + } else { + rc =3D EXIT_SUCCESS; + } + + err: + libxl_xs_quota_set_dispose(&q); + + return rc; +} --=20 2.53.0