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

[Xen-devel] [PATCH v2 11/17] tools/libxl: Re-position CPUID handling during domain construction



CPUID handling needs to be earlier in construction.  Move it from its current
position in libxl__build_post() to libxl__build_pre() for fresh builds, and
libxl__srm_callout_callback_static_data_done() for the migration/resume case.

Later changes will make the migration/resume case conditional on whether CPUID
data was present in the migration stream, and the libxc layer took care of
restoring it.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
CC: Ian Jackson <Ian.Jackson@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
CC: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 tools/libxl/libxl_create.c |  8 +++++++-
 tools/libxl/libxl_dom.c    | 16 ++++++++++++----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 1d2e193509..09f84858d5 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1303,8 +1303,14 @@ int libxl__srm_callout_callback_static_data_done(void 
*user)
     libxl__save_helper_state *shs = user;
     libxl__domain_create_state *dcs = shs->caller_state;
     STATE_AO_GC(dcs->ao);
+    libxl_ctx *ctx = libxl__gc_owner(gc);
+
+    const libxl_domain_config *d_config = dcs->guest_config;
+    const libxl_domain_build_info *info = &d_config->b_info;
 
-    /* Nothing to do (yet). */
+    libxl__cpuid_apply_policy(ctx, dcs->guest_domid);
+    if (info->cpuid != NULL)
+        libxl__cpuid_set(ctx, dcs->guest_domid, info->cpuid);
 
     return 0;
 }
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index 1bac277351..5dc8369eda 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -389,6 +389,18 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
 
     rc = libxl__arch_domain_create(gc, d_config, domid);
 
+    /* Construct a CPUID policy, but only for brand new domains.  Domains
+     * being migrated-in/restored have CPUID handled during the
+     * static_data_done() callback. */
+    if (!restore) {
+        /* For x86 at least, libxl_cpuid_apply_policy() takes an implicit
+         * parameter, HVM_PARAM_PAE_ENABLED, which is only set up in
+         * libxl__arch_domain_create(). */
+        libxl_cpuid_apply_policy(ctx, domid);
+        if (info->cpuid != NULL)
+            libxl_cpuid_set(ctx, domid, info->cpuid);
+    }
+
     return rc;
 }
 
@@ -456,10 +468,6 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid,
     if (rc)
         return rc;
 
-    libxl__cpuid_apply_policy(ctx, domid);
-    if (info->cpuid != NULL)
-        libxl__cpuid_set(ctx, domid, info->cpuid);
-
     if (info->type == LIBXL_DOMAIN_TYPE_HVM
         && !libxl_ms_vm_genid_is_zero(&info->u.hvm.ms_vm_genid)) {
         rc = libxl__ms_vm_genid_set(gc, domid,
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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