]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: run libxl__arch_domain_create() much earlier.
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 9 Apr 2013 14:44:07 +0000 (15:44 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 9 Apr 2013 14:44:07 +0000 (15:44 +0100)
Among other things, arch_domain_create() sets the shadow(/hap/p2m)
memory allocation, which must happen after vcpus are assigned (or the
shadow op will fail) but before memory is allocated (or we might run
out of p2m memory).

libxl__build_pre(), which already sets similar things like maxmem,
semes like a reasonable spot for it.  That needed a bit of plumbing to
get the right datastructure from the caller.

As a side-effect, the return code from libxl__arch_domain_create() is
no longer ignored.

This bug was analysed in:
    From: "Jan Beulich" <JBeulich@xxxxxxxx>
    "Re: [Xen-devel] [xen-unstable test] 16788: regressions - FAIL"
    Date: Mon, 04 Mar 2013 16:34:53 +0000
    http://lists.xen.org/archives/html/xen-devel/2013-03/msg00191.html

Reported-by: Jan Beulich <JBeulich@suse.com>
Signed-off-by: Tim Deegan <tim@xen.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
(Cherry-picked from 650354dbc2626b643c12873275ca67782f1382c8.)

Conflicts:
tools/libxl/libxl_dom.c
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl_create.c
tools/libxl/libxl_dm.c
tools/libxl/libxl_dom.c
tools/libxl/libxl_internal.h

index e9a514871354caf52eb719d3b6c401f894f4a850..c6011fae2d723ad1673d263ba39b2371e50d2e7d 100644 (file)
@@ -328,15 +328,16 @@ static int init_console_info(libxl__device_console *console, int dev_num)
 }
 
 int libxl__domain_build(libxl__gc *gc,
-                        libxl_domain_build_info *info,
+                        libxl_domain_config *d_config,
                         uint32_t domid,
                         libxl__domain_build_state *state)
 {
+    libxl_domain_build_info *const info = &d_config->b_info;
     char **vments = NULL, **localents = NULL;
     struct timeval start_time;
     int i, ret;
 
-    ret = libxl__build_pre(gc, domid, info, state);
+    ret = libxl__build_pre(gc, domid, d_config, state);
     if (ret)
         goto out;
 
@@ -761,14 +762,14 @@ static void domcreate_bootloader_done(libxl__egc *egc,
     dcs->dmss.callback = domcreate_devmodel_started;
 
     if ( restore_fd < 0 ) {
-        rc = libxl__domain_build(gc, &d_config->b_info, domid, state);
+        rc = libxl__domain_build(gc, d_config, domid, state);
         domcreate_rebuild_done(egc, dcs, rc);
         return;
     }
 
     /* Restore */
 
-    rc = libxl__build_pre(gc, domid, info, state);
+    rc = libxl__build_pre(gc, domid, d_config, state);
     if (rc)
         goto out;
 
@@ -1127,7 +1128,6 @@ static void domcreate_attach_pci(libxl__egc *egc, libxl__multidev *multidev,
         }
     }
 
-    libxl__arch_domain_create(gc, d_config, domid);
     domcreate_console_available(egc, dcs);
 
     domcreate_complete(egc, dcs, 0);
index 423e4a4fcb795871e560731923dff1889f9e78d1..80b497307c32c758b61422297b0eb6392effa637 100644 (file)
@@ -817,7 +817,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
     if (ret)
         goto out;
     uint32_t dm_domid = sdss->pvqemu.guest_domid;
-    ret = libxl__domain_build(gc, &dm_config->b_info, dm_domid, stubdom_state);
+    ret = libxl__domain_build(gc, dm_config, dm_domid, stubdom_state);
     if (ret)
         goto out;
 
index 95da18e560b2e8b22a224a67a1f9140a469891f2..3e6622c3a548bf5f4334fb2e200b5748d2bb14ae 100644 (file)
@@ -18,6 +18,7 @@
 #include <glob.h>
 
 #include "libxl_internal.h"
+#include "libxl_arch.h"
 
 #include <xc_dom.h>
 #include <xen/hvm/hvm_info_table.h>
@@ -199,12 +200,14 @@ static int numa_place_domain(libxl__gc *gc, uint32_t domid,
 }
 
 int libxl__build_pre(libxl__gc *gc, uint32_t domid,
-              libxl_domain_build_info *info, libxl__domain_build_state *state)
+              libxl_domain_config *d_config, libxl__domain_build_state *state)
 {
+    libxl_domain_build_info *const info = &d_config->b_info;
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int tsc_mode;
     char *xs_domid, *con_domid;
     uint32_t rtc_timeoffset;
+    int rc;
 
     xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus);
 
@@ -218,7 +221,6 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
      * whatever that turns out to be.
      */
     if (libxl_defbool_val(info->numa_placement)) {
-        int rc;
 
         if (!libxl_bitmap_is_full(&info->cpumap)) {
             LOG(ERROR, "Can run NUMA placement only if no vcpu "
@@ -288,7 +290,9 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
     state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->console_domid);
     state->vm_generationid_addr = 0;
 
-    return 0;
+    rc = libxl__arch_domain_create(gc, d_config, domid);
+
+    return rc;
 }
 
 int libxl__build_post(libxl__gc *gc, uint32_t domid,
index 9603b99cb3c194fc095f7e07b06ad9c53aaa568f..13fa509e73a0c1d9d2e9847802110763c9796aa4 100644 (file)
@@ -881,7 +881,8 @@ typedef struct {
 } libxl__domain_build_state;
 
 _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid,
-              libxl_domain_build_info *info, libxl__domain_build_state *state);
+              libxl_domain_config * const d_config,
+              libxl__domain_build_state *state);
 _hidden int libxl__build_post(libxl__gc *gc, uint32_t domid,
                libxl_domain_build_info *info, libxl__domain_build_state *state,
                char **vms_ents, char **local_ents);
@@ -1274,7 +1275,7 @@ _hidden int libxl__domain_make(libxl__gc *gc,
                                uint32_t *domid);
 
 _hidden int libxl__domain_build(libxl__gc *gc,
-                                libxl_domain_build_info *info,
+                                libxl_domain_config *d_config,
                                 uint32_t domid,
                                 libxl__domain_build_state *state);