[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/7] tools/xg: Split xc_cpu_policy_set_domain()



xc_cpu_policy_set_domain_from_serialised() converts the cpu policy into its
serialised form first and then sends that to Xen. Meanwhile,
xc_cpu_policy_domain_set_from_deserialised() uses whatever is already in
the internal serialisation buffer of the policy object.

This split helps in a future patch where modifications are done in the
serialized form and we don't want to do a serialization round-trip to
send it to Xen.

Signed-off-by: Alejandro Vallejo <alejandro.vallejo@xxxxxxxxx>
---
 tools/include/xenguest.h        |  8 ++++++--
 tools/libs/guest/xg_cpuid_x86.c | 24 ++++++++++++++----------
 tools/tests/tsx/test-tsx.c      |  2 +-
 3 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h
index 702965addc..a66d9f7807 100644
--- a/tools/include/xenguest.h
+++ b/tools/include/xenguest.h
@@ -795,8 +795,12 @@ 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_cpu_policy_set_domain(xc_interface *xch, uint32_t domid,
-                             xc_cpu_policy_t *policy);
+int xc_cpu_policy_set_domain_from_serialised(xc_interface *xch,
+                                             uint32_t domid,
+                                             xc_cpu_policy_t *policy);
+int xc_cpu_policy_set_domain_from_deserialised(xc_interface *xch,
+                                               uint32_t domid,
+                                               xc_cpu_policy_t *policy);
 
 /* Manipulate a policy via architectural representations. */
 int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t *policy,
diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index ac75ce2b4e..8fafeb2a02 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -985,20 +985,24 @@ int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t 
domid,
     return rc;
 }
 
-int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid,
-                             xc_cpu_policy_t *policy)
+int xc_cpu_policy_set_domain_from_deserialised(xc_interface *xch, uint32_t 
domid,
+                                               xc_cpu_policy_t *policy)
 {
-    uint32_t err_leaf = -1, err_subleaf = -1, err_msr = -1;
     int rc;
-
-    rc = cpu_policy_serialise_on_self(xch, policy);
-    if ( rc )
+    if ( (rc = cpu_policy_serialise_on_self(xch, policy)) )
         return rc;
 
-    rc = xc_set_domain_cpu_policy(xch, domid,
-                                  policy->leaves.len, policy->leaves.buf,
-                                  policy->msrs.len, policy->msrs.buf,
-                                  &err_leaf, &err_subleaf, &err_msr);
+    return xc_cpu_policy_set_domain_from_serialised(xch, domid, policy);
+}
+
+int xc_cpu_policy_set_domain_from_serialised(xc_interface *xch, uint32_t domid,
+                                             xc_cpu_policy_t *policy)
+{
+    uint32_t err_leaf = -1, err_subleaf = -1, err_msr = -1;
+    int rc = xc_set_domain_cpu_policy(xch, domid,
+                                      policy->leaves.len, policy->leaves.buf,
+                                      policy->msrs.len, policy->msrs.buf,
+                                      &err_leaf, &err_subleaf, &err_msr);
     if ( rc )
     {
         ERROR("Failed to set domain %u policy (%d = %s)", domid, -rc,
diff --git a/tools/tests/tsx/test-tsx.c b/tools/tests/tsx/test-tsx.c
index 3371bb26f7..21b5640796 100644
--- a/tools/tests/tsx/test-tsx.c
+++ b/tools/tests/tsx/test-tsx.c
@@ -405,7 +405,7 @@ static void test_guest(struct xen_domctl_createdomain *c)
                 (bitmaskof(X86_FEATURE_HLE) | bitmaskof(X86_FEATURE_RTM)));
 
         /* Set the new policy. */
-        rc = xc_cpu_policy_set_domain(xch, domid, guest_policy);
+        rc = xc_cpu_policy_set_domain_from_deserialised(xch, domid, 
guest_policy);
         if ( rc )
         {
             fail("  Failed to set domain policy: %d - %s\n",
-- 
2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.