@@ -99,8 +99,8 @@ struct changed_domain
/* Identifier of the changed domain. */
unsigned int domid;
- /* Amount by which this domain's nbentry field has changed. */
- int nbentry;
+ /* Accounting data. */
+ int acc[ACC_TR_N];
};
static struct hashtable *domhash;
@@ -550,7 +550,7 @@ int acc_fix_domains(struct list_head *head, bool chk_quota, bool update)
int cnt;
list_for_each_entry(cd, head, list) {
- cnt = domain_nbentry_fix(cd->domid, cd->nbentry, update);
+ cnt = domain_nbentry_fix(cd->domid, cd->acc[ACC_NODES], update);
if (!update) {
if (chk_quota && cnt >= quota_nb_entry_per_domain)
return ENOSPC;
@@ -595,19 +595,21 @@ static struct changed_domain *acc_get_changed_domain(const void *ctx,
return cd;
}
-static int acc_add_dom_nbentry(const void *ctx, struct list_head *head, int val,
- unsigned int domid)
+static int acc_add_changed_dom(const void *ctx, struct list_head *head,
+ enum accitem what, int val, unsigned int domid)
{
struct changed_domain *cd;
+ assert(what < ARRAY_SIZE(cd->acc));
+
cd = acc_get_changed_domain(ctx, head, domid);
if (!cd)
return 0;
errno = 0;
- cd->nbentry += val;
+ cd->acc[what] += val;
- return cd->nbentry;
+ return cd->acc[what];
}
static void domain_conn_reset(struct domain *domain)
@@ -1071,7 +1073,8 @@ static int domain_nbentry_add(struct connection *conn, unsigned int domid,
if (conn && conn->transaction) {
head = transaction_get_changed_domains(conn->transaction);
- ret = acc_add_dom_nbentry(conn->transaction, head, add, domid);
+ ret = acc_add_changed_dom(conn->transaction, head, ACC_NODES,
+ add, domid);
if (errno) {
fail_transaction(conn->transaction);
return -1;
@@ -19,6 +19,16 @@
#ifndef _XENSTORED_DOMAIN_H
#define _XENSTORED_DOMAIN_H
+/*
+ * All accounting data is stored in a per-domain array.
+ * Depending on the account item there might be other scopes as well, like e.g.
+ * a per transaction array.
+ */
+enum accitem {
+ ACC_NODES,
+ ACC_TR_N, /* Number of elements per transaction. */
+};
+
void handle_event(void);
void check_domains(void);