From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>, Julien Grall <julien@xen.org>,
Anthony PERARD <anthony.perard@vates.tech>
Subject: [PATCH 06/11] tools/xenstored: add infrastructure for per-domain quotas
Date: Thu, 5 Mar 2026 14:52:03 +0100 [thread overview]
Message-ID: <20260305135208.2208663-7-jgross@suse.com> (raw)
In-Reply-To: <20260305135208.2208663-1-jgross@suse.com>
Add the needed structures and helper functions for supporting quotas
per domain.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
tools/xenstored/domain.c | 59 ++++++++++++++++++++++++++++++----------
1 file changed, 44 insertions(+), 15 deletions(-)
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 9bd3ac7aca..8e52351695 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -389,6 +389,9 @@ void wrl_apply_debit_trans_commit(struct connection *conn)
static unsigned int domain_get_soft_quota(struct domain *d, enum accitem what)
{
+ if (d && d->acc[what].val[Q_IDX_SOFT] != Q_VAL_DISABLED)
+ return d->acc[what].val[Q_IDX_SOFT];
+
return quotas[what].val[Q_IDX_SOFT];
}
@@ -397,6 +400,9 @@ static bool domain_check_quota_val(struct domain *d, enum accitem what,
{
unsigned int quota = quotas[what].val[Q_IDX_HARD];
+ if (d->acc[what].val[Q_IDX_HARD] != Q_VAL_DISABLED)
+ quota = d->acc[what].val[Q_IDX_HARD];
+
if (!quota || !domid_is_unprivileged(d->domid))
return false;
@@ -809,6 +815,7 @@ static struct domain *alloc_domain(const void *context, unsigned int domid,
uint64_t unique_id)
{
struct domain *domain;
+ unsigned int q;
domain = talloc_zero(context, struct domain);
if (!domain) {
@@ -822,6 +829,11 @@ static struct domain *alloc_domain(const void *context, unsigned int domid,
domain->introduced = false;
domain->features = XENSTORE_FEATURES;
+ for (q = 0; q < ACC_N; q++) {
+ domain->acc[q].val[Q_IDX_HARD] = quotas[q].val[Q_IDX_HARD];
+ domain->acc[q].val[Q_IDX_SOFT] = quotas[q].val[Q_IDX_SOFT];
+ }
+
if (hashtable_add(domhash, &domain->domid, domain)) {
talloc_free(domain);
errno = ENOMEM;
@@ -2079,25 +2091,38 @@ static int dump_state_domain(const void *k, void *v, void *arg)
{
struct domain *domain = v;
FILE *fp = arg;
- struct xs_state_domain sd;
- struct xs_state_record_header head;
-
- head.type = XS_STATE_TYPE_DOMAIN;
- head.length = sizeof(sd);
- memset(&sd, 0, sizeof(sd));
- sd.domain_id = domain->domid;
+ struct xs_state_domain *sd;
+ struct xs_state_record_header *head;
+ void *record;
+ unsigned int n_quota;
+ unsigned int len = sizeof(*sd);
+ size_t ret;
- if (lu_status->version > 1)
- sd.features = domain->features;
+ n_quota = get_quota_size(domain->acc, &len);
+ len += n_quota * sizeof(sd->quota_val[0]);
+ len = ROUNDUP(len, 3);
- if (fwrite(&head, sizeof(head), 1, fp) != 1)
- return 1;
- if (fwrite(&sd, sizeof(sd), 1, fp) != 1)
- return 1;
- if (dump_state_align(fp))
+ record = talloc_size(NULL, len + sizeof(*head));
+ if (!record)
return 1;
- return 0;
+ head = record;
+ head->type = XS_STATE_TYPE_DOMAIN;
+ head->length = len;
+
+ sd = (struct xs_state_domain *)(head + 1);
+ sd->domain_id = domain->domid;
+ sd->n_quota = n_quota;
+ sd->features = (lu_status->version > 1) ? domain->features : 0;
+
+ build_quota_data(domain->acc, sd->quota_val,
+ (char *)(sd->quota_val + n_quota));
+
+ ret = fwrite(record, len + sizeof(*head), 1, fp);
+
+ talloc_free(record);
+
+ return (ret != 1 || dump_state_align(fp)) ? 1 : 0;
}
const char *dump_state_domains(FILE *fp)
@@ -2114,6 +2139,8 @@ void read_state_domain(const void *ctx, const void *state, unsigned int version)
{
const struct xs_state_domain *sd = state;
struct domain *domain;
+ unsigned int n_quota = sd->n_quota;
+ const char *name = (const char *)(sd->quota_val + n_quota);
domain = find_domain_struct(sd->domain_id);
if (!domain)
@@ -2121,6 +2148,8 @@ void read_state_domain(const void *ctx, const void *state, unsigned int version)
if (version > 1)
domain->features = sd->features;
+
+ parse_quota_data(sd->quota_val, name, n_quota, domain->acc);
}
const char *dump_state_glb_quota(FILE *fp)
--
2.53.0
next prev parent reply other threads:[~2026-03-05 13:52 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 13:51 [PATCH 00/11] tools: add support for per-domain xenstore quota Juergen Gross
2026-03-05 13:51 ` [PATCH 01/11] tools/libs/store: add get- and set-quota related functions Juergen Gross
2026-03-13 14:23 ` Anthony PERARD
2026-03-16 7:51 ` Jürgen Groß
2026-03-19 13:31 ` Anthony PERARD
2026-03-05 13:51 ` [PATCH 02/11] tools/xenstored: add central quota check functions Juergen Gross
2026-03-13 15:01 ` Anthony PERARD
2026-03-16 7:53 ` Jürgen Groß
2026-03-13 21:22 ` Jason Andryuk
2026-03-16 8:18 ` Jürgen Groß
2026-03-05 13:52 ` [PATCH 03/11] tools/xenstored: rework hard_quotas and soft_quotas arrays Juergen Gross
2026-03-13 16:09 ` Anthony PERARD
2026-03-05 13:52 ` [PATCH 04/11] tools/xenstored: add GLOBAL_QUOTA_DATA record for live update Juergen Gross
2026-03-13 17:08 ` Anthony PERARD
2026-03-16 8:15 ` Jürgen Groß
2026-03-18 12:16 ` Juergen Gross
2026-03-19 16:15 ` Anthony PERARD
2026-03-19 16:31 ` Jürgen Groß
2026-03-19 15:59 ` Anthony PERARD
2026-03-05 13:52 ` [PATCH 05/11] tools/xenstored: split acc[] array in struct domain Juergen Gross
2026-03-13 17:15 ` Anthony PERARD
2026-03-05 13:52 ` Juergen Gross [this message]
2026-03-13 17:32 ` [PATCH 06/11] tools/xenstored: add infrastructure for per-domain quotas Anthony PERARD
2026-03-16 8:17 ` Jürgen Groß
2026-03-05 13:52 ` [PATCH 07/11] tools/xenstored: implement the GET/SET_QUOTA commands Juergen Gross
2026-03-16 15:08 ` Anthony PERARD
2026-03-16 15:27 ` Juergen Gross
2026-03-19 16:47 ` Anthony PERARD
2026-03-20 6:36 ` Jürgen Groß
2026-03-05 13:52 ` [PATCH 08/11] tools/libxl: add functions for retrieving and setting xenstore quota Juergen Gross
2026-03-10 13:58 ` Nick Rosbrook
2026-03-19 9:11 ` Anthony PERARD
2026-03-19 11:00 ` Jürgen Groß
2026-03-05 13:52 ` [PATCH 09/11] tools/libxl: add support for xenstore quota in domain_config Juergen Gross
2026-03-10 13:57 ` Nick Rosbrook
2026-03-19 9:26 ` Anthony PERARD
2026-03-19 11:01 ` Jürgen Groß
2026-03-05 13:52 ` [PATCH 10/11] tools/xl: add xl commands for xenstore quota operations Juergen Gross
2026-03-19 12:37 ` Anthony PERARD
2026-03-19 13:06 ` Jürgen Groß
2026-03-05 13:52 ` [PATCH 11/11] tools/xl: add support for xenstore quota setting via domain config Juergen Gross
2026-03-19 13:06 ` Anthony PERARD
2026-03-19 13:11 ` Jürgen Groß
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260305135208.2208663-7-jgross@suse.com \
--to=jgross@suse.com \
--cc=anthony.perard@vates.tech \
--cc=julien@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.