libxl: Initialise CTX->xce in domain suspend, as needed
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 5 Jan 2015 14:31:00 +0000 (14:31 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 5 Jan 2015 16:42:11 +0000 (16:42 +0000)
When excuting xl migrate/Remus, the following error can occur:
  [root@master xen]# xl migrate 5 slaver
  migration target: Ready to receive domain.
  Saving to migration stream new xl format (info 0x1/0x0/1225)
  Loading new save file <incoming migration stream> (new xl fmt info 0x1/0x0/12\
)
   Savefile contains xl domain config in JSON format
  Parsing config from <saved>
  Segmentation fault (core dumped)

This is because CTX->xce is used without been initialized.
The bug was introduced by commit 2ffeb5d7f5d8
    libxl: events: Deregister evtchn fd when not needed
which removed the initialization of xce from libxl__ctx_alloc.

In this patch we initialise the CTX->xce before using it.  Also, we
adjust the doc comment for libxl__ev_evtchn_* to mention the need to
do so.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Release-Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxl_dom.c
tools/libxl/libxl_internal.h

index 74ea84b74a1fd0ddd26df9a022b3463d0605e1e0..94ae8180ed6bbd156ed0740359c106c9cca2917f 100644 (file)
@@ -1824,6 +1824,9 @@ void libxl__domain_suspend(libxl__egc *egc, libxl__domain_suspend_state *dss)
     port = xs_suspend_evtchn_port(dss->domid);
 
     if (port >= 0) {
+        rc = libxl__ctx_evtchn_init(gc);
+        if (rc) goto out;
+
         dss->guest_evtchn.port =
             xc_suspend_evtchn_init_exclusive(CTX->xch, CTX->xce,
                                   dss->domid, port, &dss->guest_evtchn_lockfd);
index 9695f18759b7fdb83a659476477910f64244ba71..6dac0f8682e047f6de410557108d5caae4ad6261 100644 (file)
@@ -800,8 +800,10 @@ static inline int libxl__ev_xswatch_isregistered(const libxl__ev_xswatch *xw)
 
 /*
  * The evtchn facility is one-shot per call to libxl__ev_evtchn_wait.
- * You should call some suitable xc bind function on (or to obtain)
- * the port, then libxl__ev_evtchn_wait.
+ * You should:
+ *   Use libxl__ctx_evtchn_init to make sure CTX->xce is valid;
+ *   Call some suitable xc bind function on (or to obtain) the port;
+ *   Then call libxl__ev_evtchn_wait.
  *
  * When the event is signaled then the callback will be made, once.
  * Then you must call libxl__ev_evtchn_wait again, if desired.