From: Ian Jackson Subject: Re: =?iso-8859-1?Q?=F0=B4:?= [PATCH] libxl: make libxl c ommunicate with xenstored by socket or xenb us driver Date: Wed, 8 Sep 2010 16:31:33 +0100 Message-ID: <19591.44117.955603.913010@mariner.uk.xensource.com> References: <433DDF91DFB08148BAD3FDB6FDDA314C9F35F3BB57@LONPMAILBOX01.citrite.net> <1283439564.12544.9720.camel@zakaz.uk.xensource.com> <433DDF91DFB08148BAD3FDB6FDDA314C9F35F3BB5B@LONPMAILBOX01.citrite.net> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <433DDF91DFB08148BAD3FDB6FDDA314C9F35F3BB5B@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: Ian Campbell , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Jun Zhu (Intern) writes ("=F0=B4: [Xen-devel] [PATCH] libxl: make libxl c= ommunicate with xenstored by socket or xenb us driver"): > libxl uses socket or xenbus dev to communicate with xenstored. Thanks for this patch. I have a few comments: > @@ -1387,10 +1385,8 @@ > { > libxl_device_model_starting *starting =3D for_spawn; > char *kvs[3]; > - int rc; > struct xs_handle *xsh; > =20 > - xsh =3D xs_daemon_open(); > /* we mustn't use the parent's handle in the child */ > =20 > kvs[0] =3D "image/device-model-pid"; > @@ -1398,10 +1394,11 @@ > return; > kvs[2] =3D NULL; > =20 > - rc =3D xs_writev(xsh, XBT_NULL, starting->dom_path, kvs); > - if (rc) > - return; > - xs_daemon_close(xsh); > + xsh =3D libxl_xs_open(); > + if (!xsh) > + fprintf(stderr, "cannot connect to xenstore"); > + xs_writev(xsh, XBT_NULL, starting->dom_path, kvs); > + libxl_xs_close(xsh); > } It's not clear to me why you're moving the open call about. Your error handling is incorrect, as passing a null xsh to xs_writev will cause a segfault. Also, while you're there you should probably fix the memory leak: this function always seems to leak kvs[0]. > - xsh =3D xs_daemon_open(); > + xsh =3D libxl_xs_open(); > + if (!xsh) > + XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, errno, > + "cannot connect to xenstore"); Logging is not sufficient; you need to set rc and "goto out", or return an error code, too. This pattern occurs a number of times in your patch. Finally, your patch seems to have been truncated at some point. patch(1) complains: patch: **** malformed patch at line 172: =20 Thanks, Ian.