From nobody Mon Apr 13 03:41:40 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; dkim=pass; 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=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1772719080; cv=none; d=zohomail.com; s=zohoarc; b=VIcoChpW7AMTXsK3qD2RLC/k83PkN0F7Zc8pD+XTA474k5YnpvcW2tfqRvqsl7hBN6MsaD1xu8AddrVefbuxmyCmuSz09RVSOY2ehUaIBtkQ2EgkfvyhOvpAOvqYTNoJQLgwQ5jF8ZOKB3JixYN+UTrkN0sC3XZ9SuDIEZQcE4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772719080; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=r+4ZO/KspblmGGLhGlNMkeWiLuNQLDCEDNiLJzLmjPY=; b=S+jxkH/W2BRPxNaEj/xMRP4E32brHbv9Gk1QW4vMwiF430MaRfLbS4yZ62r/bEE5SMRCpMUoB9qv9aY7wKRRdLbfGEdrNV3AKQYz2k/juoJUAjrCh1g5i/76dfcUlgpQ0a4cCaBmWM9Qq+4FUpX9jePyabWF3jqIiUBR4H6YBVs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1772719080194779.5193568060952; Thu, 5 Mar 2026 05:58:00 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1246734.1545847 (Exim 4.92) (envelope-from ) id 1vy9Cs-00049t-LP; Thu, 05 Mar 2026 13:57:38 +0000 Received: by outflank-mailman (output) from mailman id 1246734.1545847; Thu, 05 Mar 2026 13:57:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vy9Cs-00049m-I7; Thu, 05 Mar 2026 13:57:38 +0000 Received: by outflank-mailman (input) for mailman id 1246734; Thu, 05 Mar 2026 13:57:36 +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 1vy98F-00008m-5J for xen-devel@lists.xenproject.org; Thu, 05 Mar 2026 13:52:51 +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 98646d41-189a-11f1-9ccf-f158ae23cfc8; Thu, 05 Mar 2026 14:52:48 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [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 748E75BEC7; Thu, 5 Mar 2026 13:52:48 +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 54D0A3EA76; Thu, 5 Mar 2026 13:52:48 +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 n8KnE7CKqWkMTwAAD6G6ig (envelope-from ); Thu, 05 Mar 2026 13:52:48 +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: 98646d41-189a-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1772718768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r+4ZO/KspblmGGLhGlNMkeWiLuNQLDCEDNiLJzLmjPY=; b=foug50Oxl/72LzeH5fthq6evZ/egSmCWIwtKH48ES5xxykx8PW6vFp7YvV9Mk5NBiS9sHD F5t+nvvLv8VTVuuis5HKMRGA1ne++NR0kV7fF4xsW49Erk9v25T3ITR9kxMCy/FKdwT1PN hJ0HsStVaIIJo4y2pRJUcrQrHmg4Wd4= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1772718768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r+4ZO/KspblmGGLhGlNMkeWiLuNQLDCEDNiLJzLmjPY=; b=foug50Oxl/72LzeH5fthq6evZ/egSmCWIwtKH48ES5xxykx8PW6vFp7YvV9Mk5NBiS9sHD F5t+nvvLv8VTVuuis5HKMRGA1ne++NR0kV7fF4xsW49Erk9v25T3ITR9kxMCy/FKdwT1PN hJ0HsStVaIIJo4y2pRJUcrQrHmg4Wd4= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH 07/11] tools/xenstored: implement the GET/SET_QUOTA commands Date: Thu, 5 Mar 2026 14:52:04 +0100 Message-ID: <20260305135208.2208663-8-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-Spamd-Result: default: False [-6.79 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.19)[-0.964]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -6.79 X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1772719083626154100 Content-Type: text/plain; charset="utf-8" Add the implementation of the GET_QUOTA and SET_QUOTA wire commands. Signed-off-by: Juergen Gross --- tools/xenstored/core.c | 4 ++ tools/xenstored/domain.c | 106 +++++++++++++++++++++++++++++++++++++++ tools/xenstored/domain.h | 8 +++ 3 files changed, 118 insertions(+) diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c index 8a06b35808..e283d47184 100644 --- a/tools/xenstored/core.c +++ b/tools/xenstored/core.c @@ -2034,6 +2034,10 @@ static struct { { "GET_FEATURE", do_get_feature, XS_FLAG_PRIV }, [XS_SET_FEATURE] =3D { "SET_FEATURE", do_set_feature, XS_FLAG_PRIV }, + [XS_GET_QUOTA] =3D + { "GET_QUOTA", do_get_quota, XS_FLAG_PRIV }, + [XS_SET_QUOTA] =3D + { "SET_QUOTA", do_set_quota, XS_FLAG_PRIV }, }; =20 static const char *sockmsg_string(enum xsd_sockmsg_type type) diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index 8e52351695..c0bc8a3eb7 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -1363,6 +1363,112 @@ static bool parse_quota_name(const char *name, unsi= gned int *qidx, return true; } =20 +int do_get_quota(const void *ctx, struct connection *conn, + struct buffered_data *in) +{ + const char *vec[2]; + unsigned int n_pars; + unsigned int domid; + unsigned int q; + unsigned int idx; + char *resp; + const char *name; + const struct quota *quota; + const struct domain *domain; + + n_pars =3D get_strings(in, vec, ARRAY_SIZE(vec)); + + if (n_pars > 2) + return EINVAL; + + if (n_pars =3D=3D 0) { + resp =3D talloc_asprintf(ctx, "%s", ""); + if (!resp) + return ENOMEM; + for (q =3D 0; q < ACC_N; q++) { + if (!quota_adm[q].name) + continue; + if (quotas[q].val[Q_IDX_HARD] !=3D Q_VAL_DISABLED) { + resp =3D talloc_asprintf_append(resp, "%s%s", + *resp ? " " : "", quota_adm[q].name); + if (!resp) + return ENOMEM; + } + if (quotas[q].val[Q_IDX_SOFT] !=3D Q_VAL_DISABLED) { + resp =3D talloc_asprintf_append(resp, "%ssoft-%s", + *resp ? " " : "", quota_adm[q].name); + if (!resp) + return ENOMEM; + } + } + } else { + if (n_pars =3D=3D 1) { + quota =3D quotas; + name =3D vec[0]; + } else { + domid =3D atoi(vec[0]); + domain =3D find_or_alloc_existing_domain(domid); + if (!domain) + return ENOENT; + quota =3D domain->acc; + name =3D vec[1]; + } + + if (parse_quota_name(name, &q, &idx)) + return EINVAL; + + resp =3D talloc_asprintf(ctx, "%u", quota[q].val[idx]); + if (!resp) + return ENOMEM; + } + + send_reply(conn, XS_GET_QUOTA, resp, strlen(resp) + 1); + + return 0; +} + +int do_set_quota(const void *ctx, struct connection *conn, + struct buffered_data *in) +{ + const char *vec[3]; + unsigned int n_pars; + unsigned int domid; + unsigned int q; + unsigned int idx; + const char *name; + unsigned int val; + struct quota *quota; + struct domain *domain; + + n_pars =3D get_strings(in, vec, ARRAY_SIZE(vec)); + + if (n_pars < 2 || n_pars > 3) + return EINVAL; + + if (n_pars =3D=3D 2) { + quota =3D quotas; + name =3D vec[0]; + val =3D atoi(vec[1]); + } else { + domid =3D atoi(vec[0]); + domain =3D find_or_alloc_existing_domain(domid); + if (!domain) + return ENOENT; + quota =3D domain->acc; + name =3D vec[1]; + val =3D atoi(vec[2]); + } + + if (parse_quota_name(name, &q, &idx)) + return EINVAL; + + quota[q].val[idx] =3D val; + + send_ack(conn, XS_SET_QUOTA); + + return 0; +} + static int close_xgt_handle(void *_handle) { xengnttab_close(*(xengnttab_handle **)_handle); diff --git a/tools/xenstored/domain.h b/tools/xenstored/domain.h index 62ce3b3166..6a06b0d1af 100644 --- a/tools/xenstored/domain.h +++ b/tools/xenstored/domain.h @@ -93,6 +93,14 @@ int do_get_feature(const void *ctx, struct connection *c= onn, int do_set_feature(const void *ctx, struct connection *conn, struct buffered_data *in); =20 +/* Get quota names or value */ +int do_get_quota(const void *ctx, struct connection *conn, + struct buffered_data *in); + +/* Set quota value */ +int do_set_quota(const void *ctx, struct connection *conn, + struct buffered_data *in); + void domain_early_init(void); void domain_init(int evtfd); void init_domains(bool live_update); --=20 2.53.0