From: Ian Jackson Date: Mon, 5 Jan 2015 14:31:00 +0000 (+0000) Subject: libxl: Initialise CTX->xce in domain suspend, as needed X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~4002 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6b511af68618a86d5a2258e649042a3f0b8ace52;p=xen.git libxl: Initialise CTX->xce in domain suspend, as needed 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 (new xl fmt info 0x1/0x0/12\ ) Savefile contains xl domain config in JSON format Parsing config from 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 Signed-off-by: Ian Jackson Acked-by: Ian Campbell Release-Acked-by: Konrad Rzeszutek Wilk Cc: Wei Liu --- diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 74ea84b74a..94ae8180ed 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -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); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 9695f18759..6dac0f8682 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -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.