[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 05/21] libs/guest: introduce helper to fetch a domain cpu policy
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Tue, 13 Apr 2021 16:01:23 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7iRy9GuGFLyRtl5I3ssxtVqxdTgRXM3rmBhXql49R5s=; b=MoMjLFeu0eSqLBEE5jsaJGwqw91VgXzhDyNKaJCkxDk/dzuuoIxd2v2QsB+stqx+XE36pk9vYnBAIHm2PB7f2zfLWwemRZnTuv/J67xWMAyHOmLMGwwM3vJc+Ud0b71hjleeZzC2IiN3qTiwbuepmHARZ2RLp/0hrEKiseTLJFrh/JV2NnFrcG9+bYJDyXQ5MORivKUbs7vyD4NwsgU8P36kNp2NCQg4K1U5KL3Hr2ndm3M+0SjSpYfko/wt9qSWQpgt4SZKf0ftH5Iuj5/oiiGzlK2IjO8V/UWBOxDLSBDE/rBlxn5MzrWlVzcjGL8EChGyETiIOro/cy6CTcCMFw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S0UH35FCVfoJidA/NbGvIfQ3vUqiiuwkHizfhN7kk1PCBbY0ak1uc1hLgMNyCJQu1DcjqoSkOiVG929DUEtMzbyRKqR/npSRt5G2heuKv1vja9DpwDrRoKLP1cCM9uOK57O2fPhd1rGH7APqXW6uXREv/Chn1mF6EP2wGgJmZ4o90YfV4A9BRUjfxeVtxejr8aP4iS239Pa4Oe3HtZe09CvsIl3QdmPwXERqGItmSQboqPbFa85C4H+y76FGHRs6rG9UJujTJcqRbjrbTf+TeR1VpquUN5lZvRSIVPyHkxhT28XPkve2SBKONb6UFbX2APJHtrMQvVzzLyAPlTKR4w==
- Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
- Delivery-date: Tue, 13 Apr 2021 14:02:29 +0000
- Ironport-hdrordr: A9a23:25MGkK1424yXglONOf1kOwqjBTd3eYIsi2QD101hICF9Wvez0+ izgfUW0gL1gj4NWHcm3euNIrWEXGm0z/FIyKErF/OHUBP9sGWlaLtj44zr3iH6F0TFmtJ1/Z xLN5JzANiYNzVHpO7n/Qi1FMshytGb8KauwdzT1WtpUBsCUcBdxi1SYzzrdnFebg9AGJY/Cd 6g/cJBvTWtYjA6ac68C3kDUYH41qH2vbjhZgMLAANi1RmWgVqTmcPHOjW7/jNbaTNAxr8+7X PI+jaW2oyPu+y2oyWssVP7wI9RnLLau7l+LeyKzvMYMzD9zjuvDb4RIIGqmBAQjKWR5E0xkN /Kyi1QT/hbz3/KZGm6rV/M9mDboU8TwkTvw1OZnnfvyPaRLFlRa7sj9PBkWyDU5EY6sNZ33L gj5RPii7NtAQ7dhyO43tDUVnhR5zuJiEA/mu0ehWE3a/p4VJZtq+UkjSZoOaZFNif75Ic7Kf JpHcHR6d1HGGnqEUzxjy1BxsehUW80GQrDak8eutaN2zwTp3xhyVAErfZv0ksoxdYYcd1p9u 7EOqNnmPVnSdIXV7t0AKMkTdGsAmLAbBrQOAupUBvaPZBCH0iIh4/84b0z6u3vUocP1oEOlJ PIV04dnXIuemr1YPf+nKFjw1ToeiGQTD7twsZR69xSobvnXofmNiWFVRQHj9agmfMCGcfWMs zDea5+MrvGFy/DCIxJ1wrxV915Mn8FSvAYvd49R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AFaltWtpW+5ojlm4auHn20dfQGqAc6F2ZGni5+FalMqZLA4MF5 ePsuaVW2V+N1I+skYuIrMmId1UwYaDjQ6qf8+kJTmokH0YO8nYBP5Zk6pd83QLY9U+mDQgLjUh WcP3K+SC/fi+mHAjdpyn2nxrzjC8OxWZwAK7iwddoF0suc2Y5s3dRJlQVQtI0ASUojQTfHM8FC n+w=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Such helper is based on the existing functions to fetch a CPUID and
MSR policies, but uses the xc_cpu_policy_t type to return the data to
the caller.
No user of the interface introduced on the patch.
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Changes since v1:
- Uniformly return -1 on error from xc_cpu_policy_get_domain.
---
tools/include/xenctrl.h | 2 ++
tools/libs/guest/xg_cpuid_x86.c | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 187df5c5d2d..34d979d11da 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2599,6 +2599,8 @@ void xc_cpu_policy_destroy(xc_cpu_policy_t policy);
/* Retrieve a system policy, or get/set a domains policy. */
int xc_cpu_policy_get_system(xc_interface *xch, unsigned int policy_idx,
xc_cpu_policy_t policy);
+int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid,
+ xc_cpu_policy_t policy);
int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps);
int xc_get_cpu_featureset(xc_interface *xch, uint32_t index,
diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index 78fbc7db9d3..1394e503f3d 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -732,3 +732,28 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsigned
int policy_idx,
return rc;
}
+
+int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid,
+ xc_cpu_policy_t policy)
+{
+ unsigned int nr_leaves = ARRAY_SIZE(policy->leaves);
+ unsigned int nr_entries = ARRAY_SIZE(policy->entries);
+ int rc;
+
+ rc = xc_get_domain_cpu_policy(xch, domid, &nr_leaves, policy->leaves,
+ &nr_entries, policy->entries);
+ if ( rc )
+ {
+ PERROR("Failed to obtain domain %u policy", domid);
+ return rc;
+ }
+
+ rc = deserialize_policy(xch, policy, nr_leaves, nr_entries);
+ if ( rc )
+ {
+ errno = -rc;
+ rc = -1;
+ }
+
+ return rc;
+}
--
2.30.1
|