[libvirt] [PATCH 3/3] util: storage: Improve error message when requesting image above 'start'

Martin Kletzander mkletzan at redhat.com
Wed Apr 22 12:09:18 UTC 2015


On Tue, Apr 21, 2015 at 05:52:14PM +0200, Peter Krempa wrote:
>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
>---
> src/util/virstoragefile.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
>diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
>index c9d3977..2a2f238 100644
>--- a/src/util/virstoragefile.c
>+++ b/src/util/virstoragefile.c
>@@ -1341,6 +1341,15 @@ virStorageFileChainLookup(virStorageSourcePtr chain,
>         *parent = startFrom;
>     }
>
>+    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));

Possible crasher: startFrom can be NULL here, rather move the check
into the previous block where the parent is being set when found (idx
can't be < i when there is no startFrom anyway).  You can then avoid
cleaning up the *parent here -+
                              |
                  +-----------+
                  |
                  v
>+        *parent = NULL;
>+        return NULL;
>+    }
>+

ACK series with that fixed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150422/df66d70d/attachment-0001.sig>


More information about the libvir-list mailing list