From nobody Mon Mar 23 21:24:11 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=1774019312; cv=none; d=zohomail.com; s=zohoarc; b=oD5yds/1artlLoZHCrakkdnBOSzRRq0eT/wzfOAD8KBp8Mq7fXGv0yD6PtT3k9R0WvlA+MtbA9fVj/yvUElE+z/6tAzIM7HYNsQUazRSyJp1wbbIhv9zKIOHjpwveBmy/cSzeo2fZDFSdDnbyocaoTSvwh3zKyBHjAwadc8vDIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774019312; 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=1FYqa2/aDourOwOzPQpClM0FHHXiPvq6a2dggyIoDDM=; b=cKhwPNnTY8FZYATIMgWSH9CxSBiJl7SjppO9p84TE6WXPcwdW/n2Fi+0yaP2kqlnrs381dArjjG+qLlfoseCsYn+s8z7wQzKFfhPbpUA1QYqqYoEkGd1czeknh9/lkcIUULhlCTTAl2yscnC+Bb1/HslOCbxDzhmN7944SmTCWw= 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 1774019312571662.9090812179644; Fri, 20 Mar 2026 08:08:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1258182.1552347 (Exim 4.92) (envelope-from ) id 1w3bSS-0007Fr-JG; Fri, 20 Mar 2026 15:08:16 +0000 Received: by outflank-mailman (output) from mailman id 1258182.1552347; Fri, 20 Mar 2026 15:08:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w3bSS-0007Fk-FN; Fri, 20 Mar 2026 15:08:16 +0000 Received: by outflank-mailman (input) for mailman id 1258182; Fri, 20 Mar 2026 15:08:15 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w3bMX-0001Ve-1c for xen-devel@lists.xenproject.org; Fri, 20 Mar 2026 15:02:09 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c3e99463-246d-11f1-b164-2bf370ae4941; Fri, 20 Mar 2026 16:02:08 +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-out1.suse.de (Postfix) with ESMTPS id 95F194D27B; Fri, 20 Mar 2026 15:02:05 +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 7554842866; Fri, 20 Mar 2026 15:02:05 +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 WniTG21hvWnjXAAAD6G6ig (envelope-from ); Fri, 20 Mar 2026 15:02:05 +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: c3e99463-246d-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1774018925; 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=1FYqa2/aDourOwOzPQpClM0FHHXiPvq6a2dggyIoDDM=; b=GBtKCSZwN71iawlNf2pdCyt1/RIcOJvcvlCzBXxiUw9lJ3UlgYmfNyl0TpI9JaBza2xR3j U1xys8D+qc99q0qW6tZAJkGgtHP6N1vAwlzKluHiAjEcQIW0hYZsydiSupsejnib/pRHOO UcDO6GqdG3/Nosj9LHy+qMiFcxLMPeg= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1774018925; 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=1FYqa2/aDourOwOzPQpClM0FHHXiPvq6a2dggyIoDDM=; b=GBtKCSZwN71iawlNf2pdCyt1/RIcOJvcvlCzBXxiUw9lJ3UlgYmfNyl0TpI9JaBza2xR3j U1xys8D+qc99q0qW6tZAJkGgtHP6N1vAwlzKluHiAjEcQIW0hYZsydiSupsejnib/pRHOO UcDO6GqdG3/Nosj9LHy+qMiFcxLMPeg= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH v2 08/12] tools/xenstored: implement the GET/SET_QUOTA commands Date: Fri, 20 Mar 2026 16:01:16 +0100 Message-ID: <20260320150120.874878-9-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260320150120.874878-1-jgross@suse.com> References: <20260320150120.874878-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.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.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:mid,suse.com:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1774019315223154100 Content-Type: text/plain; charset="utf-8" Add the implementation of the GET_QUOTA and SET_QUOTA wire commands. Signed-off-by: Juergen Gross Reviewed-by: Anthony PERARD --- V2: - refuse quota value Q_VAL_DISABLED (Anthony Perard) - use talloc_strdup() (Anthony Perard) - drop comments in domain.h (Anthony Perard) --- tools/xenstored/core.c | 4 ++ tools/xenstored/domain.c | 111 +++++++++++++++++++++++++++++++++++++++ tools/xenstored/domain.h | 5 ++ 3 files changed, 120 insertions(+) diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c index dc63c97658..4786a2a82e 100644 --- a/tools/xenstored/core.c +++ b/tools/xenstored/core.c @@ -2035,6 +2035,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 7a8d285e64..1684f6dee7 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -1399,6 +1399,117 @@ 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_strdup(ctx, ""); + 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, "%s%s%s", + *resp ? " " : "", SOFT_PREFIX, + 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 parse_domid(vec[0]); + if (errno) + return errno; + 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 parse_domid(vec[0]); + if (errno) + return errno; + 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) || val =3D=3D Q_VAL_DISABLED) + 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 8f23a82854..ca38b5e0ea 100644 --- a/tools/xenstored/domain.h +++ b/tools/xenstored/domain.h @@ -93,6 +93,11 @@ 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 +int do_get_quota(const void *ctx, struct connection *conn, + struct buffered_data *in); +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