From: Bamvor Jian Zhang Subject: [PATCH RFC] improve the error message in "xl list --long" Date: Fri, 18 Oct 2013 00:21:58 +0800 Message-ID: <1382026918-19683-1-git-send-email-bjzhang@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: jfehlig@suse.com, ian.jackson@eu.citrix.com, Bamvor Jian Zhang List-Id: xen-devel@lists.xenproject.org with this patch, xl will raise a proper error when execute "xl list --long" for existed domain but no domain configuration found. it would encounter if other toolstack(like libvirt) create the vm, xl could saw the domain name but could not get the domain configuration. there is a commit a76377f1 check the return value of libxl_read_file_contents in libxl_userdata_retrieve. but skip the ENOENT. it is almost three years before. i do not know the senario about that commit. it seems that it is not safe to simplely remove the ENOENT. Signed-off-by: Bamvor Jian Zhang --- tools/libxl/libxl_dom.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 356f920..8daf51a 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1655,6 +1655,12 @@ int libxl_userdata_retrieve(libxl_ctx *ctx, uint32_t domid, goto out; } + if (access(filename, F_OK) != 0) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unknown domain configuration. Is domain id '%u' owned by another libxl toolstack?", domid); + rc = ERROR_INVAL; + goto out; + } + e = libxl_read_file_contents(ctx, filename, data_r ? &data : 0, &datalen); if (e && errno != ENOENT) { rc = ERROR_FAIL; -- 1.8.1.4