From: Peter Krempa Date: Tue, 21 Apr 2015 15:38:08 +0000 (+0200) Subject: util: storage: Improve error message when requesting image above 'start' X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=dff92b3f2fe63da63391f929134b06d3be992a40;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git util: storage: Improve error message when requesting image above 'start' When a user would specify a backing chain index that is above the start point libvirt would report a rather unhelpful error: invalid argument: could not find backing store 1 in chain for 'sub/link2' This patch adds an explicit check that the index is below start point in the backing store and reports the following error if not: invalid argument: requested backing store index 1 is above 'sub/../qcow2' in chain for 'sub/link2' Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1177062 --- diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index c9d3977f3..9507ca191 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1338,6 +1338,15 @@ virStorageFileChainLookup(virStorageSourcePtr chain, chain = chain->backingStore; i++; } + + if (idx && idx < i) { + virReportError(VIR_ERR_INVALID_ARG, + _("requested backing store index %u is above '%s' " + "in chain for '%s'"), + idx, NULLSTR(startFrom->path), NULLSTR(start)); + return NULL; + } + *parent = startFrom; }