From: Ian Campbell Subject: Re: [PATCH] libxl: make libxl communicate with xenstored by socket or xenbus driver Date: Thu, 2 Sep 2010 15:59:24 +0100 Message-ID: <1283439564.12544.9720.camel@zakaz.uk.xensource.com> References: <433DDF91DFB08148BAD3FDB6FDDA314C9F35F3BB57@LONPMAILBOX01.citrite.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <433DDF91DFB08148BAD3FDB6FDDA314C9F35F3BB57@LONPMAILBOX01.citrite.net> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "Jun Zhu (Intern)" Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Thu, 2010-09-02 at 14:56 +0100, Jun Zhu (Intern) wrote: > Hi, > > George sent a patch on this problem before, but it was not completed. > This patch makes libxl use xenbus to communicate with xenstored if > libxl cannot open a socket. I think rather than repeating the pattern: xsh = xs_daemon_open(); if (!xsh) xsh = xs_domain_open(); everywhere we should add libxl__xenstore_open() instead. > There's a place that does not close fd in the case of failure, which > is also fixed in this patch. It's a small patch in this case but generally it is best to put separate fixes in separate patches. Also you need to add a Signed-off-by to your patches. I suspect the maintainers would also appreciate it if you would format the email as DESCRIPTION Signed-off-by: PATCH without additional punctuation or delineation (such as ---Patch----) which they need to edit out when applying. Ian. > > -----------------------------------------Patch------------------------------------------------------ > diff -r eff592364826 tools/libxl/libxl.c > --- a/tools/libxl/libxl.c Wed Sep 01 11:23:49 2010 +0100 > +++ b/tools/libxl/libxl.c Thu Sep 02 14:51:46 2010 +0100 > @@ -1387,10 +1387,8 @@ > { > libxl_device_model_starting *starting = for_spawn; > char *kvs[3]; > - int rc; > struct xs_handle *xsh; > > - xsh = xs_daemon_open(); > /* we mustn't use the parent's handle in the child */ > > kvs[0] = "image/device-model-pid"; > @@ -1398,9 +1396,10 @@ > return; > kvs[2] = NULL; > > - rc = xs_writev(xsh, XBT_NULL, starting->dom_path, kvs); > - if (rc) > - return; > + xsh = xs_daemon_open(); > + if (!xsh) > + xsh = xs_domain_open(); > + xs_writev(xsh, XBT_NULL, starting->dom_path, kvs); > xs_daemon_close(xsh); > } > > diff -r eff592364826 tools/libxl/libxl_device.c > --- a/tools/libxl/libxl_device.c Wed Sep 01 11:23:49 2010 +0100 > +++ b/tools/libxl/libxl_device.c Thu Sep 02 14:51:46 2010 +0100 > @@ -406,6 +406,8 @@ > char **l = NULL; > > xsh = xs_daemon_open(); > + if (!xsh) > + xsh = xs_domain_open(); > path = libxl_sprintf(&gc, "/local/domain/0/device-model/%d/state", domid); > xs_watch(xsh, path, path); > tv.tv_sec = LIBXL_DEVICE_MODEL_START_TIMEOUT; > diff -r eff592364826 tools/libxl/libxl_dom.c > --- a/tools/libxl/libxl_dom.c Wed Sep 01 11:23:49 2010 +0100 > +++ b/tools/libxl/libxl_dom.c Thu Sep 02 14:51:46 2010 +0100 > @@ -284,6 +284,8 @@ > snprintf(path, sizeof(path), "/local/domain/0/device-model/%u/logdirty/cmd", domid); > > xsh = xs_daemon_open(); > + if (!xsh) > + xsh = xs_domain_open(); > > if (enable) > xs_write(xsh, XBT_NULL, path, "enable", strlen("enable")); > diff -r eff592364826 tools/libxl/libxl_utils.c > --- a/tools/libxl/libxl_utils.c Wed Sep 01 11:23:49 2010 +0100 > +++ b/tools/libxl/libxl_utils.c Thu Sep 02 14:51:46 2010 +0100 > @@ -368,6 +368,8 @@ > int libxl_ctx_postfork(libxl_ctx *ctx) { > if (ctx->xsh) xs_daemon_destroy_postfork(ctx->xsh); > ctx->xsh = xs_daemon_open(); > + if (!ctx->xsh) > + ctx->xsh = xs_domain_open(); > if (!ctx->xsh) return ERROR_FAIL; > return 0; > } > --------------------------------------END---------------------------------------------- > > > Jun Zhu > Citrix Systems UK > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel