[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 02/11] tools/xenstored: add central quota check functions
- To: Juergen Gross <jgross@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jason Andryuk <jason.andryuk@xxxxxxx>
- Date: Fri, 13 Mar 2026 17:22:00 -0400
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Xvd9igOVGt5yIkkA6IPxQ0vwUtUeB67QYH/xMRh2gnU=; b=sKQQw8ZnaUA3s2qvvllwRbmHfSTjoelMlnun9/xqKarRusSzcIKGBIkgqDsEBwqsNbNVWEq6CjNhKEuYD+kSXA65L0J1uxpRJOz12HXWjYyt819DMFth4kHRdrCd7PLgBcgoM3ATlG1fUzwD9pjRKovX4Ynw9xidqUtOndlJO4FUvc3UxQhyMwJDz7vwiN/y3YyRxKlsJhULpFEkfdrW6aRT8BVFuuNJCVo2aJwaQaGThO4nl3/6L/hXmcNRWrLQPNHC3PMh+YcqBCkzj1imAnhepB4FVxkwEP6IzhrdHFUuJr8rTInoNGZoOqgV+6iqRdsAHW4MWAiEIzGJGRggZA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=U0vGFm8r2bIRwvefxB/LV4zZmDQsoGlLPCo76QFzO/5Jo026RfPBufvZfGvVpZI+ILCAr33hFt6a52gzOwu35zVhF2Q0EX84yKuwrDF0iRt6CVYgWjM47Z4b1N3nsDtYDgA/9x3CA5XGLX8W2fCvLQQBzJIJ8KAX26MJZ6cMJxxquzbguXv7wfdtBoh89sAr++/d/7OUVGKMzkokSMCUVKiGG+VEQa5dfqppCiuLgYd6Eb/y4tlrf2wyGIkf564f0dRRJVD3XeQw9wn7r+cqFiGfB0sA9DI7y+BKcbFJW3qLqRZe5DWBh5nA268BNITBEJ5E1P8s9cM0QD7P88P7lQ==
- Cc: Julien Grall <julien@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
- Delivery-date: Fri, 13 Mar 2026 21:22:34 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 2026-03-05 08:51, Juergen Gross wrote:
Add central functions for checking a value (either an absolute one or
the current domain value plus an offset) against a specific quota.
This is in preparation of introducing per-domain quota.
The required changes allow to drop the "update" parameter from
domain_nbentry_fix().
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index e453b3061f..1df9265ad5 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -389,6 +389,25 @@ void wrl_apply_debit_trans_commit(struct connection *conn)
wrl_apply_debit_actual(conn->domain);
}
+static bool domain_check_quota_val(struct domain *d, enum accitem what,
+ unsigned int val)
+{
+ unsigned int quota = hard_quotas[what].val;
+
+ if (!quota || !domid_is_unprivileged(d->domid))
+ return false;
+
+ return val >= quota;
Personally, I don't like the naming of *check* where the "good" return
is false. That seems backwards from what I expect. So I'd suggest
either flipping the return value or renaming. domain_quota_fail() or
something?
+}
+
+bool domain_check_quota_add(struct domain *d, enum accitem what, int add)
+{
+ if (add < 0 || !d)
+ return false;
+
+ return domain_check_quota_val(d, what, d->acc[what].val + add);
+}
+
static bool check_indexes(XENSTORE_RING_IDX cons, XENSTORE_RING_IDX prod)
{
return ((prod - cons) <= XENSTORE_RING_SIZE);
As an example, here "good" is true.
I see Anthony already gave an R-b, so just consider it as a suggestion.
Thanks,
Jason
|