On 13.03.26 16:01, Anthony PERARD wrote:
On Thu, Mar 05, 2026 at 02:51:59PM +0100, 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().

This patch changes the return value of do_watch(), from E2BIG to ENOSPC,
but that's not mention.

I can add a remark to the commit message.


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
@@ -490,10 +509,9 @@ static bool domain_can_read(struct connection *conn)
        if (domain_is_unprivileged(conn)) {
                if (domain->wrl_credit < 0)
                        return false;
-               if (domain->acc[ACC_OUTST].val >= hard_quotas[ACC_OUTST].val)
+               if (domain_check_quota_add(domain, ACC_OUTST, 0))

Is this change fixing a potential bug? As now we check if there's a
quota for OUTST.

This is just changing how the quota is tested.


                        return false;
-               if (domain->acc[ACC_MEM].val >= hard_quotas[ACC_MEM].val &&
-                   hard_quotas[ACC_MEM].val)
+               if (domain_check_quota_add(domain, ACC_MEM, 0))
                        return false;
        }
diff --git a/tools/xenstored/watch.c b/tools/xenstored/watch.c
index b66a9f1a39..36e4d33f22 100644
--- a/tools/xenstored/watch.c
+++ b/tools/xenstored/watch.c
@@ -220,8 +220,8 @@ int do_watch(const void *ctx, struct connection *conn, 
struct buffered_data *in)
                        return EEXIST;
        }
- if (domain_watch(conn) > hard_quotas[ACC_WATCH].val)
-               return E2BIG;
+       if (domain_check_quota_add(conn->domain, ACC_WATCH, 1))
+               return ENOSPC;

Change of return value here not mentionned, even if it now aligned with
the value returned in other places.

watch = add_watch(conn, vec[0], vec[1], relative, false);
        if (!watch)

Patch looks fine to me:
Reviewed-by: Anthony PERARD <[email protected]>

Thanks


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to